I need aspectize some X classes at runtime, without using SystemClassLoader and 
jboss-aop.xml,

You couldn?t find such a sample in the examples folder and tried to run one of 
your examples in that way.

 
I have custom URLClassLoader which loaded with classpath of JBossAOP jars and 
that classes the code I have used

   public static void main(String[] args) {
  | 
  |     try {
  |       AdviceBinding binding = new AdviceBinding(
  | 
  |           "call(int java.util.ArrayList->size()) AND withincode(void 
Driver->caller())", null);
  | 
  |  
  | 
  |       binding.addInterceptor(CallerInterceptor1.class);
  | 
  |  
  | 
  |       AspectManager.verbose = true;
  | 
  |  
  | 
  |       AspectManager am = AspectManager.instance();
  | 
  |  
  | 
  |       am.addBinding(binding);
  | 
  |  
  | 
  |       org.jboss.aop.standalone.SystemClassLoader sc = new 
org.jboss.aop.standalone.SystemClassLoader( createURLClassLoader() );
  | 
  |  
  | 
  |       am.registerClassLoader(sc);
  | 
  |  
  | 
  |       byte[] b = am.translate("Driver", sc);
  | 
  |  
  | 
  |      Class c = sc.defineClassFromBytes("Driver", b, true);
  | 
  |      System.out.println("c="+c);
  | 
  |      Method m = c.getMethod("main", new Class[] {String[].class});
  | 
  |  
  | 
  |      m.invoke(null, new Object[] {new String[] {} });
  | 
  |  
  | 
  |     }
  | 
  |     catch (Exception ex) {  ex.printStackTrace();  }
  | 
  |   }
  | 
  |  
  | 
  |  
  | 
  | static URLClassLoader2 createURLClassLoader() throws Exception {
  | 
  |     URL urls[] = null;
  | 
  |  
  | 
  |     File f = new File("resources/aop/jars"); //the path where JBossAOP jars 
and that classes located
  | 
  |  
  | 
  |     if (f.isDirectory()) {
  | 
  |       File ff[] = f.listFiles();
  | 
  |       urls = new URL[ff.length];
  | 
  |  
  | 
  |       for (int i = 0; i < ff.length; i++) {
  | 
  |         urls = ff.toURL();
  | 
  |       }
  | 
  |     }
  | 
  |  
  | 
  |     return new URLClassLoader2(urls, null);
  | 
  |   }
 

It fails to transform bytecode and return null, 

Could you help me and send similar working code or indicate where I should look 
for that.



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

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


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-Development mailing list
JBoss-Development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to