}
};
// executor used for creating the appCtx
// chosen based on the sync/async configuration
TaskExecutor executor = null;
ApplicationContextConfiguration config = new ApplicationContextConfiguration(bundle);
String creationType;
// synch/asynch context creation
if (config.isCreateAsynchronously()) {
// for the async stuff use the executor
executor = taskExecutor;
creationType = "Asynchronous";
}
else {
// for the sync stuff, use this thread
executor = sameThreadTaskExecutor;
creationType = "Synchronous";
}
if (debug) {
log.debug(creationType + " context creation for bundle " + bundleString);
}
// wait/no wait for dependencies behaviour
if (config.isWaitForDependencies()) {
DependencyWaiterApplicationContextExecutor appCtxExecutor = new DependencyWaiterApplicationContextExecutor(
localApplicationContext, !config.isCreateAsynchronously(),
extenderConfiguration.getDependencyFactories());
appCtxExecutor.setTimeout(config.getTimeout());
appCtxExecutor.setWatchdog(timer);
appCtxExecutor.setTaskExecutor(executor);
appCtxExecutor.setMonitoringCounter(contextsStarted);
// set events publisher
appCtxExecutor.setDelegatedMulticaster(this.multicaster);
contextsStarted.increment();
}
else {
// do nothing; by default contexts do not wait for services.
}
executor.execute(contextRefresh);
}