Package org.apache.aries.proxy

Examples of org.apache.aries.proxy.ProxyManager


            List<Object> paths = getBlueprintPaths(bundle);
            if (paths == null) {
                // This bundle is not a blueprint bundle, so ignore it
                return false;
            }
            ProxyManager pm = proxyManager.getService();
            if (pm == null) {
                // The pm isn't available.  It may be because it is being untracked
                return false;
            }
            BundleContext bundleContext = bundle.getBundleContext();
View Full Code Here


    registerService(service);
  }
 
  private void registerProxyManager()
  {
    ProxyManager mgr = Skeleton.newMock(ProxyManager.class);
   
    //   public Object createProxy(Bundle clientBundle, Collection<Class<?>> classes, Callable<Object> dispatcher) throws UnableToProxyException;

    Skeleton.getSkeleton(mgr).registerMethodCallHandler(new MethodCall(ProxyManager.class, "createProxy", Bundle.class, Collection.class, Callable.class),
        new MethodCallHandler()
View Full Code Here

    // are enabling a slightly odd use case anyway.

    Bundle serviceProviderBundle = pair.ref.getBundle();
    Bundle owningBundle = ctx.getBundle();

    ProxyManager proxyManager = Activator.getProxyManager();

    for (String interfaceName : interfaces) {
      try {
        Class<?> potentialClass = serviceProviderBundle.loadClass(interfaceName);
        if (pair.ref.isAssignableTo(owningBundle, interfaceName)) {
          clazz.add(potentialClass);
        }
      } catch (ClassNotFoundException e) {
      }
    }

    if (clazz.isEmpty()) {
      throw new IllegalArgumentException(Arrays.asList(interfaces).toString());
    }

    Callable<Object> ih = new JNDIServiceDamper(ctx, interface1, filter, pair, dynamicRebind, timeout);

    // The ClassLoader needs to be able to load the service interface
    // classes so it needs to be
    // wrapping the service provider bundle. The class is actually defined
    // on this adapter.

    try {
      return proxyManager.createProxy(serviceProviderBundle, clazz, ih);
    } catch (UnableToProxyException e) {
      throw new IllegalArgumentException(e);
    } catch (RuntimeException e) {
      throw new IllegalArgumentException("Unable to create proxy for " + pair.ref, e);
    }
View Full Code Here

 
  private static final AtomicReference<AriesProxyService> INSTANCE =
    new AtomicReference<AriesProxyService>();
 
  private final ProxyManager getManager() {
    ProxyManager pManager = manager.get();
   
    if(pManager == null) {
      throw new NoProxySupportException();
    }
    return pManager;
View Full Code Here

            List<Object> paths = getBlueprintPaths(bundle);
            if (paths == null) {
                // This bundle is not a blueprint bundle, so ignore it
                return false;
            }
            ProxyManager pm = proxyManager.getService();
            if (pm == null) {
                // The pm isn't available.  It may be because it is being untracked
                return false;
            }
            BundleContext bundleContext = bundle.getBundleContext();
View Full Code Here



    public void testWiring() throws Exception {
        ComponentDefinitionRegistryImpl registry = parse("/test-references.xml");
        ProxyManager proxyManager = new AbstractProxyManager() {
            @Override
            protected Object createNewProxy(Bundle bundle, Collection<Class<?>> classes, Callable<Object> objectCallable, InvocationListener invocationListener) throws UnableToProxyException {
                return new Object();
            }
View Full Code Here

   * works as expected.
   */
  @Test
  public void checkProxyFinalClass() throws UnableToProxyException
  {
    ProxyManager mgr = context().getService(ProxyManager.class);
    Bundle b = FrameworkUtil.getBundle(this.getClass());
    Callable<Object> c = new TestCallable();
    Collection<Class<?>> classes = new ArrayList<Class<?>>();
    classes.add(TestCallable.class);
    try {
      mgr.createDelegatingProxy(b, classes, c, null);
    } catch (FinalModifierException e) {
      String msg = e.getMessage();
      assertEquals("The message didn't look right", "The class " + TestCallable.class.getName() + " is final.", msg);
      assertTrue("The message didn't appear in the toString", e.toString().endsWith(msg));
    }
View Full Code Here

   * It also does a quick validation on the exception message.
   */
  @Test
  public void checkProxyFinalMethods() throws UnableToProxyException
  {
    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());
    try {
      mgr.createDelegatingProxy(b, classes, c, null);
    } catch (FinalModifierException e) {
      assertTrue("The methods didn't appear in the message", e.getMessage().contains("run"));
    }
  }
View Full Code Here

  }

  @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

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.