Package org.apache.aries.proxy

Examples of org.apache.aries.proxy.ProxyManager


    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

   * delegation still works
   */
  @Test
  public void checkProxyFinalClass() throws Exception
  {
    ProxyManager mgr = context().getService(ProxyManager.class);
    Bundle b = FrameworkUtil.getBundle(this.getClass());
    TestCallable dispatcher = new TestCallable();
    TestCallable template = new TestCallable();
    Collection<Class<?>> classes = new ArrayList<Class<?>>();
    classes.add(TestCallable.class);
    Callable<Object> o = (Callable<Object>) mgr.createDelegatingProxy(b, classes,
        dispatcher, template);
    if(!!!(o instanceof WovenProxy))
      fail("Proxy should be woven!");
   
    Object inner = new Integer(3);
View Full Code Here

   * This method checks that we correctly proxy a class with final methods.
   */
  @Test
  public void checkProxyFinalMethods() throws Exception
  {
    ProxyManager mgr = context().getService(ProxyManager.class);
    Bundle b = FrameworkUtil.getBundle(this.getClass());
    Callable<Object> c = new TestCallable();
    Collection<Class<?>> classes = new ArrayList<Class<?>>();
    Runnable r = new Runnable() {
      public final void run() {
      }
    };
    classes.add(r.getClass());
    Object o = mgr.createDelegatingProxy(b, classes, c, r);
    if(!!!(o instanceof WovenProxy))
      fail("Proxy should be woven!");
  }
View Full Code Here

                }
            }
            Bundle bundle = FrameworkUtil.getBundle(CommandsCompleter.class);
            BundleContext bc = bundle.getBundleContext();
            ServiceReference<ProxyManager> ref = bc.getServiceReference(ProxyManager.class);
            ProxyManager pm = ref != null ? bc.getService(ref) : null;
            if (pm != null) {
                Callable call = pm.unwrap(function);
                if (call != null) {
                    return unProxy((Function) call.call());
                }
                bc.ungetService(ref);
            }
View Full Code Here

    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @Test
    public void testProxyCreationThread() throws Exception {
        ProxyManager proxyManager = getProxyManager();

        ConfigurationAdmin ca = EasyMock.createMock(ConfigurationAdmin.class);
        EasyMock.expect(ca.listConfigurations(EasyMock.anyObject(String.class))).andReturn(null).anyTimes();
        EasyMock.replay(ca);
View Full Code Here

        GuardProxyCatalog.ServiceRegistrationHolder holder = gpc.proxyMap.get(serviceID);
        // Mimic the thread that works the queue to create the proxy
        GuardProxyCatalog.CreateProxyRunnable runnable = gpc.createProxyQueue.take();
        assertEquals(117L, runnable.getOriginalServiceID());

        ProxyManager pm = getProxyManager();
        runnable.run(pm);

        // The runnable should have put the actual registration in the holder
        ServiceReference<?> proxySR = holder.registration.getReference();
View Full Code Here

        assertNull("The registration shouldn't have happened yet", holder.registration);
        assertEquals(1, gpc.createProxyQueue.size());

        // Mimic the thread that works the queue to create the proxy
        GuardProxyCatalog.CreateProxyRunnable runnable = gpc.createProxyQueue.take();
        ProxyManager pm = getProxyManager();
        runnable.run(pm);

        // The runnable should have put the actual registration in the holder
        ServiceReference<?> proxySR = holder.registration.getReference();
        for (String key : expectedProxyProps.keySet()) {
View Full Code Here

        assertNull("The registration shouldn't have happened yet", holder.registration);
        assertEquals(1, gpc.createProxyQueue.size());

        // Mimic the thread that works the queue to create the proxy
        GuardProxyCatalog.CreateProxyRunnable runnable = gpc.createProxyQueue.take();
        ProxyManager pm = getProxyManager();
        runnable.run(pm);

        // The runnable should have put the actual registration in the holder
        ServiceReference<?> proxySR = holder.registration.getReference();
        for (String key : expectedProxyProps.keySet()) {
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

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.