Package org.apache.aries.proxy

Examples of org.apache.aries.proxy.ProxyManager


  }

  @SuppressWarnings("unchecked")
  @Test
  public void testEquals() throws Exception {
    ProxyManager mgr = context().getService(ProxyManager.class);
    Bundle b = FrameworkUtil.getBundle(this.getClass());
   
    TestCallable c = new TestCallable();
    c.setReturn(new TestDelegate("One"));
   
    TestCallable c2 = new TestCallable();
    c.setReturn(new TestDelegate("Two"));
   
    Collection<Class<?>> classes = new ArrayList<Class<?>>();
    classes.add(List.class);
    Object proxy = mgr.createDelegatingProxy(b, classes, c, new TestDelegate("Three"));
    Object otherProxy = mgr.createDelegatingProxy(b, classes, c, new TestDelegate("Four"));
    Object totallyOtherProxy = mgr.createDelegatingProxy(b, classes, c2, new TestDelegate("Five"));
    assertTrue("The object is not equal to itself", proxy.equals(proxy));
    assertTrue("The object is not equal to another proxy of itself", proxy.equals(otherProxy));
    assertFalse("The object is equal to proxy to another object", proxy.equals(totallyOtherProxy));
  }
View Full Code Here


    assertFalse("The object is equal to proxy to another object", proxy.equals(totallyOtherProxy));
  }

  @Test
  public void testDelegation() throws Exception {
    ProxyManager mgr = context().getService(ProxyManager.class);
    Bundle b = FrameworkUtil.getBundle(this.getClass());
   
    TestCallable c = new TestCallable();
   
    Collection<Class<?>> classes = new ArrayList<Class<?>>();
    classes.add(TestDelegate.class);
   
    TestDelegate proxy = (TestDelegate) mgr.createDelegatingProxy(b, classes, c, new TestDelegate(""));
   
    c.setReturn(new TestDelegate("Hello"));
   
    assertEquals("Wrong message", "Hello", proxy.call());
   
View Full Code Here

    assertEquals("Wrong message", "Hello again", proxy.call());
  }
 
  @Test
  public void testInterception() throws Exception {
    ProxyManager mgr = context().getService(ProxyManager.class);
    Bundle b = FrameworkUtil.getBundle(this.getClass());
   
    TestDelegate td = new TestDelegate("Hello");
   
    Collection<Class<?>> classes = new ArrayList<Class<?>>();
    classes.add(TestDelegate.class);
   
    TestListener tl = new TestListener();
   
    TestDelegate proxy = (TestDelegate) mgr.createInterceptingProxy(b, classes, td, tl);
   
    //We need to call clear here, because the object will have had its toString() called
    tl.clear();
    assertCalled(tl, false, false, false);
   
View Full Code Here

    }
  }
 
  @Test
  public void testDelegationAndInterception() throws Exception {
    ProxyManager mgr = context().getService(ProxyManager.class);
    Bundle b = FrameworkUtil.getBundle(this.getClass());
   
   
    TestCallable c = new TestCallable();
   
    Collection<Class<?>> classes = new ArrayList<Class<?>>();
    classes.add(TestDelegate.class);
   
    TestListener tl = new TestListener();
   
    TestDelegate proxy = (TestDelegate) mgr.createDelegatingInterceptingProxy(b, classes, c, new TestDelegate(""), tl);
   
    c.setReturn(new TestDelegate("Hello"));
   
    //We need to call clear here, because the object will have had its toString() called
    tl.clear();
View Full Code Here

    // This customizer comes into action as the ProxyManager service arrives.
    class ServiceProxyCreatorCustomizer implements ServiceTrackerCustomizer<ProxyManager, ProxyManager> {
        @Override
        public ProxyManager addingService(ServiceReference<ProxyManager> reference) {
            runProxyCreator = true;
            final ProxyManager svc = myBundleContext.getService(reference);
            if (proxyCreatorThread == null && svc != null) {
                proxyCreatorThread = newProxyProducingThread(svc);
            }
            return svc;
        }
View Full Code Here

)
public class Activator extends BaseActivator {

    @Override
    protected void doStart() throws Exception {
        ProxyManager proxyManager = getTrackedService(ProxyManager.class);

        register(InitialContextFactory.class, new KarafInitialContextFactory());

        JndiServiceImpl service = new JndiServiceImpl();
        service.setBundleContext(bundleContext);
View Full Code Here

TOP

Related Classes of org.apache.aries.proxy.ProxyManager

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.