// 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());
long timeout;
// check whether a timeout has been defined
if (ConfigUtils.isDirectiveDefined(bundle.getHeaders(), ConfigUtils.DIRECTIVE_TIMEOUT)) {
timeout = config.getTimeout();
if (debug)
log.debug("Setting bundle-defined, wait-for-dependencies timeout value=" + timeout
+ " ms, for bundle " + bundleString);
}
else {
timeout = extenderConfiguration.getDependencyWaitTime();
if (debug)
log.debug("Setting globally defined wait-for-dependencies timeout value=" + timeout
+ " ms, for bundle " + bundleString);
}
appCtxExecutor.setTimeout(config.getTimeout());
appCtxExecutor.setWatchdog(timer);
appCtxExecutor.setTaskExecutor(executor);
appCtxExecutor.setMonitoringCounter(contextsStarted);
// set events publisher