Package org.aopalliance.intercept

Examples of org.aopalliance.intercept.MethodInterceptor


        MethodPointcut methodCut = (MethodPointcut) attributes.remove("methodCut");
        if(methodCut != null) {
            currentMethodCut = methodCut;
        }

        MethodInterceptor interceptor = (MethodInterceptor) attributes.remove("interceptor");
        Object interceptorKey = attributes.remove("interceptorKey");
        Class mixinClass = (Class) attributes.remove("mixinClass");
        List mixinInterfaces = (List) attributes.remove("mixinInterfaces");

        ComponentPointcut componentCut = (ComponentPointcut) attributes.remove("componentCut");
View Full Code Here


     * @return the <code>Interceptor</code> object.
     * @throws NullPointerException if the interceptor can not be found in the
     *                              pico container.
     */
    public Interceptor create(Proxy proxy) throws NullPointerException {
        MethodInterceptor methodInterceptor = (MethodInterceptor) pico.getComponentInstance(interceptorComponentKey);
        if (methodInterceptor == null) {
            throw new NullPointerException("Interceptor with component key " + interceptorComponentKey
                    + " + not found in PicoContainer");
        }
        return new MethodInterceptorAdapter(methodInterceptor);
View Full Code Here

  public static void bindJNIContextClassLoader(Binder binder, Class<?> wrapInterface) {
    final ClassLoader mainClassLoader = GuiceUtils.class.getClassLoader();
    binder.bindInterceptor(
        Matchers.subclassesOf(wrapInterface),
        interfaceMatcher(wrapInterface, false),
        new MethodInterceptor() {
          @Override
          public Object invoke(MethodInvocation invocation) throws Throwable {
            Thread currentThread = Thread.currentThread();
            ClassLoader prior = currentThread.getContextClassLoader();
            try {
View Full Code Here

        "Non-void methods must be explicitly whitelisted with @AllowUnchecked: " + disallowed);

    Matcher<Method> matcher =
        Matchers.<Method>not(WHITELIST_MATCHER).and(interfaceMatcher(wrapInterface, false));
    binder.bindInterceptor(Matchers.subclassesOf(wrapInterface), matcher,
        new MethodInterceptor() {
          @Override
          public Object invoke(MethodInvocation invocation) throws Throwable {
            try {
              return invocation.proceed();
            } catch (RuntimeException e) {
View Full Code Here

    // unit testing without the creation of Guice injectors.
    bindThriftDecorator(new LoggingInterceptor());

    // Note: it's important that the capability interceptor is only applied to AuroraAdmin.Iface
    // methods, and does not pick up methods on AuroraSchedulerManager.Iface.
    MethodInterceptor authInterceptor = new UserCapabilityInterceptor();
    requestInjection(authInterceptor);
    bindInterceptor(
        THRIFT_IFACE_MATCHER,
        GuiceUtils.interfaceMatcher(AuroraAdmin.Iface.class, true),
        authInterceptor);
View Full Code Here

  public void testInterceptorIsInvokedWithNoTarget() throws Throwable {
    // Test return value
    int age = 25;
    MockControl miControl = MockControl.createControl(MethodInterceptor.class);
    MethodInterceptor mi = (MethodInterceptor) miControl.getMock();

    AdvisedSupport pc = new AdvisedSupport(new Class[] { ITestBean.class });
    pc.addAdvice(mi);
    AopProxy aop = createAopProxy(pc);

    // Really would like to permit null arg:can't get exact mi
    mi.invoke(null);
    //mi.invoke(new MethodInvocationImpl(aop, null, ITestBean.class,
    //  ITestBean.class.getMethod("getAge", null),
    //  null, l, r));
    //miControl.
    //miControl.setReturnValue(new Integer(age));
View Full Code Here

  public void testValidInvocation() throws Throwable {
    Method m = Object.class.getMethod("hashCode", (Class[]) null);
    Object proxy = new Object();
    final Object returnValue = new Object();
    List is = new LinkedList();
    is.add(new MethodInterceptor() {
      public Object invoke(MethodInvocation invocation) throws Throwable {
        return returnValue;
      }
    });
      ReflectiveMethodInvocation invocation = new ReflectiveMethodInvocation(proxy, null, //?
View Full Code Here

   * @param context if true, want context
   */
  private void testContext(final boolean context) throws Throwable {
    final String s = "foo";
    // Test return value
    MethodInterceptor mi = new MethodInterceptor() {
      public Object invoke(MethodInvocation invocation) throws Throwable {
        if (!context) {
          assertNoInvocationContext();
        } else {
          assertTrue("have context", ExposeInvocationInterceptor.currentInvocation() != null);
View Full Code Here

  }

  public void testDeclaredException() throws Throwable {
    final Exception expectedException = new Exception();
    // Test return value
    MethodInterceptor mi = new MethodInterceptor() {
      public Object invoke(MethodInvocation invocation) throws Throwable {
        throw expectedException;
      }
    };
    AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
View Full Code Here

   * net.sf.cglib UndeclaredThrowableException
   */
  public void testUndeclaredCheckedException() throws Throwable {
    final Exception unexpectedException = new Exception();
    // Test return value
    MethodInterceptor mi = new MethodInterceptor() {
      public Object invoke(MethodInvocation invocation) throws Throwable {
        throw unexpectedException;
      }
    };
    AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
View Full Code Here

TOP

Related Classes of org.aopalliance.intercept.MethodInterceptor

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.