Package org.aopalliance.intercept

Examples of org.aopalliance.intercept.MethodInterceptor


                         TypeEncounter<T> encounter) {
        Class<? super T> klass = literal.getRawType();

        do {
            for (Method method : klass.getDeclaredMethods()) {
                final MethodInterceptor interceptor = TimedInterceptor.forMethod(metricRegistry,
                                                                                 klass, method);
                if (interceptor != null) {
                    encounter.bindInterceptor(Matchers.only(method), interceptor);
                }
            }
View Full Code Here


    @Override
    public <T> void hear(TypeLiteral<T> literal,
                         TypeEncounter<T> encounter) {
        final Class<?> klass = literal.getRawType();
        for (Method method : klass.getDeclaredMethods()) {
            final MethodInterceptor interceptor = ExceptionMeteredInterceptor.forMethod(
                    metricRegistry,
                    klass,
                    method);

            if (interceptor != null) {
View Full Code Here

                         TypeEncounter<T> encounter) {
        Class<? super T> klass = literal.getRawType();

        do {
            for (Method method : klass.getDeclaredMethods()) {
                final MethodInterceptor interceptor = MeteredInterceptor.forMethod(metricRegistry,
                                                                                   klass,
                                                                                   method);
                if (interceptor != null) {
                    encounter.bindInterceptor(Matchers.only(method), interceptor);
                }
View Full Code Here

public class ValidationModule
    extends AbstractModule
{
  @Override
  protected void configure() {
    final MethodInterceptor interceptor = new ValidationInterceptor();
    bindInterceptor(Matchers.any(), Matchers.annotatedWith(Validate.class), interceptor);
    requestInjection(interceptor);
  }
View Full Code Here

        bindExplicitly();
        bindActions();
        bindCrudActions();

        // Bind a dummy interceptor to specifically test AOP interaction with decorated pages.
        bindInterceptor(Matchers.annotatedWith(Decorated.class), Matchers.any(), new MethodInterceptor() {
          @Override
          public Object invoke(MethodInvocation methodInvocation) throws Throwable {
            return methodInvocation.proceed();
          }
        });
View Full Code Here

    return org.springframework.retry.interceptor.Retryable.class.isAssignableFrom(intf);
  }

  @Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    MethodInterceptor delegate = getDelegate(invocation.getThis(), invocation.getMethod());
    if (delegate != null) {
      return delegate.invoke(invocation);
    }
    else {
      return invocation.proceed();
    }
  }
View Full Code Here

            retryable = AnnotationUtils.findAnnotation(method.getDeclaringClass(), Retryable.class);
          }
          if (retryable == null) {
            return this.delegates.put(method, null);
          }
          MethodInterceptor delegate;
          if (StringUtils.hasText(retryable.interceptor())) {
            delegate = this.beanFactory.getBean(retryable.interceptor(), MethodInterceptor.class);
          }
          else if (retryable.stateful()) {
            delegate = getStatefulInterceptor(target, method, retryable);
View Full Code Here

   * @see DATAREST-221
   */
  @Test
  public void wrapsDelegateResultInProxyIfTypesDontMatch() throws Throwable {

    MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(null), interceptor);

    when(invocation.getMethod()).thenReturn(Helper.class.getMethod("getHelper"));
    when(interceptor.invoke(invocation)).thenReturn("Foo");

    assertThat(methodInterceptor.invoke(invocation), is(instanceOf(Helper.class)));
  }
View Full Code Here

   * @see DATAREST-221
   */
  @Test
  public void retunsDelegateResultAsIsIfTypesMatch() throws Throwable {

    MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor);

    when(invocation.getMethod()).thenReturn(Helper.class.getMethod("getString"));
    when(interceptor.invoke(invocation)).thenReturn("Foo");

    assertThat(methodInterceptor.invoke(invocation), is((Object) "Foo"));
  }
View Full Code Here

   * @see DATAREST-221
   */
  @Test
  public void returnsNullAsIs() throws Throwable {

    MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor);

    when(interceptor.invoke(invocation)).thenReturn(null);

    assertThat(methodInterceptor.invoke(invocation), is(nullValue()));
  }
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.