Examples of MethodInterceptor


Examples of org.aopalliance.intercept.MethodInterceptor

    {
        final Class[] interfaces = new Class[]{stack.getServiceInterface()};
        final ClassLoader classLoader = invokingModule.getClassResolver().getClassLoader();
        final Object parameter = parameters.get( 0 );
        Defense.isAssignable( parameter, MethodInterceptor.class, "Implementation Object" );
        MethodInterceptor methodInterceptor = ( MethodInterceptor )parameter;
        final InvocationHandler invocationHandler = new MethodInterceptorInvocationHandler( methodInterceptor, stack );
        stack.push( Proxy.newProxyInstance( classLoader, interfaces, invocationHandler ) );
    }
View Full Code Here

Examples of org.aopalliance.intercept.MethodInterceptor

     */
    public void createInterceptor(InterceptorStack stack, Module invokingModule, Object parameters)
    {
        final Object parameter = ((List) parameters).get( 0 );
        Defense.isAssignable( parameter, MethodInterceptor.class, "Implementation Object" );
        MethodInterceptor methodInterceptor = ( MethodInterceptor )parameter;
        createInterceptor(stack, invokingModule, methodInterceptor);
    }
View Full Code Here

Examples of org.aopalliance.intercept.MethodInterceptor

        bind( ConfigurationState.class ).toProvider( ConfigurationStateProvider.class ).in( Singleton.class );
        bind( ValidatorFactory.class ).toProvider( ValidatorFactoryProvider.class ).in( Singleton.class );
        bind( Validator.class ).toProvider( ValidatorProvider.class );

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

Examples of org.aopalliance.intercept.MethodInterceptor

   * 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

Examples of org.aopalliance.intercept.MethodInterceptor

  }

  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

Examples of org.aopalliance.intercept.MethodInterceptor

    return Proxy.newProxyInstance(getClass().getClassLoader(), advised.getTargetSource().getInterfaces(), this);
  }

  @Override
  public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
    MethodInterceptor methodInterceptor = advised.getMethodInterceptor();
    if (advised.getMethodMatcher() != null
        && advised.getMethodMatcher().matches(method, advised.getTargetSource().getTarget().getClass())) {
      return methodInterceptor.invoke(new ReflectiveMethodInvocation(advised.getTargetSource().getTarget(),
          method, args));
    } else {
      return method.invoke(advised.getTargetSource().getTarget(), args);
    }
  }
View Full Code Here

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

Examples of org.aopalliance.intercept.MethodInterceptor

     * @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

Examples of org.aopalliance.intercept.MethodInterceptor

  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

Examples of org.aopalliance.intercept.MethodInterceptor

        "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
TOP
Copyright © 2018 www.massapi.com. 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.