Examples of OsgiServiceProxyFactoryBean


Examples of org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean

  private BundleContext bundleContext;


  protected void setUp() throws Exception {
    super.setUp();
    this.serviceFactoryBean = new OsgiServiceProxyFactoryBean();
    this.serviceFactoryBean.setBeanClassLoader(getClass().getClassLoader());
    // this.serviceFactoryBean.setApplicationContext(new
    // GenericApplicationContext());
    this.mockControl = MockControl.createControl(BundleContext.class);
    this.bundleContext = (BundleContext) this.mockControl.getMock();
View Full Code Here

Examples of org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean

   *
   * @return proxy to the found OSGi service
   */
  public static Object createServerServiceProxy(BundleContext bundleContext, Class proxyType, String serviceName) {

    OsgiServiceProxyFactoryBean proxyFB = new OsgiServiceProxyFactoryBean();
    proxyFB.setBundleContext(bundleContext);
    proxyFB.setContextClassLoader(ImportContextClassLoader.UNMANAGED);
    proxyFB.setInterfaces(new Class[] { proxyType });
    // use the spring-dm class loader to generate the proxy (since it can see all the needed server classes)
    proxyFB.setBeanClassLoader(proxyType.getClassLoader());
    // wait 5 seconds
    proxyFB.setTimeout(5 * 1000);
    if (StringUtils.hasText(serviceName))
      proxyFB.setServiceBeanName(serviceName);
    proxyFB.afterPropertiesSet();

    return proxyFB.getObject();
  }
View Full Code Here

Examples of org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean

  public void testSimpleReference() throws Exception {
    Object factoryBean = appContext.getBean("&serializable");

    assertTrue(factoryBean instanceof OsgiServiceProxyFactoryBean);
    OsgiServiceProxyFactoryBean proxyFactory = (OsgiServiceProxyFactoryBean) factoryBean;

    Class[] intfs = (Class[]) TestUtils.getFieldValue(proxyFactory, "interfaces");

    assertEquals(1, intfs.length);
    assertSame(Serializable.class, intfs[0]);
View Full Code Here

Examples of org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean

    assertTrue(Proxy.isProxyClass(bean.getClass()));

  }

  public void testFullReference() throws Exception {
    OsgiServiceProxyFactoryBean factory = (OsgiServiceProxyFactoryBean) appContext.getBean("&full-options");
    factory.getObject(); // required to initialise proxy and hook
    // listeners into the binding process

    OsgiServiceLifecycleListener[] listeners = (OsgiServiceLifecycleListener[]) TestUtils.getFieldValue(factory,
      "listeners");
    assertNotNull(listeners);
View Full Code Here

Examples of org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean

    listeners[3].unbind(null, null);
    assertEquals(1, DummyListenerServiceSignature2.UNBIND_CALLS);
  }

  public void testMultipleInterfaces() throws Exception {
    OsgiServiceProxyFactoryBean factory = (OsgiServiceProxyFactoryBean) appContext.getBean("&multi-interfaces");
    Class[] intfs = (Class[]) TestUtils.getFieldValue(factory, "interfaces");
    assertNotNull(intfs);
    assertEquals(2, intfs.length);

    assertTrue(Arrays.equals(new Class[] { Serializable.class, Externalizable.class }, intfs));
View Full Code Here

Examples of org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean

    assertTrue(Arrays.equals(new Class[] { Serializable.class, Externalizable.class }, intfs));
  }

  public void testBeanNameAttrToServiceBeanNameProperty() throws Exception {
    OsgiServiceProxyFactoryBean factory = (OsgiServiceProxyFactoryBean) appContext.getBean("&importerWithBeanName");
    Object obj = TestUtils.getFieldValue(factory, "serviceBeanName");
    assertEquals("bean-name attr hasn't been properly parsed", "someBean", obj);
  }
View Full Code Here

Examples of org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean

    appContext.close();
    appContext = null;
  }

  public void testLocalDefinitionForTimeout() throws Exception {
    OsgiServiceProxyFactoryBean fb = (OsgiServiceProxyFactoryBean) appContext.getBean("&refWLocalConfig");
    assertEquals(55, getTimeout(fb));
  }
View Full Code Here

Examples of org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean

      SmartFactoryBean reference = (SmartFactoryBean) beanFactory.getBean(beanName);

      OsgiServiceDependency dependency;
      if (reference instanceof OsgiServiceProxyFactoryBean) {
        OsgiServiceProxyFactoryBean importer = (OsgiServiceProxyFactoryBean) reference;

        dependency = new DefaultOsgiServiceDependency(beanName, importer.getUnifiedFilter(),
          importer.getCardinality().isMandatory());
      }
      else {
        OsgiServiceCollectionProxyFactoryBean importer = (OsgiServiceCollectionProxyFactoryBean) reference;

        dependency = new DefaultOsgiServiceDependency(beanName, importer.getUnifiedFilter(),
          importer.getCardinality().isMandatory());
      }

      beansCollections.add(dependency);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.