[jboss-dev-forums] [Design the new POJO MicroContainer] - Du(Three)plicated proxy creation code

alesj do-not-reply at jboss.com
Fri Feb 2 07:07:46 EST 2007


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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4009975#4009975

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4009975



More information about the jboss-dev-forums mailing list