Package org.aopalliance.intercept

Examples of org.aopalliance.intercept.MethodInterceptor


  @Test
  public void testNullPrimitiveWithCglibProxy() {

    Bar target = new Bar();
    ProxyFactory factory = new ProxyFactory(target);
    factory.addAdvice(new MethodInterceptor() {
      @Override
      public Object invoke(MethodInvocation invocation) throws Throwable {
        return null;
      }
    });
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<Object> is = new LinkedList<Object>();
    is.add(new MethodInterceptor() {
      @Override
      public Object invoke(MethodInvocation invocation) throws Throwable {
        return returnValue;
      }
    });
View Full Code Here

  public void testGetThis() {
    final AtomicReference<Object> lastTarget = new AtomicReference<Object>();

    Injector injector = Guice.createInjector(new AbstractModule() {
      protected void configure() {
        bindInterceptor(Matchers.any(), Matchers.any(), new MethodInterceptor() {
          public Object invoke(MethodInvocation methodInvocation) throws Throwable {
            lastTarget.set(methodInvocation.getThis());
            return methodInvocation.proceed();
          }
        });
View Full Code Here

    };

    ProxyFactory proxy = new ProxyFactory();
    proxy.setTarget(reader);
    proxy.setInterfaces(new Class<?>[] { ItemReader.class, ItemStream.class });
    proxy.addAdvice(new MethodInterceptor() {
      @Override
      public Object invoke(MethodInvocation invocation) throws Throwable {
        return invocation.proceed();
      }
    });
View Full Code Here

  }

  public void testInterceptorChainWithRetry() throws Exception {
    ((Advised) service).addAdvice(interceptor);
    final List<Object> list = new ArrayList<Object>();
    ((Advised) service).addAdvice(new MethodInterceptor() {
            @Override
      public Object invoke(MethodInvocation invocation) throws Throwable {
        list.add("chain");
        return invocation.proceed();
      }
View Full Code Here

  @Test
  public void testProxyWithNoTarget() throws Exception {
    ProxyFactory factory = new ProxyFactory();
    factory.addInterface(DataSource.class);
    factory.addAdvice(new MethodInterceptor() {
      @Override
      public Object invoke(MethodInvocation invocation) throws Throwable {
        return null;
      }
    });
View Full Code Here

      TransactionInterceptor advice = new TransactionInterceptor(transactionManager,
          PropertiesConverter.stringToProperties("create*=PROPAGATION_REQUIRES_NEW,"
              + isolationLevelForCreate + "\ngetLastJobExecution*=PROPAGATION_REQUIRES_NEW,"
              + isolationLevelForCreate + "\n*=PROPAGATION_REQUIRED"));
      if (validateTransactionState) {
        DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(new MethodInterceptor() {
          @Override
          public Object invoke(MethodInvocation invocation) throws Throwable {
            if (TransactionSynchronizationManager.isActualTransactionActive()) {
              throw new IllegalStateException(
                  "Existing transaction detected in JobRepository. "
View Full Code Here

                @Override
                public Object answer(InvocationOnMock invocation) throws Throwable {
                    return invocation.getArguments()[2];
                }
            });
        MethodInterceptor securityInterceptor = new ForwardMethodInterceptor();
        serviceRegistrationManagerImpl = new ConnectorRegistrationManager(bundleContext, transformationEngine,
            securityInterceptor, new SecurityAttributeProviderImpl());
        serviceUtils = new DefaultOsgiUtilsService(bundleContext);
        mockedServiceUtils = mock(DefaultOsgiUtilsService.class);
        mockedServiceUtils = mock(DefaultOsgiUtilsService.class);
View Full Code Here

     * @return a proxy that locks while its methods are executed
     */
    private Object getDisposalLockProxy(Object bean, final Lock lock) {
      ProxyFactory factory = new ProxyFactory(bean);
      factory.setProxyTargetClass(proxyTargetClass);
      factory.addAdvice(new MethodInterceptor() {
        public Object invoke(MethodInvocation invocation) throws Throwable {
          lock.lock();
          try {
            return invocation.proceed();
          } finally {
View Full Code Here

  @Test
  public void testInterceptorChainWithRetry() throws Exception {
    ((Advised) service).addAdvice(interceptor);
    final List<String> list = new ArrayList<String>();
    ((Advised) service).addAdvice(new MethodInterceptor() {
      public Object invoke(MethodInvocation invocation) throws Throwable {
        list.add("chain");
        return invocation.proceed();
      }
    });
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.