Package org.osgi.framework

Examples of org.osgi.framework.ServiceFactory


   *
   * @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


    Dictionary props = new Hashtable();
    props.put(Constants.SERVICE_VENDOR, "Eclipse"); //$NON-NLS-1$
    props.put(Constants.SERVICE_PID,
        SimpleConfiguratorConstants.TARGET_CONFIGURATOR_NAME);
    ServiceFactory configurationFactory = new SimpleConfiguratorFactory(
        context);
    configuratorRegistration = context.registerService(Configurator.class
        .getName(), configurationFactory, props);

    try {
View Full Code Here

        ));
        return securityConfig;
    }

    private void registerSecurityProvider() {
        ServiceFactory sf = new ServiceFactory() {
            @Override
            public Object getService(Bundle bundle, ServiceRegistration serviceRegistration) {
                return securityProvider;
            }
View Full Code Here

        WebServer webServer = injectedWebServer.getValue();

        Hashtable<String, Object> props = new Hashtable<String, Object>();
        props.put("provider", getClass().getPackage().getName());

        ServiceFactory serviceFactory = new HttpServiceFactory(webServer, virtualHost, serverEnvironment);
        registration = syscontext.registerService(HttpService.class.getName(), serviceFactory, props);
    }
View Full Code Here

        ));
        return securityConfig;
    }

    private void registerSecurityProvider() {
        ServiceFactory sf = new ServiceFactory() {
            @Override
            public Object getService(Bundle bundle, ServiceRegistration serviceRegistration) {
                return securityProvider;
            }
View Full Code Here

public class SmooksServiceFactoryTest
{
    @Test
    public void getService()
    {
        final ServiceFactory serviceFactory = new SmooksServiceFactory();
        final Bundle bundle = mock(Bundle.class);
        final Object service = serviceFactory.getService(bundle, null);
        assertThat(service, is(instanceOf(SmooksFactory.class)));
    }
View Full Code Here

    // sort the names in alphabetical order (eases debugging)
    Arrays.sort(names);

    log.info("Publishing service under classes [" + ObjectUtils.nullSafeToString(names) + "]");

    ServiceFactory serviceFactory = new PublishingServiceFactory(classes, target, beanFactory, targetBeanName,
      (contextClassLoader == ExportContextClassLoader.SERVICE_PROVIDER), classLoader, aopClassLoader,
      bundleContext);

    if (isBeanBundleScoped())
      serviceFactory = new OsgiBundleScope.BundleScopeServiceFactory(serviceFactory);
View Full Code Here

  private Object getServiceAtIndex(int index) {
    Object sFactory = services.get(index);
    assertNotNull(sFactory);
    assertTrue(sFactory instanceof ServiceFactory);
    ServiceFactory fact = (ServiceFactory) sFactory;
    return fact.getService(null, null);
  }
View Full Code Here

  public void testLazyBeanServiceWithServiceFactoryBean() throws Exception {
    final ServiceRegistration reg = new MockServiceRegistration();
    final ServiceFactory[] factory = new ServiceFactory[1];

    final Object actualService = new Object();
    Object service = new ServiceFactory() {

      public Object getService(Bundle arg0, ServiceRegistration arg1) {
        return actualService;
      }

      public void ungetService(Bundle arg0, ServiceRegistration arg1, Object arg2) {
      }

    };

    BundleContext ctx = new MockBundleContext() {

      public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
        assertTrue(service instanceof ServiceFactory);
        factory[0] = (ServiceFactory) service;
        return reg;
      }
    };

    String beanName = "fooBar";

    beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), true);
    beanFactoryControl.expectAndReturn(beanFactory.containsBean(beanName), true);
    beanFactoryControl.expectAndReturn(beanFactory.getBean(beanName), service);
    beanFactoryControl.replay();

    exporter.setBundleContext(ctx);
    exporter.setBeanFactory(beanFactory);
    exporter.setTargetBeanName(beanName);
    exporter.setInterfaces(new Class[] { service.getClass() });

    exporter.afterPropertiesSet();
    exporter.registerService(new Class[] { actualService.getClass() }, new Properties());
    assertSame(actualService, factory[0].getService(null, null));
    beanFactoryControl.verify();
View Full Code Here

    }
    return true;
  }

  public void testServiceFactory() throws Exception {
    ServiceFactory factory = new ServiceFactory() {

      public Object getService(Bundle bundle, ServiceRegistration registration) {
        return null;
      }
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.