@Override public synchronized void start(StartContext context) throws StartException { ServiceController<?> controller = context.getController(); LOGGER.tracef("Starting: %s in mode %s", controller.getName(), controller.getMode()); try { ServiceContainer serviceContainer = context.getController().getServiceContainer(); // Setup the OSGi {@link Framework} properties SubsystemState subsystemState = injectedSubsystemState.getValue(); Map<String, Object> props = new HashMap<String, Object>(subsystemState.getProperties()); setupIntegrationProperties(context, props); // Register the URLStreamHandlerFactory Module coreFrameworkModule = ((ModuleClassLoader) FrameworkBuilder.class.getClassLoader()).getModule(); Module.registerURLStreamHandlerFactoryModule(coreFrameworkModule); Module.registerContentHandlerFactoryModule(coreFrameworkModule); ServiceTarget serviceTarget = context.getChildTarget(); JAXPServiceProvider.addService(serviceTarget); ResolverService.addService(serviceTarget); RepositoryService.addService(serviceTarget); Activation activation = subsystemState.getActivationPolicy(); Mode initialMode = (activation == Activation.EAGER ? Mode.ACTIVE : Mode.LAZY); // Configure the {@link Framework} builder FrameworkBuilder builder = FrameworkBuilderFactory.create(props, initialMode); builder.setServiceContainer(serviceContainer); builder.setServiceTarget(serviceTarget); builder.createFrameworkServices(serviceContainer, true); builder.registerIntegrationService(FrameworkPhase.CREATE, new BundleLifecycleIntegration()); builder.registerIntegrationService( FrameworkPhase.CREATE, new FrameworkModuleIntegration(props)); builder.registerIntegrationService(FrameworkPhase.CREATE, new ModuleLoaderIntegration()); builder.registerIntegrationService( FrameworkPhase.CREATE, new SystemServicesIntegration(resource, extensions)); builder.registerIntegrationService(FrameworkPhase.INIT, new BootstrapBundlesIntegration()); builder.registerIntegrationService( FrameworkPhase.INIT, new PersistentBundlesIntegration(deploymentTracker)); // Install the services to create the framework builder.installServices(FrameworkPhase.CREATE, serviceTarget, verificationHandler); if (activation == Activation.EAGER) { builder.installServices(FrameworkPhase.INIT, serviceTarget, verificationHandler); builder.installServices(FrameworkPhase.ACTIVE, serviceTarget, verificationHandler); } // Create the framework activator FrameworkActivator.create(builder); } catch (Throwable th) { throw MESSAGES.startFailedToCreateFrameworkServices(th); } }