public DataSourceDeploymentInfo resync(DataSourceDef dataSourceDef, DataSourceDeploymentInfo deploymentInfo) throws Exception { javax.sql.DataSource dataSource = (javax.sql.DataSource) jndiLookupDataSource(deploymentInfo.getJndi()); WildlfyDataSource wfDataSource = new WildlfyDataSource(dataSource, deploymentInfo.getJndi()); managedDataSources.put(deploymentInfo.getDeploymentId(), wfDataSource); return deploymentInfo; }
@Override public DataSource lookupDataSource(DataSourceDeploymentInfo deploymentInfo) throws Exception { WildlfyDataSource dataSource = managedDataSources.get(deploymentInfo.getDeploymentId()); if (dataSource == null) { dataSource = unManagedDataSources.get(deploymentInfo.getDeploymentId()); } if (dataSource == null) { DataSourceDeploymentInfo refreshedDeploymentInfo = getDeploymentInfo(deploymentInfo.getUuid()); if (refreshedDeploymentInfo != null && refreshedDeploymentInfo.getJndi() != null) { javax.sql.DataSource sqlDataSource = (javax.sql.DataSource) jndiLookupDataSource(refreshedDeploymentInfo.getJndi()); if (sqlDataSource != null) { dataSource = new WildlfyDataSource(sqlDataSource, refreshedDeploymentInfo.getJndi()); unManagedDataSources.put(deploymentInfo.getDeploymentId(), dataSource); return dataSource; } } } if (dataSource != null) { if (dataSource.isNew()) { //first access to the data source dataSource.setStatus(DataSourceStatus.REFERENCED); } return dataSource; } else { throw new Exception("Data source for: " + deploymentInfo + " is not deployed in current system."); } }
@Override public String getJndi() { if (view.getSelectedRow().getDataSourceDefInfo().getDeploymentInfo() != null) { return view.getSelectedRow().getDataSourceDefInfo().getDeploymentInfo().getJndi(); } return null; }