Package org.aopalliance.intercept

Examples of org.aopalliance.intercept.MethodInterceptor


  @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


   * creates a proxy that dispatches invocations to the currently bound {@link ProcessInstance}
   *
   * @return shareable {@link ProcessInstance}
   */
  private Object createSharedProcessInstance()   {
    ProxyFactory proxyFactoryBean = new ProxyFactory(ProcessInstance.class, new MethodInterceptor() {
      public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        String methodName = methodInvocation.getMethod().getName() ;

        logger.info("method invocation for " + methodName+ ".");
        if(methodName.equals("toString"))
View Full Code Here

  }

  private Object createDirtyCheckingProxy(final String name, final Object scopedObject) throws Throwable {
    ProxyFactory proxyFactoryBean = new ProxyFactory(scopedObject);
    proxyFactoryBean.setProxyTargetClass(this.proxyTargetClass);
    proxyFactoryBean.addAdvice(new MethodInterceptor() {
      public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        Object result = methodInvocation.proceed();
        persistVariable(name, scopedObject);
        return result;
      }
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

    /**
     * Binds transaction interceptor for all methods or classes that are annotated with {@link Transactional}.
     */
    public static void bindTransactionInterceptor(@NotNull Binder binder, @NotNull Key<Database> databaseKey) {
        Provider<Database> databaseProvider = binder.getProvider(databaseKey);
        MethodInterceptor interceptor = new AopAllianceTransactionalMethodInterceptor(databaseProvider);

        binder.bindInterceptor(any(), annotatedWith(Transactional.class), interceptor);
        binder.bindInterceptor(annotatedWith(Transactional.class), any(), interceptor);
    }
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.