Examples of OsgiServiceProxyFactoryBean


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

    ;
    assertEquals(beanName, "myBean");
  }

  public void testGetServicePropertyFilter() throws Exception {
    OsgiServiceProxyFactoryBean pfb = new OsgiServiceProxyFactoryBean();
    Method setter = AnnotatedBean.class.getMethod("setAnnotatedBeanTypeWithFilter",
      new Class[] { AnnotatedBean.class });
    ServiceReference ref = AnnotationUtils.getAnnotation(setter, ServiceReference.class);
    processor.getServiceProperty(pfb, ref, setter, null);
    String filter = (String) getPrivateProperty(pfb, "filter");
View Full Code Here

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

    ;
    assertEquals(filter, "(wooey=fooo)");
  }

  public void testGetServicePropertyServiceClass() throws Exception {
    OsgiServiceProxyFactoryBean pfb = new OsgiServiceProxyFactoryBean();
    Method setter = AnnotatedBean.class.getMethod("setAnnotatedBeanTypeWithServiceType",
      new Class[] { AnnotatedBean.class });
    ServiceReference ref = AnnotationUtils.getAnnotation(setter, ServiceReference.class);
    processor.getServiceProperty(pfb, ref, setter, null);
    Class[] intfs = (Class[]) getPrivateProperty(pfb, "interfaces");
View Full Code Here

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

    Class[] intfs = (Class[]) getPrivateProperty(pfb, "interfaces");
    assertEquals(intfs[0], Object.class);
  }

  public void testGetServicePropertyComplex() throws Exception {
    OsgiServiceProxyFactoryBean pfb = new OsgiServiceProxyFactoryBean();
    Method setter = AnnotatedBean.class.getMethod("setAnnotatedBeanTypeComplex",
      new Class[] { AnnotatedBean.class });
    ServiceReference ref = AnnotationUtils.getAnnotation(setter, ServiceReference.class);
    processor.getServiceProperty(pfb, ref, setter, null);
    Class[] intfs = (Class[]) getPrivateProperty(pfb, "interfaces");
    String filter = (String) getPrivateProperty(pfb, "filter");
    String beanName = (String) getPrivateProperty(pfb, "serviceBeanName");
    assertEquals(intfs[0], AnnotatedBean.class);
    assertFalse(pfb.getCardinality().isMandatory());
    assertEquals(ImportContextClassLoader.SERVICE_PROVIDER, pfb.getContextClassLoader());
    assertEquals(filter, "(id=fooey)");
    assertEquals(beanName, "myBean");
  }
View Full Code Here

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

  private OsgiServiceProxyFactoryBean fb;


  protected void onSetUp() throws Exception {
    fb = new OsgiServiceProxyFactoryBean();
    fb.setBundleContext(bundleContext);
    // execute retries fast
    fb.setTimeout(1);
    fb.setBeanClassLoader(getClass().getClassLoader());
  }
View Full Code Here

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

  private OsgiServiceProxyFactoryBean fb;


  protected void onSetUp() throws Exception {
    fb = new OsgiServiceProxyFactoryBean();
    fb.setBundleContext(bundleContext);
    // execute retries fast
    fb.setTimeout(1);
    fb.setBeanClassLoader(getClass().getClassLoader());
  }
View Full Code Here

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

*/
public class ReferenceInterruptTest extends BaseIntegrationTest {

  public void testProxyInterrupt() throws Exception {
    long initialWait = 20 * 1000;
    final OsgiServiceProxyFactoryBean proxyFactory = new OsgiServiceProxyFactoryBean();
    proxyFactory.setBeanClassLoader(getClass().getClassLoader());
    proxyFactory.setBundleContext(bundleContext);
    proxyFactory.setCardinality(Cardinality.C_0__1);
    proxyFactory.setContextClassLoader(ImportContextClassLoader.UNMANAGED);
    proxyFactory.setInterfaces(new Class[] { Shape.class });
    proxyFactory.setTimeout(initialWait);
    proxyFactory.afterPropertiesSet();

    Runnable resetProxy = new Runnable() {

      public void run() {
        try {
          Thread.sleep(3 * 1000);
        }
        catch (InterruptedException e) {
          throw new RuntimeException(e);
        }
        proxyFactory.setTimeout(0);
      }
    };

    Object proxy = proxyFactory.getObject();
    assertNotNull(proxy);
    Thread stopThread = new Thread(resetProxy, "reset-proxy-thread");
    stopThread.start();

    long start = System.currentTimeMillis();
View Full Code Here

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


  public void testPackageDependency() throws Exception {
    ClassLoader cl = applicationContext.getClassLoader();
    System.out.println(cl);
    OsgiServiceProxyFactoryBean fb = new OsgiServiceProxyFactoryBean();
    fb.setBundleContext(bundleContext);
    fb.setCardinality(Cardinality.C_0__1);
    fb.setContextClassLoader(ImportContextClassLoader.UNMANAGED);
    fb.setInterfaces(new Class[] { DocumentEvent.class });
    fb.setBeanClassLoader(cl);
    fb.setApplicationEventPublisher(applicationContext);
    fb.afterPropertiesSet();

    checkPackageVisibility(cl);

    Object proxy = fb.getObject();
    assertNotNull(proxy);
    assertTrue(proxy instanceof DocumentEvent);
    System.out.println(proxy.getClass());

  }
View Full Code Here

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

    OsgiServiceCollectionProxyFactoryBean fb = (OsgiServiceCollectionProxyFactoryBean) appContext.getBean("&colWLocalConfig");
    assertEquals(Cardinality.C_1__N, getCardinality(fb));
  }

  public void testLocalDefinitionForCardinalityOnSingleImporter() throws Exception {
    OsgiServiceProxyFactoryBean fb = (OsgiServiceProxyFactoryBean) appContext.getBean("&refWLocalConfig");
    assertEquals(Cardinality.C_1__1, getCardinality(fb));
  }
View Full Code Here

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

    OsgiServiceProxyFactoryBean fb = (OsgiServiceProxyFactoryBean) appContext.getBean("&refWLocalConfig");
    assertEquals(Cardinality.C_1__1, getCardinality(fb));
  }

  public void testTimeoutDefault() throws Exception {
    OsgiServiceProxyFactoryBean fb = (OsgiServiceProxyFactoryBean) appContext.getBean("&refWDefaults");
    assertEquals("default osgi timeout not applied", 10, getTimeout(fb));
  }
View Full Code Here

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

    OsgiServiceProxyFactoryBean fb = (OsgiServiceProxyFactoryBean) appContext.getBean("&refWDefaults");
    assertEquals("default osgi timeout not applied", 10, getTimeout(fb));
  }

  public void testCardinalityDefaultOnSingleImporter() throws Exception {
    OsgiServiceProxyFactoryBean fb = (OsgiServiceProxyFactoryBean) appContext.getBean("&refWDefaults");
    assertEquals(Cardinality.C_0__1, getCardinality(fb));
  }
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.