org.osgi.framework.BundleContext Java Examples
The following examples show how to use
org.osgi.framework.BundleContext.
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: ShiroAuthorizationActivator.java From aries-jax-rs-whiteboard with Apache License 2.0 | 6 votes |
@Override public void start(BundleContext context) throws Exception { _LOG.debug("Starting the Shiro JAX-RS Authorization Feature"); _registration = coalesce( configuration("org.apache.aries.jax.rs.shiro.authorization"), just(() -> { _LOG.debug("Using the default configuration for the Shiro JAX-RS Authorization Feature"); Dictionary<String, Object> properties = new Hashtable<>(); properties.put( Constants.SERVICE_PID, "org.apache.aries.jax.rs.shiro.authorization"); return properties; }) ).map(this::filter) .flatMap(p -> register(Feature.class, new ShiroAuthorizationFeature(), p)) .run(context); }
Example #2
Source File: DiscoveryServiceManager.java From smarthome with Eclipse Public License 2.0 | 6 votes |
/** * Registers all {@link SceneDiscoveryService}s and {@link DeviceDiscoveryService}s of this * {@link DiscoveryServiceManager} to the given {@link BundleContext}. * * @param bundleContext (must not be null) */ public void registerDiscoveryServices(BundleContext bundleContext) { if (discoveryServices != null) { for (AbstractDiscoveryService service : discoveryServices.values()) { if (service instanceof SceneDiscoveryService) { this.discoveryServiceRegs.put(bridgeUID + ((SceneDiscoveryService) service).getID(), bundleContext.registerService(DiscoveryService.class.getName(), service, new Hashtable<String, Object>())); } if (service instanceof DeviceDiscoveryService) { this.discoveryServiceRegs.put(bridgeUID + ((DeviceDiscoveryService) service).getID(), bundleContext.registerService(DiscoveryService.class.getName(), service, new Hashtable<String, Object>())); } if (service instanceof ZoneTemperatureControlDiscoveryService) { this.discoveryServiceRegs.put( bridgeUID + ((ZoneTemperatureControlDiscoveryService) service).getID(), bundleContext.registerService(DiscoveryService.class.getName(), service, new Hashtable<String, Object>())); } } } }
Example #3
Source File: MongoDBPersistenceService.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
public void activate(final BundleContext bundleContext, final Map<String, Object> config) { url = (String) config.get("url"); logger.debug("MongoDB URL {}", url); if (StringUtils.isBlank(url)) { logger.warn( "The MongoDB database URL is missing - please configure the mongodb:url parameter in openhab.cfg"); } db = (String) config.get("database"); logger.debug("MongoDB database {}", db); if (StringUtils.isBlank(db)) { logger.warn( "The MongoDB database name is missing - please configure the mongodb:database parameter in openhab.cfg"); } collection = (String) config.get("collection"); logger.debug("MongoDB collection {}", collection); if (StringUtils.isBlank(collection)) { logger.warn( "The MongoDB database collection is missing - please configure the mongodb:collection parameter in openhab.cfg"); } disconnectFromDatabase(); connectToDatabase(); // connection has been established ... initialization completed! initialized = true; }
Example #4
Source File: MenuAdminClient.java From attic-stratos with Apache License 2.0 | 5 votes |
private void setDefaultMenus(String loggedInUserName, boolean isSuperTenant, ArrayList<String> userPermission, HttpServletRequest request) { BundleContext bundleContext = CarbonUIUtil.getBundleContext(); if (bundleContext != null) { ServiceReference reference = bundleContext.getServiceReference(CarbonUIDefinitions.class.getName()); CarbonUIDefinitions carbonUIDefinitions; if (reference != null) { carbonUIDefinitions = (CarbonUIDefinitions) bundleContext.getService(reference); Menu[] userMenus = carbonUIDefinitions.getMenuDefinitions(loggedInUserName, isSuperTenant, userPermission,request); if (userMenus != null) { Set<Menu> menuList = new LinkedHashSet<Menu>(); menuList.addAll(Arrays.<Menu>asList(userMenus)); Menu[] customMenus = (Menu[]) request.getSession().getAttribute(USER_CUSTOM_MENU_ITEMS); if (customMenus != null) { menuList.addAll(Arrays.<Menu>asList(customMenus)); } menus = menuList.toArray(new Menu[menuList.size()]); if (log.isDebugEnabled()) { log.debug("Found exiting menu items in OSGI context"); } } } } }
Example #5
Source File: DefaultExportationLinker.java From fuchsia with Apache License 2.0 | 5 votes |
public DefaultExportationLinker(BundleContext context) { this.bundleContext = context; processProperties(); linkerManagement = new LinkerManagement<ExportDeclaration, ExporterService>(bundleContext, exporterServiceFilter, exportDeclarationFilter); exportersManager = linkerManagement.getBindersManager(); declarationsManager = linkerManagement.getDeclarationsManager(); }
Example #6
Source File: SiddhiExtensionLoader.java From siddhi with Apache License 2.0 | 5 votes |
/** * Helper method to load the Siddhi extensions. * * @param siddhiExtensionsMap reference map for the Siddhi extension * @param extensionHolderMap reference map for the Siddhi extension holder */ public static void loadSiddhiExtensions(Map<String, Class> siddhiExtensionsMap, ConcurrentHashMap<Class, AbstractExtensionHolder> extensionHolderMap) { loadLocalExtensions(siddhiExtensionsMap, extensionHolderMap); BundleContext bundleContext = ReferenceHolder.getInstance().getBundleContext(); if (bundleContext != null) { loadExtensionOSGI(bundleContext, siddhiExtensionsMap, extensionHolderMap); } }
Example #7
Source File: InVivoRunner.java From wisdom with Apache License 2.0 | 5 votes |
/** * Creates a new {@link InVivoRunner}. * * @param context the bundle context, used to retrieve services * @param clazz the class. * @throws InitializationError if the class cannot be initialized, because for instance services cannot be found */ public InVivoRunner(BundleContext context, Class<?> clazz) throws InitializationError { super(clazz); // Set time factor. TimeUtils.TIME_FACTOR = Integer.getInteger("TIME_FACTOR", 1); //NOSONAR if (TimeUtils.TIME_FACTOR == 1) { TimeUtils.TIME_FACTOR = Integer.getInteger("time.factor", 1); //NOSONAR } this.helper = new OSGiHelper(context); }
Example #8
Source File: CallerActivator.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void start(BundleContext bc) throws IOException { ServiceReference sRef = bc.getServiceReference(UserService.class.getName()); if (sRef != null) { UserService us = (UserService) bc.getService(sRef); if (us != null) { us.login("joek"); } bc.ungetService(sRef); } }
Example #9
Source File: HSDBItemController.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public HSDBItemController ( final String id, final ScheduledExecutorService executor, final BundleContext context, final HSDBValueSource source ) { this.source = source; final Map<String, Variant> properties = new HashMap<String, Variant> (); final HistoricalItemInformation information = new HistoricalItemInformation ( id, properties ); this.item = new HSDBHistoricalItem ( executor, source, information ); final Dictionary<String, Object> serviceProperties = new Hashtable<String, Object> (); serviceProperties.put ( Constants.SERVICE_PID, id ); serviceProperties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" ); this.handle = context.registerService ( HistoricalItem.class, this.item, serviceProperties ); }
Example #10
Source File: EventPoolConfigurationFactory.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override protected Entry<EventPoolManager> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception { logger.info ( "Creating event pool '{}'", configurationId ); final ConfigurationDataHelper cfg = new ConfigurationDataHelper ( parameters ); final String filter = parameters.get ( "filter" ); final Integer size = cfg.getIntegerChecked ( "size", "Need 'size' parameter" ); final EventPoolManager manager = new EventPoolManager ( context, configurationId, filter, size ); return new Entry<EventPoolManager> ( configurationId, manager ); }
Example #11
Source File: HttpClientFactoryTest.java From roboconf-platform with Apache License 2.0 | 5 votes |
@Test public void testNonTrivialConstructor() { BundleContext bundleContext = Mockito.mock( BundleContext.class ); HttpClientFactory factory = new HttpClientFactory( bundleContext ); Assert.assertEquals( bundleContext, factory.bundleContext ); }
Example #12
Source File: FactoryModelTest.java From wisdom with Apache License 2.0 | 5 votes |
@Test public void testFactories() throws Exception { Factory factory1 = mock(Factory.class); when(factory1.getName()).thenReturn("factory-1"); Factory factory2 = mock(Factory.class); when(factory2.getName()).thenReturn("factory-2"); HandlerFactory factory3 = mock(HandlerFactory.class); when(factory3.getName()).thenReturn("factory-3"); when(factory3.getHandlerName()).thenReturn("h:factory-3"); ServiceReference<Factory> ref1 = mock(ServiceReference.class); ServiceReference<Factory> ref2 = mock(ServiceReference.class); ServiceReference<HandlerFactory> ref3 = mock(ServiceReference.class); BundleContext context = mock(BundleContext.class); when(context.getServiceReferences(Factory.class, null)).thenReturn(ImmutableList.of(ref1, ref2)); when(context.getServiceReferences(HandlerFactory.class, null)).thenReturn(ImmutableList.of(ref3)); when(context.getService(ref1)).thenReturn(factory1); when(context.getService(ref2)).thenReturn(factory2); when(context.getService(ref3)).thenReturn(factory3); List<FactoryModel> models = FactoryModel.factories(context); assertThat(models).hasSize(3); }
Example #13
Source File: Activator.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void stop(BundleContext bc) throws Exception { if(msfr != null) { msfr.unregister(); } if(sr != null) { sr.unregister(); } factory.destroyAll(); }
Example #14
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(); oracleServiceRegistration = context.registerService(DBServiceProvider.class, service, null); }
Example #15
Source File: Activator.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void stop ( final BundleContext context ) throws Exception { this.configAdminTracker.close (); instance = null; }
Example #16
Source File: ServiceImpl.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public ServiceImpl ( final BundleContext context, final Executor executor ) throws InvalidSyntaxException { super ( context, executor ); this.context = context; this.monitorSubscriptions = new SubscriptionManager<String> (); this.eventSubscriptions = new SubscriptionManager<String> (); // create akn handler this.aknTracker = new ServiceTracker<AknHandler, AknHandler> ( context, AknHandler.class, null ); }
Example #17
Source File: Activator.java From ContentAssist with MIT License | 5 votes |
/** * Performs actions when when the plug-in is shut down. * @param context the bundle context for this plug-in * @throws Exception if this this plug-in fails to stop */ @Override public void stop(BundleContext context) throws Exception { Recorder.getInstance().stop(); super.stop(context); plugin = null; }
Example #18
Source File: EventTableModel.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** The default constructor. */ public EventTableModel(BundleContext bc) { super(); final String capacityS = bc.getProperty(CAPACITY_PROP_NAME); if (null!=capacityS && capacityS.length()>0) { try { capacity = Integer.parseInt(capacityS.trim()); } catch (NumberFormatException nfe){ } } if (capacity>0) { entries.ensureCapacity(capacity); } }
Example #19
Source File: OSGiStartProcessEngineStepTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@Test public void loadClassWithNullCustomClassloader() throws ClassNotFoundException{ OSGiStartProcessEngineStep step = new OSGiStartProcessEngineStep(mock(ProcessEngineXml.class), mock(BundleContext.class)); String clazz = "java.lang.Object"; Class<? extends Object> loadedClazz = step.loadClass(clazz, null, null); assertThat(loadedClazz.getName(), is(Object.class.getName())); }
Example #20
Source File: Activator.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void stop ( final BundleContext bundleContext ) throws Exception { this.tracker.close (); if ( this.injector != null ) { this.injector.dispose (); this.injector = null; } Activator.context = null; }
Example #21
Source File: Activator.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void start ( final BundleContext context ) throws Exception { this.service = new FactoryImpl ( context ); final Dictionary<String, Object> properties = new Hashtable<> (); properties.put ( Constants.SERVICE_DESCRIPTION, "A factory for parser components" ); properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" ); properties.put ( ConfigurationAdministrator.FACTORY_ID, org.eclipse.scada.da.server.component.parser.factory.Constants.FACTORY_ID ); this.handle = context.registerService ( ConfigurationFactory.class, this.service, properties ); }
Example #22
Source File: PackageAdminTestSuite.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
public PackageAdminTestSuite (BundleContext bc) { super("PackageAdminTestSuite"); this.bc = bc; this.bu = bc.getBundle(); addTest(new Setup()); addTest(new Frame0187a()); addTest(new Frame0200a()); addTest(new Frame215a()); addTest(new Frame220b()); addTest(new Cleanup()); }
Example #23
Source File: Activator.java From hana-native-adapters with Apache License 2.0 | 5 votes |
@Override public void start(BundleContext bundleContext) throws Exception { PropertyConfigurator.configure("log4j.properties"); logger.info("### BQAdapter start"); Activator.context = bundleContext; BQAdapterFactory srv = new BQAdapterFactory(); adapterRegistration = context.registerService(AdapterFactory.class.getName(),srv ,null); }
Example #24
Source File: Activator.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void stop ( final BundleContext bundleContext ) throws Exception { this.factory.dispose (); this.executor.shutdown (); this.factory = null; this.executor = null; }
Example #25
Source File: ReChargeTarmedOpenCons.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private boolean initCodeElementService(){ BundleContext context = FrameworkUtil.getBundle(ReChargeTarmedOpenCons.class).getBundleContext(); serviceRef = context.getServiceReference(ICodeElementService.class); if (serviceRef != null) { codeElementService = context.getService(serviceRef); return true; } else { return false; } }
Example #26
Source File: TestingMonitor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public TestingMonitor ( final BundleContext context, final Executor executor, final EventProcessor eventProcessor, final String sourceName ) { super ( sourceName, executor, null, eventProcessor ); this.scheduler.scheduleAtFixedRate ( new Runnable () { @Override public void run () { TestingMonitor.this.tick (); } }, 1000, 1000, TimeUnit.MILLISECONDS ); }
Example #27
Source File: EventDistributorHandler.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
private EventAdmin findEventAdmin(BundleContext ctx) { ServiceReference<EventAdmin> ref = ctx.getServiceReference(EventAdmin.class); EventAdmin eventAdmin = null; if (ref != null) { eventAdmin = ctx.getService(ref); } return eventAdmin; }
Example #28
Source File: TestPluginActivator.java From sarl with Apache License 2.0 | 4 votes |
@Override public void start(BundleContext ctx) throws Exception { context = ctx; }
Example #29
Source File: LauncherPlugin.java From uima-uimaj with Apache License 2.0 | 4 votes |
@Override public void stop(BundleContext context) throws Exception { super.stop(context); plugin = null; }
Example #30
Source File: SemverActivator.java From n4js with Eclipse Public License 1.0 | 4 votes |
@Override public void stop(BundleContext context) throws Exception { injectors.clear(); INSTANCE = null; super.stop(context); }