4 Replies Latest reply on Feb 2, 2007 8:32 AM by Kabir Khan

    Du(Three)plicated proxy creation code

    Ales Justin Master

      We have totally the same proxy creation code in three places:
      - WrapperAdvice (managed)
      - AbstractDeploymentContext (deployers)
      - ProxyUtils (aop-int)

      <T> T createProxy(T target, Class<T> interfaceClass)
       {
       if (target == null)
       return null;
      
       GeneratedAOPProxyFactory proxyFactory = new GeneratedAOPProxyFactory();
       AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
       params.setInterfaces(new Class[] { interfaceClass });
       params.setObjectAsSuperClass(true);
       params.setTarget(target);
       Object proxy = proxyFactory.createAdvisedProxy(params);
       if( log.isTraceEnabled() )
       log.trace("Created proxy: "+proxy.getClass()+"@"+System.identityHashCode(proxy)+" target: "+target.getClass());
       return interfaceClass.cast(proxy);
       }


      Kabir, can we push this somehow in AOP (-jdk5)?
      Or should we do a mc-common module / project?