KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ha > httpsession > beanimpl > ejb > ServerTCLInterceptor


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.ha.httpsession.beanimpl.ejb;
8
9 import org.jboss.ejb.plugins.AbstractInterceptor;
10 import org.jboss.invocation.Invocation;
11
12 /**
13  * @author Scott.Stark@jboss.org
14  * @version $Revision: 1.2.6.1 $
15  */

16 public class ServerTCLInterceptor extends AbstractInterceptor
17 {
18    public Object JavaDoc invokeHome(Invocation mi) throws Exception JavaDoc
19    {
20       ClassLoader JavaDoc prevTCL = Thread.currentThread().getContextClassLoader();
21       ClassLoader JavaDoc tcl = (ClassLoader JavaDoc) mi.getValue("org.jboss.invocation.TCL");
22       try
23       {
24          // Set the active TCL to that of the invocation TCL
25
if( tcl != null )
26             Thread.currentThread().setContextClassLoader(tcl);
27          return getNext().invokeHome(mi);
28       }
29       finally
30       {
31          // Restore the incoming TCL if we overrode it
32
if( tcl != null )
33             Thread.currentThread().setContextClassLoader(prevTCL);
34       }
35    }
36
37    public Object JavaDoc invoke(Invocation mi) throws Exception JavaDoc
38    {
39       ClassLoader JavaDoc prevTCL = Thread.currentThread().getContextClassLoader();
40       ClassLoader JavaDoc tcl = (ClassLoader JavaDoc) mi.getValue("org.jboss.invocation.TCL");
41       try
42       {
43          // Set the active TCL to that of the invocation TCL
44
if( tcl != null )
45             Thread.currentThread().setContextClassLoader(tcl);
46          return getNext().invoke(mi);
47       }
48       finally
49       {
50          // Restore the incoming TCL if we overrode it
51
if( tcl != null )
52             Thread.currentThread().setContextClassLoader(prevTCL);
53       }
54    }
55 }
56
Popular Tags