[jboss-dev-forums] [Design the new POJO MicroContainer] - Using ClassInfo in JBoss AOP

kabir.khan@jboss.com do-not-reply at jboss.com
Mon Jan 5 13:16:30 EST 2009


We would like to start using ClassInfo in JBoss AOP, since that will get rid of the duplicated code we have in our pointcut matchers. Currently we have code doing the same thing for javassist (during weaving) and for java.lang.reflect (to populate the advisors of woven classes at runtime).

For our use the current implementation of JavassistTypeInfoFactoryImpl has a few problems:

1) From what I can see, it does not allow the specification of a javassist ClassPool to use, instead it falls back on ClassPool.getDefault(), which just gives you the stuff on the bootstrap classpath, and so will not work in AS for application classes. It should be possible to pass in the ClassPool to use, or if working out the ClassPool from the classloader, to pass in some kind of ClassPool factory so that it uses the same underlying ClassPool as AOP does.

2) We would want to use the javassist version of ClassInfo during weaving, i.e. before the classes are loaded. However, the WeakClassCache used by JavassistTypeInfoFactoryImpl seems to need to load the class:

  | Thread [main] (Suspended (breakpoint at line 126 in JavassistTypeInfoFactoryImpl))	
  | 	JavassistTypeInfoFactoryImpl.instantiate(Class) line: 126	
  | 	JavassistTypeInfoFactoryImpl(WeakClassCache).get(Class) line: 67	
  | 	JavassistTypeInfoFactoryImpl.getTypeInfo(Class<?>) line: 280	
  | 	JavassistTypeInfoFactoryImpl.getTypeInfo(String, ClassLoader) line: 312	
  | 	JavassistTypeInfoFactory.getTypeInfo(String, ClassLoader) line: 54	
  | 	JavassistArrayUnitTestCase(AbstractClassInfoTest).testBasics(Class<?>, TypeInfo) line: 72	
  | 	JavassistArrayUnitTestCase(ClassInfoArrayTest).testArray(Object) line: 139	
  | 	JavassistArrayUnitTestCase(ClassInfoArrayTest).testSimpleArray() line: 46
  | 
So that is not good for us. We need a javassist version of ClassInfo to use during weaving that does not load the class as part of its instantiation,  once woven the class can be put into the WeakClassCache.


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

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



More information about the jboss-dev-forums mailing list