Java 类org.osgi.framework.hooks.service.FindHook 实例源码

项目:aspecio    文件:AspecioActivator.java   
@Override
public void start(BundleContext context) {
    aspecio = new AspecioImpl(context);
    aspecio.activate();

    boolean filterServices = shouldFilterServices(context);

    if (filterServices) {
        context.registerService(new String[] { Aspecio.class.getName(), FindHook.class.getName(), EventListenerHook.class.getName() },
                aspecio, null);
    } else {
        context.registerService(Aspecio.class, aspecio, null);
    }
    Hashtable<String, Object> props = new Hashtable<>();
    props.put("osgi.command.scope", AspecioGogoCommand.ASPECIO_GOGO_COMMAND_SCOPE);
    props.put("osgi.command.function", AspecioGogoCommand.ASPECIO_GOGO_COMMANDS);

    AspecioGogoCommand gogoCommand = new AspecioGogoCommand(context, aspecio);
    context.registerService(Object.class, gogoCommand, props);
}
项目:osgi-in-action    文件:Activator.java   
private synchronized void bindRegistry(Registry registry,
    String[] intents, String[] configs) {
  RegistryWatcher watcher = new RegistryWatcher(ctx, registry);
  watchers.put(registry, watcher);

  ServiceRegistration[] regs = new ServiceRegistration[2];

  ExportedServiceTracker export = new ExportedServiceTracker(ctx,
      registry, intents, configs);
  export.open();

  trackers.put(registry, export);

  ImportedServiceFindHook find = new ImportedServiceFindHook(watcher);
  regs[0] = ctx.registerService(FindHook.class.getName(), find, null);

  ImportedServiceListenerHook listener = new ImportedServiceListenerHook(
      watcher);
  regs[1] = ctx.registerService(ListenerHook.class.getName(), listener,
      null);

  serviceRegs.put(registry, regs);
}
项目:osgi_in_action-    文件:Activator.java   
private synchronized void bindRegistry(Registry registry,
    String[] intents, String[] configs) {
  RegistryWatcher watcher = new RegistryWatcher(ctx, registry);
  watchers.put(registry, watcher);

  ServiceRegistration[] regs = new ServiceRegistration[2];

  ExportedServiceTracker export = new ExportedServiceTracker(ctx,
      registry, intents, configs);
  export.open();

  trackers.put(registry, export);

  ImportedServiceFindHook find = new ImportedServiceFindHook(watcher);
  regs[0] = ctx.registerService(FindHook.class.getName(), find, null);

  ImportedServiceListenerHook listener = new ImportedServiceListenerHook(
      watcher);
  regs[1] = ctx.registerService(ListenerHook.class.getName(), listener,
      null);

  serviceRegs.put(registry, regs);
}
项目:service-jockey    文件:ActivatorTest.java   
public void testActivator() throws Exception {
    ServiceRegistration sreg = mock(ServiceRegistration.class);
    BundleContext bc = mock(BundleContext.class);
    when(bc.registerService(anyString(), anyObject(), any(Dictionary.class))).thenReturn(sreg); 

    Activator a = new Activator();
    a.start(bc);

    verify(bc).registerService(eq(EventHook.class.getName()), isA(HidingEventHook.class), any(Dictionary.class));
    verify(bc).registerService(eq(FindHook.class.getName()), isA(HidingFindHook.class), any(Dictionary.class));
    verify(bc).addServiceListener(isA(ServiceJockeyListener.class));

    verify(bc, never()).removeServiceListener((ServiceListener) anyObject());
    verify(sreg, never()).unregister();
    a.stop(bc);
    verify(bc).removeServiceListener(isA(ServiceJockeyListener.class));
    verify(sreg, times(2)).unregister();
}
项目:service-jockey    文件:Activator.java   
public void start(BundleContext context) throws Exception {
       ServiceHandlerCatalog shc = new ServiceHandlerCatalog();

       EventHook eh = new HidingEventHook(context, shc);
       ereg = context.registerService(EventHook.class.getName(), eh, new Hashtable<String, Object>());

       FindHook fh = new HidingFindHook(context, shc);
       freg = context.registerService(FindHook.class.getName(), fh, new Hashtable<String, Object>());

       listener = new ServiceJockeyListener(context, shc);
       context.addServiceListener(listener);
}
项目:aries-rsa    文件:TopologyManagerImport.java   
public void start() {
    bctx.registerService(RemoteServiceAdminListener.class, this, null);
    bctx.registerService(ListenerHook.class, listenerHook, null);
    bctx.registerService(FindHook.class, findHook, null);
    endpointListenerManager.start();
}
项目:openeos    文件:ServiceHideManager.java   
private void registerHideHook() {
    if (reg == null) {
        reg = context.registerService(new String[] { FindHook.class.getName(), EventListenerHook.class.getName() }, this, null);
    }
}