Package org.aopalliance.intercept

Examples of org.aopalliance.intercept.MethodInterceptor


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

    MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor);

    when(invocation.getMethod()).thenReturn(Helper.class.getMethod("getPrimitive"));
    when(interceptor.invoke(invocation)).thenReturn(1L);

    assertThat(methodInterceptor.invoke(invocation), is((Object) 1L));
    verify(factory, times(0)).createProjection(anyObject(), (Class<?>) anyObject());
  }
View Full Code Here


    Source source = new Source();
    source.firstname = "Dave";

    when(invocation.getMethod()).thenReturn(Projection.class.getMethod("getFirstname"));
    MethodInterceptor interceptor = new PropertyAccessingMethodInterceptor(source);

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

  @Test
  public void invokesMethodOnTarget() throws Throwable {

    when(invocation.getMethod()).thenReturn(Projection.class.getMethod("propertyFromTarget"));

    MethodInterceptor interceptor = new SpelEvaluatingMethodInterceptor(delegate, new Target(), null);

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

   * @param projectionType must not be {@literal null}.
   * @return
   */
  private MethodInterceptor getMethodInterceptor(Object source, Class<?> projectionType) {

    MethodInterceptor propertyInvocationInterceptor = new PropertyAccessingMethodInterceptor(source);
    return new ProjectingMethodInterceptor(this, getSpelMethodInterceptorIfNecessary(source, projectionType,
        propertyInvocationInterceptor));
  }
View Full Code Here

      bind(HistoryManager.class).to(NoopHistoryManager.class).in(Scopes.SINGLETON);
    }
  }

  private void bindMethodInterceptorForStringTemplateClassLoaderWorkaround() {
    bindInterceptor(Matchers.subclassesOf(JDBIHistoryManager.class), Matchers.any(), new MethodInterceptor() {

      @Override
      public Object invoke(MethodInvocation invocation) throws Throwable {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
View Full Code Here

        this.bind(ConfigurationState.class).toProvider(ConfigurationStateProvider.class).in(Scopes.SINGLETON);
        this.bind(ValidatorFactory.class).toProvider(ValidatorFactoryProvider.class).in(Scopes.SINGLETON);
        this.bind(Validator.class).toProvider(ValidatorProvider.class);

        // AOP stuff
        MethodInterceptor validateMethodInterceptor = new ValidateMethodInterceptor();
        this.binder().requestInjection(validateMethodInterceptor);
        this.bindInterceptor(Matchers.any(), Matchers.annotatedWith(Validate.class), validateMethodInterceptor);
    }
View Full Code Here

        assertEquals(2, monitor.getRequestCount());

        service.baz();
        assertEquals(2, monitor.getRequestCount());       
       
        MethodInterceptor wrapper =
            (MethodInterceptor)context.getBean("dummyServicePerformanceMonitorInterceptor");
        assertNotNull(wrapper);  
    }
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() {
      @Override
      public Object invoke(MethodInvocation invocation) throws Throwable {
        if (!context) {
          assertNoInvocationContext();
        } else {
View Full Code Here

  @Test
  public void testDeclaredException() throws Throwable {
    final Exception expectedException = new Exception();
    // Test return value
    MethodInterceptor mi = new MethodInterceptor() {
      @Override
      public Object invoke(MethodInvocation invocation) throws Throwable {
        throw expectedException;
      }
    };
View Full Code Here

   */
  @Test
  public void testUndeclaredCheckedException() throws Throwable {
    final Exception unexpectedException = new Exception();
    // Test return value
    MethodInterceptor mi = new MethodInterceptor() {
      @Override
      public Object invoke(MethodInvocation invocation) throws Throwable {
        throw unexpectedException;
      }
    };
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.