1 22 package org.jboss.ejb3.test.classloader; 23 24 import java.lang.reflect.Method ; 25 26 import javax.ejb.Remote ; 27 import javax.ejb.Stateless ; 28 29 import java.net.URL ; 30 31 import org.apache.log4j.Category; 32 import org.apache.log4j.PropertyConfigurator; 33 import org.jboss.annotation.ejb.RemoteBinding; 34 35 39 @Stateless (name="Shared") 40 @Remote (Session30.class) 41 @RemoteBinding(jndiBinding = "Shared") 42 public class SharedBean implements Session30 43 { 44 private Category log; 45 46 public Throwable checkVersion() 47 { 48 Throwable error = null; 49 try 51 { 52 Class categoryClass = Category.class; 53 System.out.println("Category.CS: "+categoryClass.getProtectionDomain().getCodeSource()); 54 Class [] sig = {boolean.class, String .class}; 56 Method m = categoryClass.getDeclaredMethod("assert", sig); 57 System.out.println("found assert method: "+m); 58 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 60 URL resURL = loader.getResource("log4j.properties"); 61 System.out.println("found log4j.properties: "+resURL); 62 PropertyConfigurator config = new PropertyConfigurator(); 63 log = Category.getInstance(Session30Bean.class); 64 config.configure(resURL); 65 } 66 catch(Throwable t) 67 { 68 t.printStackTrace(); 69 error = t; 70 } 71 return error; 72 } 73 74 } 75 | Popular Tags |