KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > classloader > scoping > override > ejb > log4j113 > StatelessBean


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.test.classloader.scoping.override.ejb.log4j113;
23
24 import java.lang.reflect.Method JavaDoc;
25 import java.net.URL JavaDoc;
26 import javax.ejb.SessionBean JavaDoc;
27 import javax.ejb.SessionContext JavaDoc;
28 import javax.ejb.CreateException JavaDoc;
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 /**
35  * @author Scott.Stark@jboss.org
36  * @version $Revision: 37406 $
37  */

38 public class StatelessBean implements SessionBean JavaDoc
39 {
40    private Category log;
41
42    public void ejbCreate() throws CreateException JavaDoc
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 JavaDoc context)
57    {
58    }
59
60    public Throwable JavaDoc checkVersion()
61    {
62       Throwable JavaDoc error = null;
63       // Validate the log4j env against the 1.1.3 classes
64
try
65       {
66          Class JavaDoc categoryClass = Category.class;
67          System.out.println("Category.CS: "+categoryClass.getProtectionDomain().getCodeSource());
68          // Check that the 1.1.3 assert(boolean, String) method exists
69
Class JavaDoc[] sig = {boolean.class, String JavaDoc.class};
70          Method JavaDoc m = categoryClass.getDeclaredMethod("assert", sig);
71          System.out.println("found assert method: "+m);
72          // Find the log4j.properties file
73
ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
74          URL JavaDoc 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 JavaDoc t)
81       {
82          t.printStackTrace();
83          error = t;
84       }
85       return error;
86    }
87 }
88
Popular Tags