java.net.ContentHandler#org.osgi.framework.BundleContext源码实例Demo

下面列出了java.net.ContentHandler#org.osgi.framework.BundleContext 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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);
}
 
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;
}
 
源代码3 项目: smarthome   文件: DiscoveryServiceManager.java
/**
 * 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>()));
            }
        }
    }
}
 
源代码4 项目: neoscada   文件: EventPoolConfigurationFactory.java
@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 );
}
 
源代码5 项目: neoscada   文件: HSDBItemController.java
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 );
}
 
源代码6 项目: knopflerfish.org   文件: CallerActivator.java
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);
  }
}
 
源代码7 项目: wisdom   文件: InVivoRunner.java
/**
 * 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);
}
 
源代码8 项目: tmxeditor8   文件: Activator.java
public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;

	DbServiceProviderImpl service = new DbServiceProviderImpl();
	oracleServiceRegistration = context.registerService(DBServiceProvider.class, service, null);
}
 
源代码9 项目: neoscada   文件: Activator.java
@Override
public void stop ( final BundleContext context ) throws Exception
{
    this.configAdminTracker.close ();

    instance = null;
}
 
源代码10 项目: neoscada   文件: ServiceImpl.java
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 );
}
 
源代码11 项目: ContentAssist   文件: Activator.java
/**
 * 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;
}
 
源代码12 项目: hana-native-adapters   文件: Activator.java
@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);
}
 
源代码13 项目: neoscada   文件: TestingMonitor.java
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 );
}
 
源代码14 项目: attic-stratos   文件: MenuAdminClient.java
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");
                }
            }
        }
    }
}
 
源代码15 项目: elexis-3-core   文件: ReChargeTarmedOpenCons.java
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;
	}
}
 
源代码16 项目: neoscada   文件: Activator.java
@Override
public void stop ( final BundleContext bundleContext ) throws Exception
{
    this.factory.dispose ();
    this.executor.shutdown ();
    this.factory = null;
    this.executor = null;
}
 
源代码17 项目: knopflerfish.org   文件: PackageAdminTestSuite.java
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());
}
 
源代码18 项目: neoscada   文件: Activator.java
@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 );
}
 
源代码19 项目: neoscada   文件: Activator.java
@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;
}
 
@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()));
}
 
源代码21 项目: knopflerfish.org   文件: EventTableModel.java
/** 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);
  }
}
 
private EventAdmin findEventAdmin(BundleContext ctx) {
  ServiceReference<EventAdmin> ref = ctx.getServiceReference(EventAdmin.class);
  EventAdmin eventAdmin = null;
  if (ref != null) {
    eventAdmin = ctx.getService(ref);
  }
  return eventAdmin;
}
 
源代码23 项目: knopflerfish.org   文件: Activator.java
@Override
public void stop(BundleContext bc) throws Exception {
  if(msfr != null) {
    msfr.unregister();
  }
  if(sr != null) {
    sr.unregister();
  }
  factory.destroyAll();
}
 
源代码24 项目: wisdom   文件: FactoryModelTest.java
@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);
}
 
源代码25 项目: fuchsia   文件: DefaultExportationLinker.java
public DefaultExportationLinker(BundleContext context) {
    this.bundleContext = context;
    processProperties();

    linkerManagement = new LinkerManagement<ExportDeclaration, ExporterService>(bundleContext, exporterServiceFilter, exportDeclarationFilter);
    exportersManager = linkerManagement.getBindersManager();
    declarationsManager = linkerManagement.getDeclarationsManager();
}
 
源代码26 项目: siddhi   文件: SiddhiExtensionLoader.java
/**
 * 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);
    }
}
 
源代码27 项目: roboconf-platform   文件: HttpClientFactoryTest.java
@Test
public void testNonTrivialConstructor() {

	BundleContext bundleContext = Mockito.mock( BundleContext.class );
	HttpClientFactory factory = new HttpClientFactory( bundleContext );
	Assert.assertEquals( bundleContext, factory.bundleContext );
}
 
源代码28 项目: neoscada   文件: Activator.java
@Override
public void start ( final BundleContext context ) throws Exception
{
    super.start ( context );
    plugin = this;
}
 
源代码29 项目: Pydev   文件: RefactoringPlugin.java
/**
 * This method is called upon plug-in activation
 */
@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
}
 
源代码30 项目: micro-integrator   文件: FileBasedClaimBuilder.java
public static void setBundleContext(BundleContext bundleContext) {
    FileBasedClaimBuilder.bundleContext = bundleContext;
}