Examples of InvocationListener


Examples of org.apache.aries.proxy.InvocationListener

                Bundle b = FrameworkUtil.getBundle(original.getClass());
                if (b == null) {
                  // we have a class from the framework parent, so use our bundle for proxying.
                  b = blueprintContainer.getBundleContext().getBundle();
                }
                InvocationListener collaborator = new Collaborator(cm, interceptors);

                intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
                        getClassesForProxying(original), original, collaborator);
            } catch (Exception u) {
                Bundle b = blueprintContainer.getBundleContext().getBundle();
View Full Code Here

Examples of org.apache.aries.proxy.InvocationListener

  public ProxyHandler(AbstractProxyManager abstractProxyManager, Callable<Object> dispatcher, InvocationListener listener)
  {
    target = dispatcher;
    proxyManager = abstractProxyManager;
    final InvocationListener nonNullListener;
    if (listener == null) {
      nonNullListener = new DefaultWrapper();
    } else {
      nonNullListener = listener;
    }
   
    core = new InvocationHandler() {
      public Object invoke(Object proxy, Method method, Object[] args)
          throws Throwable
      {
        Object result = null;
        Object token = null;
        boolean inInvoke = false;
        try {
          token = nonNullListener.preInvoke(proxy, method, args);
          inInvoke = true;
          result = method.invoke(target.call(), args);
          inInvoke = false;
          nonNullListener.postInvoke(token, proxy, method, result);

        } catch (Throwable e) {
          // whether the the exception is an error is an application decision
          // if we catch an exception we decide carefully which one to
          // throw onwards
          Throwable exceptionToRethrow = null;
          // if the exception came from a precall or postcall
          // we will rethrow it
          if (!inInvoke) {
            exceptionToRethrow = e;
          }
          // if the exception didn't come from precall or postcall then it
          // came from invoke
          // we will rethrow this exception if it is not a runtime
          // exception, but we must unwrap InvocationTargetExceptions
          else {
            if (e instanceof InvocationTargetException) {
              e = ((InvocationTargetException) e).getTargetException();
            }
           
            if (!(e instanceof RuntimeException)) {
              exceptionToRethrow = e;
            }
          }
          try {
            nonNullListener.postInvokeExceptionalReturn(token, proxy, method, e);
          } catch (Exception f) {
            // we caught an exception from
            // postInvokeExceptionalReturn
            // if we haven't already chosen an exception to rethrow then
            // we will throw this exception
View Full Code Here

Examples of org.apache.aries.proxy.InvocationListener

                Bundle b = FrameworkUtil.getBundle(original.getClass());
                if (b == null) {
                  // we have a class from the framework parent, so use our bundle for proxying.
                  b = blueprintContainer.getBundleContext().getBundle();
                }
                InvocationListener collaborator = new Collaborator(cm, interceptors);

                intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
                        getClassesForProxying(original), original, collaborator);
            } catch (Exception u) {
                Bundle b = blueprintContainer.getBundleContext().getBundle();
View Full Code Here

Examples of org.apache.aries.proxy.InvocationListener

                        }
                    }
                }
            }

            InvocationListener il = new ProxyInvocationListener(originalRef);
            try {
                return pm.createInterceptingProxy(originalRef.getBundle(), allClasses, svc, il);
            } catch (UnableToProxyException e) {
                throw new RuntimeException(e);
            }
View Full Code Here

Examples of org.apache.aries.proxy.InvocationListener

                Bundle b = FrameworkUtil.getBundle(original.getClass());
                if (b == null) {
                  // we have a class from the framework parent, so use our bundle for proxying.
                  b = blueprintContainer.getBundleContext().getBundle();
                }
                InvocationListener collaborator = new Collaborator(cm, interceptors);

                intercepted = BlueprintExtender.getProxyManager().createInterceptingProxy(b,
                        getClassesForProxying(), original, collaborator);
            } catch (Exception u) {
                Bundle b = blueprintContainer.getBundleContext().getBundle();
View Full Code Here

Examples of org.apache.aries.proxy.InvocationListener

                Bundle b = FrameworkUtil.getBundle(original.getClass());
                if (b == null) {
                  // we have a class from the framework parent, so use our bundle for proxying.
                  b = blueprintContainer.getBundleContext().getBundle();
                }
                InvocationListener collaborator = new Collaborator(cm, interceptors);

                intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
                        getClassesForProxying(original), original, collaborator);
            } catch (Exception u) {
                Bundle b = blueprintContainer.getBundleContext().getBundle();
View Full Code Here

Examples of org.apache.aries.proxy.InvocationListener

                        }
                    }
                }
            }

            InvocationListener il = new ProxyInvocationListener(originalRef);
            try {
                return pm.createInterceptingProxy(originalRef.getBundle(), allClasses, svc, il);
            } catch (UnableToProxyException e) {
                throw new RuntimeException(e);
            }
View Full Code Here

Examples of org.apache.aries.proxy.InvocationListener

                Bundle b = FrameworkUtil.getBundle(original.getClass());
                if (b == null) {
                  // we have a class from the framework parent, so use our bundle for proxying.
                  b = blueprintContainer.getBundleContext().getBundle();
                }
                InvocationListener collaborator = new Collaborator(cm, interceptors);

                intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
                        getClassesForProxying(original), original, collaborator);
            } catch (Exception u) {
                Bundle b = blueprintContainer.getBundleContext().getBundle();
View Full Code Here

Examples of org.apache.sirona.javaagent.spi.InvocationListener

        //System.out.println("listeners:" + listeners.toString());
        return listeners.toArray(new InvocationListener[listeners.size()]);
    }

    private static void addListener(final Collection<InvocationListener> listeners, final String key, final InvocationListener listener) {
        InvocationListener autoset;
        try {
            autoset = IoCs.autoSet(key, listener);
        } catch (final Exception e) {
            autoset = listener;
        }
View Full Code Here

Examples of org.mockito.listeners.InvocationListener


    @Test
    public void should_call_all_listener_when_mock_throws_exception() throws Exception {
        // given
        InvocationListener listener1 = mock(InvocationListener.class, "listener1");
        InvocationListener listener2 = mock(InvocationListener.class, "listener2");
        Foo foo = mock(Foo.class, withSettings().invocationListeners(listener1, listener2));
        doThrow(new OvenNotWorking()).when(foo).doSomething("cook");

        // when
        try {
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.