Package org.osgi.framework

Examples of org.osgi.framework.ServiceFactory


        // configure and start listening for configuration
        updateConfiguration(null);

        // register managed service as a service factory
        this.configurationListener = bundleContext.registerService( "org.osgi.service.cm.ManagedService", //$NON-NLS-1$
            new ServiceFactory()
            {
                public Object getService( Bundle bundle, ServiceRegistration registration )
                {
                    /*
                     * Explicitly load the class through the class loader to dynamically
View Full Code Here


    public void open(boolean trackAllServices)
    {
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(Constants.SERVICE_PID, SslFilter.PID);

        this.configReceiver = super.context.registerService(ManagedService.class.getName(), new ServiceFactory()
        {
            public Object getService(Bundle bundle, ServiceRegistration registration)
            {
                return new ManagedService()
                {
View Full Code Here

    {
        LogWrapper.setContext(context);

        mgr = new CoordinationMgr();

        final ServiceFactory factory = new CoordinatorFactory(mgr);
        final Hashtable<String, String> props = new Hashtable<String, String>();
        props.put(Constants.SERVICE_DESCRIPTION, "Coordinator Service Implementation");
        props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
        coordinatorService = context.registerService(Coordinator.class.getName(), factory, props);
    }
View Full Code Here

        controlContext.replay();

        ServiceRegistry sr = new ServiceRegistry(new Logger(), null);
        MockControl sfControl = MockControl.createNiceControl(ServiceFactory.class);
        sfControl.replay();
        ServiceFactory sf = (ServiceFactory) sfControl.getMock();

        assertEquals("Precondition failed", 0, sr.getHooks(EventHook.class).size());
        assertEquals("Precondition failed", 0, sr.getHooks(FindHook.class).size());
        assertEquals("Precondition failed", 0, sr.getHooks(ListenerHook.class).size());
        ServiceRegistration reg = sr.registerService(c, new String [] {EventHook.class.getName()}, sf, new Hashtable());
View Full Code Here

        controlContext.replay();

        ServiceRegistry sr = new ServiceRegistry(new Logger(), null);
        MockControl sfControl = MockControl.createNiceControl(ServiceFactory.class);
        sfControl.replay();
        ServiceFactory sf = (ServiceFactory) sfControl.getMock();

        assertEquals("Precondition failed", 0, sr.getHooks(EventHook.class).size());
        assertEquals("Precondition failed", 0, sr.getHooks(FindHook.class).size());
        assertEquals("Precondition failed", 0, sr.getHooks(ListenerHook.class).size());
        ServiceRegistration reg = sr.registerService(c, new String [] {FindHook.class.getName()}, sf, new Hashtable());
View Full Code Here

        controlContext.replay();

        ServiceRegistry sr = new ServiceRegistry(new Logger(), null);
        MockControl sfControl = MockControl.createNiceControl(ServiceFactory.class);
        sfControl.replay();
        ServiceFactory sf = (ServiceFactory) sfControl.getMock();

        assertEquals("Precondition failed", 0, sr.getHooks(EventHook.class).size());
        assertEquals("Precondition failed", 0, sr.getHooks(FindHook.class).size());
        assertEquals("Precondition failed", 0, sr.getHooks(ListenerHook.class).size());
        ServiceRegistration reg = sr.registerService(c, new String [] {ListenerHook.class.getName()}, sf, new Hashtable());
View Full Code Here

                }
      }}).start();
    }

    protected ServiceRegistration register(final Object service, final int delay) {
        return bundleContext.registerService(service.getClass().getName(), new ServiceFactory() {
            public Object getService(Bundle bundle, ServiceRegistration registration)
            {
                delay(delay);
                return service;
            }
View Full Code Here

   *
   * @param service2 The service to register.
   */
  private void registerService(Runnable service2)
  {
    ServiceFactory factory = Skeleton.newMock(ServiceFactory.class);
    Skeleton skel = Skeleton.getSkeleton(factory);
   
    skel.setReturnValue(new MethodCall(ServiceFactory.class, "getService", Bundle.class, ServiceRegistration.class), service2);
   
    Hashtable<String, String> props = new Hashtable<String, String>();
View Full Code Here

        mainCompInst = main.getComponentInstance();
        TestCase.assertNotNull(mainCompInst);
    }

    protected ServiceRegistration register(final Object service, final int delay) {
        return bundleContext.registerService(service.getClass().getName(), new ServiceFactory() {
            public Object getService(Bundle bundle, ServiceRegistration registration)
            {
                delay(delay);
                return service;
            }
View Full Code Here

        // Check that the proxy registration was done on the original provider bundle's context
        EasyMock.verify(providerBC);

        // Test that the actual proxy invokes the original service...
        ServiceFactory proxyServiceSF = (ServiceFactory) serviceMap.get(proxySR);
        TestServiceAPI proxyService = (TestServiceAPI) proxyServiceSF.getService(clientBundle, null);

        assertNotSame("The proxy should not be the same object as the original service", testService, proxyService);
        assertEquals("Doing it", proxyService.doit());

        EasyMock.reset(clientBC);
        EasyMock.expect(clientBC.ungetService(sr)).andReturn(true).once();
        EasyMock.replay(clientBC);

        proxyServiceSF.ungetService(clientBundle, null, proxyService);

        EasyMock.verify(clientBC);
    }
View Full Code Here

TOP

Related Classes of org.osgi.framework.ServiceFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.