1 22 package org.jboss.test.classloader.scoping.override.ejb.log4j113; 23 24 import java.lang.reflect.Method ; 25 import java.net.URL ; 26 import javax.ejb.SessionBean ; 27 import javax.ejb.SessionContext ; 28 import javax.ejb.CreateException ; 29 30 import org.apache.log4j.Category; 31 import org.apache.log4j.PropertyConfigurator; 32 import org.jboss.test.classloader.scoping.override.web.log4j113.Log4jServlet; 33 34 38 public class StatelessBean implements SessionBean 39 { 40 private Category log; 41 42 public void ejbCreate() throws CreateException 43 { 44 } 45 public void ejbActivate() 46 { 47 } 48 49 public void ejbPassivate() 50 { 51 } 52 53 public void ejbRemove() 54 { 55 } 56 public void setSessionContext(SessionContext context) 57 { 58 } 59 60 public Throwable checkVersion() 61 { 62 Throwable error = null; 63 try 65 { 66 Class categoryClass = Category.class; 67 System.out.println("Category.CS: "+categoryClass.getProtectionDomain().getCodeSource()); 68 Class [] sig = {boolean.class, String .class}; 70 Method m = categoryClass.getDeclaredMethod("assert", sig); 71 System.out.println("found assert method: "+m); 72 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 74 URL resURL = loader.getResource("log4j.properties"); 75 System.out.println("found log4j.properties: "+resURL); 76 PropertyConfigurator config = new PropertyConfigurator(); 77 log = Category.getInstance(StatelessBean.class); 78 config.configure(resURL); 79 } 80 catch(Throwable t) 81 { 82 t.printStackTrace(); 83 error = t; 84 } 85 return error; 86 } 87 } 88 | Popular Tags |