Author: rareddy
Date: 2012-09-17 11:38:33 -0400 (Mon, 17 Sep 2012)
New Revision: 4450
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
Log:
TEIID-2212 - This was result of non service code and service code and their lifecycles;
separated them by responsibilities now.
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-09-17
11:25:25 UTC (rev 4449)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-09-17
15:38:33 UTC (rev 4450)
@@ -421,7 +421,7 @@
processorTarget.addDeploymentProcessor(Phase.STRUCTURE,
Phase.STRUCTURE_WAR_DEPLOYMENT_INIT|0x0001,new VDBStructureDeployer());
processorTarget.addDeploymentProcessor(Phase.PARSE,
Phase.PARSE_WEB_DEPLOYMENT|0x0001, new VDBParserDeployer());
processorTarget.addDeploymentProcessor(Phase.DEPENDENCIES,
Phase.DEPENDENCIES_WAR_MODULE|0x0001, new VDBDependencyDeployer());
- processorTarget.addDeploymentProcessor(Phase.INSTALL,
Phase.INSTALL_WAR_DEPLOYMENT|0x1000, new VDBDeployer(translatorRepo, asyncThreadPoolName,
statusChecker, shutdownListener));
+ processorTarget.addDeploymentProcessor(Phase.INSTALL,
Phase.INSTALL_WAR_DEPLOYMENT|0x1000, new VDBDeployer(translatorRepo, asyncThreadPoolName,
vdbRepository, shutdownListener));
// translator deployers
processorTarget.addDeploymentProcessor(Phase.STRUCTURE,
Phase.STRUCTURE_JDBC_DRIVER|0x0001,new TranslatorStructureDeployer());
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2012-09-17
11:25:25 UTC (rev 4449)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2012-09-17
15:38:33 UTC (rev 4450)
@@ -1389,9 +1389,7 @@
synchronized (vdb.getVdb()) {
ReplaceResult rr = vdb.assignDatasource(modelName, sourceName, translatorName,
dsName);
if (rr.isNew) {
- ServiceController<?> sc =
context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_STATUS_CHECKER);
- VDBStatusChecker vsc = VDBStatusChecker.class.cast(sc.getValue());
- VDBDeployer.addDataSourceListener(context.getServiceTarget(), new
VDBKey(vdb.getVdb().getName(), vdb.getVdb().getVersion()), dsName, vsc);
+ VDBDeployer.addDataSourceListener(context.getServiceTarget(), new
VDBKey(vdb.getVdb().getName(), vdb.getVdb().getVersion()), dsName);
}
if (rr.removedDs != null) {
final ServiceRegistry registry = context.getServiceRegistry(true);
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-09-17
11:25:25 UTC (rev 4449)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-09-17
15:38:33 UTC (rev 4450)
@@ -81,13 +81,13 @@
private static final String JAVA_CONTEXT = "java:/"; //$NON-NLS-1$
private TranslatorRepository translatorRepository;
private String asyncThreadPoolName;
- private VDBStatusChecker vdbStatusChecker;
+ private VDBRepository vdbRepository;
JBossLifeCycleListener shutdownListener;
- public VDBDeployer (TranslatorRepository translatorRepo, String poolName,
VDBStatusChecker vdbStatusChecker, JBossLifeCycleListener shutdownListener) {
+ public VDBDeployer (TranslatorRepository translatorRepo, String poolName, VDBRepository
vdbRepo, JBossLifeCycleListener shutdownListener) {
this.translatorRepository = translatorRepo;
this.asyncThreadPoolName = poolName;
- this.vdbStatusChecker = vdbStatusChecker;
+ this.vdbRepository = vdbRepo;
this.shutdownListener = shutdownListener;
}
@@ -154,8 +154,7 @@
indexRepo = new IndexMetadataRepository(indexFactory);
visibilityMap = indexFactory.getEntriesPlusVisibilities();
}
- VDBRepository repo = vdbStatusChecker.getVDBRepository();
- repo.addPendingDeployment(deployment);
+ this.vdbRepository.addPendingDeployment(deployment);
// build a VDB service
final VDBService vdb = new VDBService(deployment, visibilityMap);
if (indexRepo != null) {
@@ -255,13 +254,14 @@
static void addDataSourceListener(
final ServiceTarget serviceTarget,
final VDBKey vdbKey,
- final String dsName, VDBStatusChecker vdbStatusChecker) {
+ final String dsName) {
final String jndiName = getJndiName(dsName);
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
final ServiceName svcName = bindInfo.getBinderServiceName();
- DataSourceListener dsl = new DataSourceListener(dsName, svcName, vdbStatusChecker,
vdbKey);
+ DataSourceListener dsl = new DataSourceListener(dsName, svcName, vdbKey);
ServiceBuilder<DataSourceListener> sb =
serviceTarget.addService(TeiidServiceNames.dsListenerServiceName(vdbKey.getName(),
vdbKey.getVersion(), dsName), dsl);
sb.addDependency(svcName);
+ sb.addDependency(TeiidServiceNames.VDB_STATUS_CHECKER, VDBStatusChecker.class,
dsl.vdbStatusCheckInjector);
sb.setInitialMode(Mode.PASSIVE).install();
}
@@ -284,21 +284,20 @@
if (!dataSources.add(VDBStatusChecker.stripContext(dsName))) {
continue; //already listening
}
- addDataSourceListener(serviceTarget, vdbKey, dsName, vdbStatusChecker);
+ addDataSourceListener(serviceTarget, vdbKey, dsName);
}
}
}
static class DataSourceListener implements Service<DataSourceListener>{
- private VDBStatusChecker vdbStatusChecker;
private String dsName;
private ServiceName svcName;
private VDBKey vdb;
+ InjectedValue<VDBStatusChecker> vdbStatusCheckInjector = new
InjectedValue<VDBStatusChecker>();
- public DataSourceListener(String dsName, ServiceName svcName, VDBStatusChecker checker,
VDBKey vdb) {
+ public DataSourceListener(String dsName, ServiceName svcName, VDBKey vdb) {
this.dsName = dsName;
this.svcName = svcName;
- this.vdbStatusChecker = checker;
this.vdb = vdb;
}
@@ -310,7 +309,7 @@
public void start(StartContext context) throws StartException {
ServiceController<?> s =
context.getController().getServiceContainer().getService(this.svcName);
if (s != null) {
- this.vdbStatusChecker.dataSourceAdded(this.dsName, vdb);
+ this.vdbStatusCheckInjector.getValue().dataSourceAdded(this.dsName, vdb);
}
}
@@ -318,7 +317,7 @@
public void stop(StopContext context) {
ServiceController<?> s =
context.getController().getServiceContainer().getService(this.svcName);
if (s.getMode().equals(Mode.REMOVE) || s.getState().equals(State.STOPPING)) {
- this.vdbStatusChecker.dataSourceRemoved(this.dsName, vdb);
+ this.vdbStatusCheckInjector.getValue().dataSourceRemoved(this.dsName, vdb);
}
}
}
@@ -348,7 +347,7 @@
LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+vdb.getName()+"
metadata removed"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- this.vdbStatusChecker.getVDBRepository().removeVDB(deployment.getName(),
deployment.getVersion());
+ this.vdbRepository.removeVDB(deployment.getName(), deployment.getVersion());
for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
for (SourceMappingMetadata smm:model.getSources().values()) {