Search in sources :

Example 1 with BundleServiceImpl

use of org.apache.karaf.bundle.core.internal.BundleServiceImpl in project karaf by apache.

the class Activator method doStart.

@Override
protected void doStart() throws Exception {
    ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
    if (configurationAdmin == null) {
        return;
    }
    final BundleServiceImpl bundleService = new BundleServiceImpl(bundleContext);
    register(BundleService.class, bundleService);
    bundleStateServicesTracker = new ServiceTracker<>(bundleContext, BundleStateService.class, new ServiceTrackerCustomizer<BundleStateService, BundleStateService>() {

        @Override
        public BundleStateService addingService(ServiceReference<BundleStateService> reference) {
            BundleStateService service = bundleContext.getService(reference);
            bundleService.registerBundleStateService(service);
            return service;
        }

        @Override
        public void modifiedService(ServiceReference<BundleStateService> reference, BundleStateService service) {
        }

        @Override
        public void removedService(ServiceReference<BundleStateService> reference, BundleStateService service) {
            bundleService.unregisterBundleStateService(service);
            bundleContext.ungetService(reference);
        }
    });
    bundleStateServicesTracker.open();
    bundleWatcher = new BundleWatcherImpl(bundleContext, new MavenConfigService(configurationAdmin), bundleService);
    bundleWatcher.start();
    register(BundleWatcher.class, bundleWatcher);
    BundlesMBeanImpl bundlesMBeanImpl = new BundlesMBeanImpl(bundleContext, bundleService);
    registerMBean(bundlesMBeanImpl, "type=bundle");
}
Also used : MavenConfigService(org.apache.karaf.bundle.core.internal.MavenConfigService) BundleStateService(org.apache.karaf.bundle.core.BundleStateService) BundleWatcherImpl(org.apache.karaf.bundle.core.internal.BundleWatcherImpl) BundleServiceImpl(org.apache.karaf.bundle.core.internal.BundleServiceImpl) ServiceTrackerCustomizer(org.osgi.util.tracker.ServiceTrackerCustomizer) BundlesMBeanImpl(org.apache.karaf.bundle.core.internal.BundlesMBeanImpl) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

BundleStateService (org.apache.karaf.bundle.core.BundleStateService)1 BundleServiceImpl (org.apache.karaf.bundle.core.internal.BundleServiceImpl)1 BundleWatcherImpl (org.apache.karaf.bundle.core.internal.BundleWatcherImpl)1 BundlesMBeanImpl (org.apache.karaf.bundle.core.internal.BundlesMBeanImpl)1 MavenConfigService (org.apache.karaf.bundle.core.internal.MavenConfigService)1 ServiceReference (org.osgi.framework.ServiceReference)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1 ServiceTrackerCustomizer (org.osgi.util.tracker.ServiceTrackerCustomizer)1