KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > classloader > Session30Bean


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.test.classloader;
23
24 import java.lang.reflect.Method JavaDoc;
25
26 import javax.ejb.Remote JavaDoc;
27 import javax.ejb.Stateless JavaDoc;
28
29 import java.net.URL JavaDoc;
30
31 import org.apache.log4j.Category;
32 import org.apache.log4j.PropertyConfigurator;
33 import org.jboss.annotation.ejb.RemoteBinding;
34
35 /**
36  * @version <tt>$Revision: 44532 $</tt>
37  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
38  */

39 @Stateless JavaDoc(name="Session30")
40 @Remote JavaDoc(Session30.class)
41 @RemoteBinding(jndiBinding = "Session30")
42 public class Session30Bean implements Session30
43 {
44    private Category log;
45    
46    public Throwable JavaDoc checkVersion()
47    {
48       Throwable JavaDoc error = null;
49       // Validate the log4j env against the 1.1.3 classes
50
try
51       {
52          Class JavaDoc categoryClass = Category.class;
53          System.out.println("Category.CS: "+categoryClass.getProtectionDomain().getCodeSource());
54          // Check that the 1.1.3 assert(boolean, String) method exists
55
Class JavaDoc[] sig = {boolean.class, String JavaDoc.class};
56          Method JavaDoc m = categoryClass.getDeclaredMethod("assert", sig);
57          System.out.println("found assert method: "+m);
58          // Find the log4j.properties file
59
ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
60          URL JavaDoc 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 JavaDoc t)
67       {
68          t.printStackTrace();
69          error = t;
70       }
71       return error;
72    }
73    
74 }
75
Popular Tags