use of org.apache.aries.blueprint.utils.threading.ScheduledExecutorServiceWrapper.ScheduledExecutorServiceFactory in project aries by apache.
the class BlueprintExtender method start.
public void start(BundleContext ctx) {
LOGGER.debug("Starting blueprint extender...");
this.context = ctx;
boolean useSystemContext = Boolean.parseBoolean(ctx.getProperty("org.apache.aries.blueprint.use.system.context"));
BundleContext trackingContext = useSystemContext ? ctx.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).getBundleContext() : ctx;
handlers = new NamespaceHandlerRegistryImpl(trackingContext);
executors = new ScheduledExecutorServiceWrapper(ctx, "Blueprint Extender", new ScheduledExecutorServiceFactory() {
public ScheduledExecutorService create(String name) {
return Executors.newScheduledThreadPool(3, new BlueprintThreadFactory(name));
}
});
eventDispatcher = new BlueprintEventDispatcher(ctx, executors);
// Ideally we'd want to only track STARTING and ACTIVE bundle, but this is not supported
// when using equinox composites. This would ensure that no STOPPING event is lost while
// tracking the initial bundles. To work around this issue, we need to register
// a synchronous bundle listener that will ensure the stopping event will be correctly
// handled.
context.addBundleListener(this);
int mask = Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING | Bundle.ACTIVE;
bt = useSystemContext ? new BundleTracker(trackingContext, mask, this) : new RecursiveBundleTracker(ctx, mask, this);
proxyManager = new SingleServiceTracker<ProxyManager>(ctx, ProxyManager.class, new SingleServiceListener() {
public void serviceFound() {
LOGGER.debug("Found ProxyManager service, starting to process blueprint bundles");
if (bt instanceof BundleTracker) {
((BundleTracker) bt).open();
} else if (bt instanceof RecursiveBundleTracker) {
((RecursiveBundleTracker) bt).open();
}
}
public void serviceLost() {
while (!containers.isEmpty()) {
for (Bundle bundle : getBundlesToDestroy()) {
destroyContainer(bundle);
}
}
if (bt instanceof BundleTracker) {
((BundleTracker) bt).close();
} else if (bt instanceof RecursiveBundleTracker) {
((RecursiveBundleTracker) bt).close();
}
}
public void serviceReplaced() {
}
});
proxyManager.open();
// Determine if the ParserService should ignore unknown namespace handlers
boolean ignoreUnknownNamespaceHandlers = Boolean.parseBoolean(ctx.getProperty("org.apache.aries.blueprint.parser.service.ignore.unknown.namespace.handlers"));
// Create and publish a ParserService
parserServiceReg = ctx.registerService(ParserService.class.getName(), new ParserServiceImpl(handlers, ignoreUnknownNamespaceHandlers), new Hashtable<String, Object>());
// Create and publish a BlueprintContainerService
blueprintServiceReg = ctx.registerService(BlueprintExtenderService.class.getName(), new BlueprintContainerServiceImpl(), new Hashtable<String, Object>());
try {
ctx.getBundle().loadClass(QUIESCE_PARTICIPANT_CLASS);
//Class was loaded, register
quiesceParticipantReg = ctx.registerService(QUIESCE_PARTICIPANT_CLASS, new BlueprintQuiesceParticipant(ctx, this), new Hashtable<String, Object>());
} catch (ClassNotFoundException e) {
LOGGER.info("No quiesce support is available, so blueprint components will not participate in quiesce operations");
}
LOGGER.debug("Blueprint extender started");
}
Aggregations