org.osgi.service.component.ComponentContext Java Examples
The following examples show how to use
org.osgi.service.component.ComponentContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhasedRecoveryManager.java From onos with Apache License 2.0 | 6 votes |
@Activate protected void activate(ComponentContext context) { appId = coreService.registerApplication(APP_NAME); KryoNamespace.Builder serializer = KryoNamespace.newBuilder() .register(KryoNamespaces.API) .register(Phase.class); phasedRecoveryStore = storageService.<DeviceId, Phase>consistentMapBuilder() .withName("onos-sr-phasedrecovery") .withRelaxedReadConsistency() .withSerializer(Serializer.using(serializer.build())) .build(); compCfgService.registerProperties(getClass()); modified(context); log.info("Started"); }
Example #2
Source File: SecurityMgtServiceComponent.java From carbon-identity with Apache License 2.0 | 6 votes |
protected void activate(ComponentContext ctxt) { try { ConfigurationContext mainConfigCtx = configContextService.getServerConfigContext(); AxisConfiguration mainAxisConfig = mainConfigCtx.getAxisConfiguration(); BundleContext bundleCtx = ctxt.getBundleContext(); String enablePoxSecurity = ServerConfiguration.getInstance() .getFirstProperty("EnablePoxSecurity"); if (enablePoxSecurity == null || "true".equals(enablePoxSecurity)) { mainAxisConfig.engageModule(POX_SECURITY_MODULE); } else { log.info("POX Security Disabled"); } bundleCtx.registerService(SecurityConfigAdmin.class.getName(), new SecurityConfigAdmin(mainAxisConfig, registryService.getConfigSystemRegistry(), null), null); bundleCtx.registerService(Axis2ConfigurationContextObserver.class.getName(), new SecurityAxis2ConfigurationContextObserver(), null); log.debug("Security Mgt bundle is activated"); } catch (Throwable e) { log.error("Failed to activate SecurityMgtServiceComponent", e); } }
Example #3
Source File: APIKeyMgtServiceComponent.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Activate protected void activate(ComponentContext ctxt) { try { APIKeyMgtDataHolder.initData(); log.debug("Key Manager User Operation Listener is enabled."); // Register subscription datastore related service serviceRegistration = ctxt.getBundleContext().registerService( Axis2ConfigurationContextObserver.class.getName(), new ServerStartupListener(), null); serviceRegistration = ctxt.getBundleContext().registerService( ServerStartupObserver.class.getName(), new ServerStartupListener(), null); // Register KeyManagerDataService serviceRegistration = ctxt.getBundleContext().registerService(KeyManagerDataService.class.getName(), new KeyManagerDataServiceImpl(), null); if (log.isDebugEnabled()) { log.debug("Identity API Key Mgt Bundle is started."); } } catch (Exception e) { log.error("Failed to initialize key management service.", e); } }
Example #4
Source File: HostManager.java From onos with Apache License 2.0 | 6 votes |
@Modified public void modified(ComponentContext context) { boolean oldValue = monitorHosts; readComponentConfiguration(context); if (probeRate > 0) { monitor.setProbeRate(probeRate); } else { log.warn("ProbeRate cannot be less than 0"); } if (oldValue != monitorHosts) { if (monitorHosts) { startMonitoring(); } else { stopMonitoring(); } } }
Example #5
Source File: GoogleConnectorServiceComponent.java From carbon-identity with Apache License 2.0 | 6 votes |
protected void activate(ComponentContext context) { if (log.isDebugEnabled()) { log.debug("Activating GoogleConnectorServiceComponent"); } try { GoogleProvisioningConnectorFactory googleProvisioningConnectorFactory = new GoogleProvisioningConnectorFactory(); context.getBundleContext().registerService(AbstractProvisioningConnectorFactory.class.getName(), googleProvisioningConnectorFactory, null); if (log.isDebugEnabled()) { log.debug("Google Identity Provisioning Connector bundle is activated"); } } catch (Throwable e) { log.error("Error while activating Google Identity Provisioning Connector", e); } }
Example #6
Source File: DataSourceCappDeployerServiceComponent.java From micro-integrator with Apache License 2.0 | 6 votes |
protected synchronized void activate(ComponentContext ctx) { this.ctx = ctx; if (log.isDebugEnabled()) { log.debug("Data Source Capp deployer activated"); } if (log.isDebugEnabled()) { log.debug("Data Source Capp deployer activated"); } try { //register data source deployer as an OSGi service DataSourceCappDeployer dataSourceDeployer = new DataSourceCappDeployer(); this.ctx.getBundleContext().registerService( AppDeploymentHandler.class.getName(), dataSourceDeployer, null); } catch (Throwable e) { log.error("Failed to activate Data Source Capp Deployer", e); } }
Example #7
Source File: MessagingPerfApp.java From onos with Apache License 2.0 | 6 votes |
@Activate public void activate(ComponentContext context) { configService.registerProperties(getClass()); setupCodecs(); messageReceivingExecutor = receiveOnIOLoopThread ? MoreExecutors.directExecutor() : Executors.newFixedThreadPool( totalReceiverThreads, groupedThreads("onos/net-perf-test", "receiver-%d")); registerMessageHandlers(); startTest(); reporter.scheduleWithFixedDelay(this::reportPerformance, reportIntervalSeconds, reportIntervalSeconds, TimeUnit.SECONDS); logConfig("Started"); }
Example #8
Source File: JMSListenerComponent.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Activate protected void activate(ComponentContext context) { log.debug("Activating component..."); APIManagerConfiguration configuration = ServiceReferenceHolder.getInstance().getAPIMConfiguration(); if (configuration != null) { if (!configuration.getThrottleProperties().getJmsConnectionProperties().isEnabled()) { return; } } else { log.warn("API Manager Configuration not properly set."); } JMSListenerStartupShutdownListener jmsListenerStartupShutdownListener = new JMSListenerStartupShutdownListener(); registration = context.getBundleContext() .registerService(ServerStartupObserver.class, jmsListenerStartupShutdownListener, null); registration = context.getBundleContext() .registerService(ServerShutdownHandler.class, jmsListenerStartupShutdownListener, null); }
Example #9
Source File: MigrationServiceComponent.java From product-ei with Apache License 2.0 | 6 votes |
/** * Method to activate bundle. * * @param context OSGi component context. */ protected void activate(ComponentContext context) { try { // if -Dmigrate option is used. String migrate = System.getProperty("migrate"); if (Boolean.parseBoolean(migrate)) { log.info("Executing Migration client : " + MigrationClient.class.getName()); MigrationClient migrationClientImpl = new MigrationClientImpl(); migrationClientImpl.execute(); } if (log.isDebugEnabled()) { log.debug("WSO2 EI migration bundle is activated"); } } catch (Throwable e) { log.error("Error while initiating Config component", e); } }
Example #10
Source File: TestMapAttribute.java From karaf-decanter with Apache License 2.0 | 6 votes |
@Test public void testSeveralObjectNames() throws Exception { ComponentContext ctx = Mockito.mock(ComponentContext.class); Dictionary props = new Hashtable(); Mockito.when(ctx.getProperties()).thenReturn(props); props.put("object.name.system", "java.lang:*"); props.put("object.name", "org.something.else:*"); props.put("object.name.karaf", "org.apache.karaf:type=http"); props.put("object.name.2", "whatever"); props.put("object.name-invalid", "not expected"); JmxCollector collector = new JmxCollector(); Assert.assertNull(collector.getObjectNames()); collector.activate(ctx); List<String> objectNames = new ArrayList<>(collector.getObjectNames()); Collections.sort(objectNames); Assert.assertEquals(4, objectNames.size()); Assert.assertEquals("java.lang:*", objectNames.get(0)); Assert.assertEquals("org.apache.karaf:type=http", objectNames.get(1)); Assert.assertEquals("org.something.else:*", objectNames.get(2)); Assert.assertEquals("whatever", objectNames.get(3)); }
Example #11
Source File: ServiceComponent.java From product-iots with Apache License 2.0 | 6 votes |
protected void deactivate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("De-activating b Management Service Component"); } try { if (serviceRegistration != null) { serviceRegistration.unregister(); } if (log.isDebugEnabled()) { log.debug("Current Sensor Management Service Component has been successfully " + "de-activated"); } } catch (Throwable e) { log.error("Error occurred while de-activating Iot Device Management bundle", e); } }
Example #12
Source File: EventBrokerBuilderDS.java From carbon-commons with Apache License 2.0 | 6 votes |
/** * initialize the cep service here. * * @param context */ @Activate protected void activate(ComponentContext context) { this.eventBrokerHandler = new EventBrokerHandler(context); // need to differ the bundle deployment if the Qpid bundle is in the plugins directory and it is not // started boolean isQpidBundlePresent = false; final BundleContext bundleContext = context.getBundleContext(); for (Bundle bundle : bundleContext.getBundles()) { if (bundle.getSymbolicName().equals("org.wso2.carbon.qpid")) { isQpidBundlePresent = true; break; } } if (isQpidBundlePresent) { // if the Qpid bundle is present we register an event broker handler // so that the qpid compoent will notify that. context.getBundleContext().registerService(EventBundleNotificationService.class.getName(), this .eventBrokerHandler, null); } else { this.eventBrokerHandler.startEventBroker(); } }
Example #13
Source File: Dhcp6HandlerImpl.java From onos with Apache License 2.0 | 5 votes |
@Activate protected void activate(ComponentContext context) { cfgService.registerProperties(getClass()); modified(context); appId = coreService.registerApplication(DHCP_V6_RELAY_APP); providerService = providerRegistry.register(this); hostService.addListener(hostListener); }
Example #14
Source File: EmailVerificationServiceComponent.java From carbon-commons with Apache License 2.0 | 5 votes |
@Activate protected void activate(ComponentContext context) { log.debug("******* Email Verification bundle is activated ******* "); try { start(context.getBundleContext()); log.debug("******* Email Verification bundle is activated ******* "); } catch (Exception e) { log.debug("******* Failed to activate Email Verification bundle bundle ******* "); } }
Example #15
Source File: GenericThingProviderTest4.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Before public void setUp() { registerVolatileStorageService(); readyService = getService(ReadyService.class); assertThat(readyService, is(notNullValue())); thingRegistry = getService(ThingRegistry.class); assertThat(thingRegistry, is(notNullValue())); modelRepository = getService(ModelRepository.class); assertThat(modelRepository, is(notNullValue())); modelRepository.removeModel(TESTMODEL_NAME); ComponentContext componentContextMock = mock(ComponentContext.class); when(componentContextMock.getBundleContext()).thenReturn(bundleContext); hueThingHandlerFactory = new TestHueThingHandlerFactoryX(componentContextMock) { @Override protected ThingHandler createHandler(final Thing thing) { if (thing instanceof Bridge) { return new TestBridgeHandler((Bridge) thing); } else { return new BaseThingHandler(thing) { @Override public void handleCommand(ChannelUID arg0, Command arg1) { }; @Override public void initialize() { updateStatus(ThingStatus.ONLINE); } }; } } }; finished = false; bundle = FrameworkUtil.getBundle(TestHueThingHandlerFactoryX.class); removeReadyMarker(); }
Example #16
Source File: EmailMessageSendingServiceComponent.java From carbon-identity with Apache License 2.0 | 5 votes |
protected void activate(ComponentContext ctxt) { try { // Registering email message sending module on user operation for entitlement component ctxt.getBundleContext().registerService(NotificationSendingModule.class.getName(), new EmailSendingModule(), null); if (log.isDebugEnabled()) { log.debug("Email notification sending module is activated"); } } catch (Throwable t) { // Catching throwable, since there may be throwable throwing while initiating log.error("Error while registering email notification sending module", t); } }
Example #17
Source File: DeviceTaskManagerServiceComponent.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") protected void deactivate(ComponentContext componentContext) { try { // DeviceTaskManagerService taskManagerService = new DeviceTaskManagerServiceImpl(); // taskManagerService.stopTask(); } catch (Throwable e) { log.error("Error occurred while destroying the device details retrieving task manager service.", e); } }
Example #18
Source File: OAuthRequestPathAuthenticatorServiceComponent.java From carbon-identity with Apache License 2.0 | 5 votes |
protected void activate(ComponentContext ctxt) { try { OAuthRequestPathAuthenticator auth = new OAuthRequestPathAuthenticator(); ctxt.getBundleContext().registerService(ApplicationAuthenticator.class.getName(), auth, null); if (log.isDebugEnabled()) { log.debug("OAuthRequestPathAuthenticator bundle is activated"); } } catch (Throwable e) { log.error("OAuthRequestPathAuthenticator bundle activation failed", e); } }
Example #19
Source File: ThingManagerImpl.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Deactivate protected synchronized void deactivate(ComponentContext componentContext) { thingRegistry.removeThingTracker(this); for (ThingHandlerFactory factory : thingHandlerFactories) { removeThingHandlerFactory(factory); } readyService.unregisterTracker(this); }
Example #20
Source File: EmailSenderServiceComponent.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
private void registerServices(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Registering email sender service"); } EmailSenderService emailServiceProvider = new EmailSenderServiceImpl(); EmailSenderDataHolder.getInstance().setEmailServiceProvider(emailServiceProvider); componentContext.getBundleContext().registerService(EmailSenderService.class, emailServiceProvider, null); }
Example #21
Source File: ModuleHandlerFactoryStarter.java From org.openhab.ui.habot with Eclipse Public License 1.0 | 5 votes |
@Activate protected void activate(ComponentContext context) { try { context.enableComponent(WebPushNotificationModuleHandlerFactory.class.getName()); logger.info("WebPushNotificationModuleHandlerFactory started by ModuleHandlerFactoryStarter"); } catch (NoClassDefFoundError e) { logger.info( "Not registering WebPushNotificationModuleHandlerFactory - make sure the automation engine add-on is installed"); } }
Example #22
Source File: TenantInitializerServiceComponent.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Activate protected void activate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("Activating tenant initialization component."); } BundleContext bundleContext = ctx.getBundleContext(); bundleContext.registerService(ServerStartupObserver.class.getName(), new ServerStartupListener(), null); }
Example #23
Source File: FlowRuleManager.java From onos with Apache License 2.0 | 5 votes |
@Activate public void activate(ComponentContext context) { store.setDelegate(delegate); eventDispatcher.addSink(FlowRuleEvent.class, listenerRegistry); deviceService.addListener(deviceListener); cfgService.registerProperties(getClass()); modified(context); idGenerator = coreService.getIdGenerator(FLOW_OP_TOPIC); local = clusterService.getLocalNode().id(); log.info("Started"); }
Example #24
Source File: SSOHostObjectServiceComponent.java From carbon-commons with Apache License 2.0 | 5 votes |
@Activate protected void activate(ComponentContext ctxt) { if (log.isDebugEnabled()) { log.info("SSO host bundle is activated"); } }
Example #25
Source File: DefaultGangliaMetricsReporter.java From onos with Apache License 2.0 | 5 votes |
/** * Extracts properties from the component configuration context. * * @param context the component context */ private void readComponentConfiguration(ComponentContext context) { Dictionary<?, ?> properties = context.getProperties(); String addressStr = Tools.get(properties, ADDRESS); address = addressStr != null ? addressStr : ADDRESS_DEFAULT; log.info("Configured. Ganglia server address is {}", address); String metricNameStr = Tools.get(properties, METRIC_NAMES); metricNames = metricNameStr != null ? metricNameStr : METRIC_NAMES_DEFAULT; log.info("Configured. Metric name is {}", metricNames); Integer portConfigured = Tools.getIntegerProperty(properties, PORT); if (portConfigured == null) { port = PORT_DEFAULT; log.info("Ganglia port is not configured, default value is {}", port); } else { port = portConfigured; log.info("Configured. Ganglia port is configured to {}", port); } Integer ttlConfigured = Tools.getIntegerProperty(properties, TTL); if (ttlConfigured == null) { ttl = TTL_DEFAULT; log.info("Ganglia TTL is not configured, default value is {}", ttl); } else { ttl = ttlConfigured; log.info("Configured. Ganglia TTL is configured to {}", ttl); } Boolean monitorAllEnabled = Tools.isPropertyEnabled(properties, MONITOR_ALL); if (monitorAllEnabled == null) { log.info("Monitor all metrics is not configured, " + "using current value of {}", monitorAll); } else { monitorAll = monitorAllEnabled; log.info("Configured. Monitor all metrics is {}", monitorAll ? "enabled" : "disabled"); } }
Example #26
Source File: ActiveBundleHealthCheck.java From aem-healthcheck with Apache License 2.0 | 5 votes |
@Activate protected void activate(ComponentContext context) { bundleContext = context.getBundleContext(); Dictionary<String, Object> properties = context.getProperties(); if(properties != null) { ignoredBundles = PropertiesUtil.toStringArray(properties.get(IGNORED_BUNDLES)); } else { ignoredBundles = new String[]{}; } }
Example #27
Source File: MeterManager.java From onos with Apache License 2.0 | 5 votes |
@Modified public void modified(ComponentContext context) { if (context != null) { readComponentConfiguration(context); } defaultProvider.init(deviceService, createProviderService(defaultProvider), mastershipService, fallbackMeterPollFrequency); }
Example #28
Source File: JmxProcessCollector.java From karaf-decanter with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void activate(ComponentContext context) { properties = context.getProperties(); String type = getProperty(properties, "type", "process-jmx"); String process = getProperty(properties, "process", null); String objectName = getProperty(properties, "object.name", null); Dictionary<String, String> serviceProperties = new Hashtable<String, String>(); serviceProperties.put("decanter.collector.name", type); this.type = type; this.process = process; this.objectName = objectName; }
Example #29
Source File: LogAppender.java From karaf-decanter with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Activate public void activate(ComponentContext context) { this.properties = context.getProperties(); if (this.properties.get("ignored.categories") != null) { ignoredCategories = ((String)this.properties.get("ignored.categories")).split(","); } if (this.properties.get("location.disabled") != null) { locationDisabledCategories = ((String) this.properties.get("location.disabled")).split(","); } }
Example #30
Source File: SonosHandlerFactory.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override protected void activate(ComponentContext componentContext) { super.activate(componentContext); Dictionary<String, Object> properties = componentContext.getProperties(); opmlUrl = (String) properties.get("opmlUrl"); callbackUrl = (String) properties.get("callbackUrl"); }