Java Code Examples for org.osgi.framework.BundleContext#registerService()
The following examples show how to use
org.osgi.framework.BundleContext#registerService() .
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: RemoteResourceProviderFactory.java From sling-whiteboard with Apache License 2.0 | 6 votes |
void registerResourceProviderIfNeeded(BundleContext bundleContext) { if (resourceProviderServiceRegistration == null) { int cacheSize = configuration.cacheSize() >= 100 ? configuration.cacheSize() : 0; int lastAccessedExpirationTime = configuration.lastAccessedExpirationTime() >= 0 ? configuration.lastAccessedExpirationTime() : 0; resourceProvider = new RemoteResourceProvider(threadPoolManager, jsonParser, new InMemoryResourceCache(cacheSize, lastAccessedExpirationTime), remoteStorageProvider, !ResourceProvider.AUTHENTICATE_NO .equals(resourceProviderRegistrationProperties.get(ResourceProvider.PROPERTY_AUTHENTICATE))); resourceProviderServiceRegistration = bundleContext.registerService(ResourceProvider.class, resourceProvider, resourceProviderRegistrationProperties); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Registered a Resource Provider for: {}.", resourceProviderRegistrationProperties); } } }
Example 2
Source File: ConnectorRegistrarImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override public void addConnector(final ConnectorConfiguration connectorConfiguration) { checkNotNull(connectorConfiguration); validate(connectorConfiguration); final Bundle bundle = FrameworkUtil.getBundle(connectorConfiguration.getClass()); if (bundle == null) { log.warn("No bundle found for {}, not registering connector", connectorConfiguration); return; } final BundleContext bundleContext = bundle.getBundleContext(); if (bundleContext == null) { log.warn("No context found for bundle {}, not registering connector", bundle); return; } log.info("Adding connector configuration {}", connectorConfiguration); final ServiceRegistration<ConnectorConfiguration> serviceRegistration = bundleContext.registerService(ConnectorConfiguration.class, connectorConfiguration, null); managedConfigurations.put(connectorConfiguration, serviceRegistration); }
Example 3
Source File: GPIOActivator.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
/** * Called when this bundle is started by OSGi Framework. * Determines underlying platform and loads the relevant service * which implements <code>GPIO</code> interface. */ public void start(BundleContext context) throws Exception { /* Linux user space GPIO implementation, "sysfs" based */ if (System.getProperty("os.name").toLowerCase().startsWith("linux")) { GPIOLinux gpioLinux = new GPIOLinux(); Dictionary<String, String> properties = new Hashtable<String, String>(); properties.put("service.pid", "org.openhab.gpio"); context.registerService(GPIO.class, gpioLinux, null); context.registerService(ManagedService.class, gpioLinux, properties); } else { /* * Throwing exception is not implemented because it's causing Equinox to constantly trying to start the * bundle */ logger.error("No supported operating system was found, GPIO service won't be available"); } }
Example 4
Source File: LogCommands.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Called by the framework when this bundle is started. * * @param bc * Bundle context. */ public void start(BundleContext bc) { LogCommands.bc = bc; // Create service tracker for log config service LogCommands.logConfigTracker = new ServiceTracker<LogConfig, LogConfig>(bc, LogConfig.class, null); LogCommands.logConfigTracker.open(); // Register log commands final CommandGroup logCommandGroup = new LogCommandGroup(bc); Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put("groupName", logCommandGroup.getGroupName()); bc.registerService(CommandGroup.class, logCommandGroup, props); // Register log config commands final CommandGroup logConfigCommandGroup = new LogConfigCommandGroup(); props = new Hashtable<String, Object>(); props.put("groupName", logConfigCommandGroup.getGroupName()); bc.registerService(CommandGroup.class, logConfigCommandGroup, props); }
Example 5
Source File: IdentityClaimManagementServiceComponent.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
@Activate protected void activate(ComponentContext ctxt) { try { BundleContext bundleCtx = ctxt.getBundleContext(); IdentityClaimManagementServiceDataHolder.getInstance().setBundleContext(bundleCtx); ClaimMetadataStoreFactory claimMetadataStoreFactory = new ClaimMetadataStoreFactory(); bundleCtx.registerService(ClaimManagerFactory.class.getName(), claimMetadataStoreFactory, null); ClaimMetadataManagementService claimManagementService = new ClaimMetadataManagementServiceImpl(); bundleCtx.registerService(ClaimMetadataManagementService.class.getName(), claimManagementService, null); IdentityClaimManagementServiceDataHolder.getInstance().setClaimManagementService(claimManagementService); bundleCtx.registerService(TenantMgtListener.class.getName(), new ClaimMetadataTenantMgtListener(), null); registerClaimConfigListener(bundleCtx); if (log.isDebugEnabled()) { log.debug("Identity Claim Management Core bundle is activated"); } } catch (Throwable e) { log.error("Error occurred while activating Identity Claim Management Service Component", e); } }
Example 6
Source File: TracingServiceComponent.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Activate protected void activate(ComponentContext componentContext) { try { log.debug("Tracing Component activated"); BundleContext bundleContext = componentContext.getBundleContext(); registration = bundleContext.registerService(OpenTracer.class,new JaegerTracer(),null); registration = bundleContext.registerService(OpenTracer.class,new ZipkinTracer(),null); registration = bundleContext.registerService(OpenTracer.class,new LogTracer(),null); registration = bundleContext.registerService(TracingService.class, TracingServiceImpl.getInstance(), null); } catch (Exception e) { log.error("Error occured in tracing component activation", e); } }
Example 7
Source File: StartupServiceComponent.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Activate protected void activate(ComponentContext componentContext) { try { log.debug("Startup Service Component activated"); BundleContext bundleContext = componentContext.getBundleContext(); registration = bundleContext .registerService(ServerStartupObserver.class.getName(), new ServerStartupListener(), null); } catch (Exception e) { log.error("Error occurred in startup service component activation", e); } }
Example 8
Source File: Activator.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void start ( final BundleContext context ) throws Exception { logger.info ( "Starting file based DS" ); this.service = new StorageImpl (); final Dictionary<String, Object> properties = new Hashtable<String, Object> ( 2 ); properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" ); properties.put ( Constants.SERVICE_DESCRIPTION, "A file based data store implemenentation" ); context.registerService ( DataStore.class.getName (), this.service, properties ); }
Example 9
Source File: Activator.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Bundle is started by framework. */ public void start(BundleContext bc) throws Exception { basicLocator = new BasicDriverLocator(bc); sr = bc.registerService(DriverLocator.class, basicLocator, null); }
Example 10
Source File: Activator.java From sling-samples with Apache License 2.0 | 5 votes |
@Override public void start(BundleContext bundleContext) throws Exception { final Object service = new Object(); final Dictionary<String, String> properties = new Hashtable<>(); properties.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Fling Sample “Sling Authentication Requirements”"); properties.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation"); properties.put("sling.auth.requirements", "/fling/auth"); serviceRegistration = bundleContext.registerService(Object.class, service, properties); }
Example 11
Source File: WorkflowTemplateServiceComponent.java From carbon-identity with Apache License 2.0 | 5 votes |
protected void activate(ComponentContext context) { try { BundleContext bundleContext = context.getBundleContext(); String templateParamMetaDataXML = readTemplateParamMetaDataXML(TemplateConstant.TEMPLATE_PARAMETER_METADATA_FILE_NAME); bundleContext.registerService(AbstractTemplate.class, new MultiStepApprovalTemplate(templateParamMetaDataXML),null); }catch(Throwable e){ log.error("Error occurred while activating WorkflowTemplateServiceComponent bundle, " + e.getMessage()); } }
Example 12
Source File: Activator.java From concierge with Eclipse Public License 1.0 | 5 votes |
public void start(final BundleContext context) throws Exception { service = new LEDServiceImpl(); final Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(RemoteOSGiService.R_OSGi_REGISTRATION, Boolean.TRUE); context.registerService(LEDService.class, service, props); }
Example 13
Source File: EventInjectorManager.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public synchronized void start () throws Exception { final BundleContext context = FrameworkUtil.getBundle ( EventInjectorManager.class ).getBundleContext (); this.impl = new EventInjectorImpl ( context, this.evaluator ); final Dictionary<String, Object> properties = new Hashtable<> (); properties.put ( Constants.SERVICE_DESCRIPTION, "Event injector manager" ); properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" ); properties.put ( "osgi.command.scope", "ein" ); properties.put ( "osgi.command.function", new String[] { "rules", "state" } ); properties.put ( ConfigurationAdministrator.FACTORY_ID, "org.eclipse.scada.ae.server.injector" ); context.registerService ( ConfigurationFactory.class, this.impl, properties ); }
Example 14
Source File: Activator.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public void start ( final BundleContext context ) throws Exception { this.factory = new EventPoolConfigurationFactory ( context ); final Dictionary<String, String> properties = new Hashtable<String, String> (); properties.put ( ConfigurationAdministrator.FACTORY_ID, context.getBundle ().getSymbolicName () + ".pool" ); properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" ); properties.put ( Constants.SERVICE_DESCRIPTION, "Event pool service factory" ); context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties ); }
Example 15
Source File: Activator.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void start(BundleContext context) throws Exception { super.start(context); plugin = this; DbServiceProviderImpl service = new DbServiceProviderImpl(); mssqlServiceRegistration = context.registerService(DBServiceProvider.class, service, null); }
Example 16
Source File: Activator.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public void start ( final BundleContext context ) throws Exception { this.executor = Executors.newSingleThreadExecutor ( new NamedThreadFactory ( context.getBundle ().getSymbolicName () ) ); this.factory = new MemorySourceFactory ( context, this.executor ); final Dictionary<String, String> properties = new Hashtable<String, String> (); properties.put ( Constants.SERVICE_DESCRIPTION, "A memory data source" ); properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" ); properties.put ( ConfigurationAdministrator.FACTORY_ID, context.getBundle ().getSymbolicName () ); context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties ); }
Example 17
Source File: UrlPrinterServiceComponent.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
protected void activate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("Activating Url printer Service Component"); } try { BundleContext bundleContext = ctx.getBundleContext(); bundleContext.registerService(ServerStartupObserver.class.getName(), new URLPrinterStartupHandler(), null); if (log.isDebugEnabled()) { log.debug("Url printer Service Component has been successfully activated"); } } catch (Throwable e) { log.error("Error occurred while activating Url printer Service Component", e); } }
Example 18
Source File: OSGiConsole.java From orion.server with Eclipse Public License 1.0 | 4 votes |
protected void init() { super.init(); BundleContext context = Activator.getDefault().getBundle().getBundleContext(); context.registerService(ConsoleSession.class.getName(), session, null); }
Example 19
Source File: Activator.java From cxf with Apache License 2.0 | 4 votes |
@Override public void start(final BundleContext bundleContext) { Dictionary<String, String> properties = new Hashtable<>(); properties.put(Constants.SERVICE_PID, CONFIG_PID); bundleContext.registerService(ManagedService.class.getName(), new ConfigUpdater(bundleContext), properties); }
Example 20
Source File: UserService.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void start(BundleContext bc) throws BundleException { this.bc = bc; bc.registerService(UserService.class.getName(), this, null); }