User: cgjung
Date: 02/03/12 03:04:45
Modified: jboss.net/src/main/org/jboss/net/axis
AxisInvocationHandler.java XMLResourceProvider.java
Added: jboss.net/src/main/org/jboss/net/axis Constants.java
Deployment.java ResetClassLoaderHandler.java
SetClassLoaderHandler.java
Log:
Axis Beta RC1 is here. Needs no more to be patched for integrating with the
jboss classloading architecture. Lots of interna have changed, though.
Adapted the deployment descriptors to support WSDD now.
Revision Changes Path
1.7 +266 -219
contrib/jboss.net/src/main/org/jboss/net/axis/AxisInvocationHandler.java
Index: AxisInvocationHandler.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/axis/AxisInvocationHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AxisInvocationHandler.java 4 Feb 2002 09:38:58 -0000 1.6
+++ AxisInvocationHandler.java 12 Mar 2002 11:04:45 -0000 1.7
@@ -5,14 +5,12 @@
* See terms of license at gnu.org.
*/
-// $Id: AxisInvocationHandler.java,v 1.6 2002/02/04 09:38:58 cgjung Exp $
+// $Id: AxisInvocationHandler.java,v 1.7 2002/03/12 11:04:45 cgjung Exp $
package org.jboss.net.axis;
-import org.apache.axis.client.ServiceClient;
-import org.apache.axis.AxisEngine;
-import org.apache.axis.AxisFault;
-import org.apache.axis.MessageContext;
+import org.apache.axis.client.Call;
+import org.apache.axis.client.Service;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -22,227 +20,276 @@
import java.util.HashMap;
import java.net.URL;
+import javax.xml.rpc.namespace.QName;
+
/**
* An invocation handler that allows typed and persistent client access to
* remote SOAP/Axis services. Adds method/interface to name resolution
- * to the axis client engine.
- *
- * @created 1. Oktober 2001, 09:29
- * @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
- * @version $Revision: 1.6 $
- * Change notes:
+ * to the axis client engine. Unfortunately the AxisClientProxy has a
package-protected
+ * constructor, otherwise we could inherit from there.
+ * <br>
+ * <h3>Change notes</h3>
* <ul>
- * <li> 17.12.01: CGJ, Added overtaking of basic authentication data from
- * target url
+ * <li> cgj, 09.03.02: Adopted axis alpha3 changes. </li>
+ * <li> cgj, 17.12.01: Added overtaking of basic authentication
+ * data from target url.
* <li>
* </ul>
+ * @created 1. Oktober 2001, 09:29
+ * @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
+ * @version $Revision: 1.7 $
*/
-public class AxisInvocationHandler implements InvocationHandler
-{
+public class AxisInvocationHandler implements InvocationHandler {
+
- /** mapping of methods to interface names */
- final protected Map methodToInterface;
- /** mapping of methods to method names */
- final protected Map methodToName;
- /** the "session" management underneath */
- final protected ServiceClient serviceClient;
-
- /** Creates new AxisInvocationHandler */
- public AxisInvocationHandler(ServiceClient client, Map methodMap, Map
interfaceMap)
- {
- this.serviceClient=client;
- this.methodToInterface=interfaceMap;
- this.methodToName=methodMap;
- // we set maintain session for this to true
- // probably we should make this a configurable
- // parameter and more probably we should
- // have a hook for finalizing the session
- // explicitely and implicitely by the gc!
- serviceClient.setMaintainSession(true);
- }
-
- /** Creates new AxisInvocationHandler */
- public AxisInvocationHandler(ServiceClient client, Map methodMap)
- {
- this(client,methodMap,new DefaultInterfaceMap());
- }
-
- /** Creates new AxisInvocationHandler */
- public AxisInvocationHandler(ServiceClient client)
- {
- this(client,new DefaultMethodMap());
- }
-
- /** Creates new AxisInvocationHandler pointing to a given url, using the given
engine */
- public AxisInvocationHandler(URL endpoint, AxisEngine engine, Map methodMap, Map
interfaceMap) throws AxisFault
- {
- this(new ServiceClient(endpoint.toString(),engine),methodMap,interfaceMap);
- setBasicAuthentication(endpoint);
- }
-
- /** Creates new AxisInvocationHandler pointing to a given url, using the given
engine */
- public AxisInvocationHandler(URL endpoint, AxisEngine engine, Map methodMap)
throws AxisFault
- {
- this(endpoint,engine,methodMap, new DefaultInterfaceMap());
- setBasicAuthentication(endpoint);
- }
-
- /** Creates new AxisInvocationHandler pointing to a given url, using the given
engine */
- public AxisInvocationHandler(URL endpoint, AxisEngine engine) throws AxisFault
- {
- this(endpoint,engine,new DefaultMethodMap());
- setBasicAuthentication(endpoint);
- }
-
- /** Creates new AxisInvocationHandler pointing to a given url, using the given
engine */
- public AxisInvocationHandler(URL endpoint, Map methodMap, Map interfaceMap)
throws AxisFault
- {
- this(new ServiceClient(endpoint.toString()),methodMap,interfaceMap);
- setBasicAuthentication(endpoint);
- }
-
- /** Creates new AxisInvocationHandler pointing to a given url, using the given
engine */
- public AxisInvocationHandler(URL endpoint, Map methodMap) throws AxisFault
- {
- this(endpoint,methodMap,new DefaultInterfaceMap());
- setBasicAuthentication(endpoint);
- }
-
- /** Creates new AxisInvocationHandler pointing to a given url */
- public AxisInvocationHandler(URL endpoint) throws AxisFault
- {
- this(endpoint,new DefaultMethodMap());
- setBasicAuthentication(endpoint);
- }
-
- /** helper to transfer url authentication information into engine */
- protected void setBasicAuthentication(URL target)
- {
- String userInfo=target.getUserInfo();
-
- if(userInfo!=null)
- {
- java.util.StringTokenizer tok=new java.util.StringTokenizer(userInfo,":");
- if(tok.hasMoreTokens())
- {
- serviceClient.set(MessageContext.USERID,tok.nextToken());
- if(tok.hasMoreTokens())
- {
- serviceClient.set(MessageContext.PASSWORD,tok.nextToken());
- }
- }
- }
- }
-
- /** invoke given namespace+method+args */
- public Object invoke(String serviceName, String methodName, Object[] args)
throws AxisFault
- {
- return serviceClient.invoke(serviceName,methodName,args);
- }
-
- /** invoke with additional method parameter signature */
- public Object invoke(String serviceName, String methodName, Object[] args,
Class[] parameters) throws AxisFault
- {
- // classes are normally ignored
- return invoke(serviceName,methodName,args);
- }
-
- /** generic invocation method */
- public java.lang.Object invoke(java.lang.Object target,
- java.lang.reflect.Method method, java.lang.Object[] args)
- throws java.lang.Throwable
- {
- return invoke((String) methodToInterface.get(method),
- (String) methodToName.get(method), args,method.getParameterTypes());
- }
-
- /** default creation of service */
- public static Object createAxisService(Class _interface, URL endpoint) throws
AxisFault
- {
- return createAxisService(_interface,new AxisInvocationHandler(endpoint));
- }
-
- /** default creation of service */
- public static Object createAxisService(Class _interface, URL endpoint,
AxisEngine engine) throws AxisFault
- {
- return createAxisService(_interface,new
AxisInvocationHandler(endpoint,engine));
- }
-
- /** default creation of service */
- public static Object createAxisService(Class _interface, AxisInvocationHandler
handler) throws AxisFault
- {
- return Proxy.newProxyInstance(_interface.getClassLoader(),new Class[]
- {_interface},handler);
- }
-
- /**
- * a tiny helper that does some default mapping of methods to interface names
- */
-
- public static class DefaultInterfaceMap extends HashMap
- {
-
- /** no entries is the default */
- public DefaultInterfaceMap()
- {
- super(0);
- }
-
- /** returns default interface if no mapping of method/interface is defined */
- public Object get(Object key)
- {
-
- // first try a direct lookup
- Object result=super.get(key);
-
- if(result==null && key instanceof Method)
- {
- // if that is unsuccessful, we try to
- // lookup the class/interface itself
- result=super.get(((Method) key).getDeclaringClass());
-
- // if that is not specified, we simply extract the
- // un-qualified classname
- if(result==null)
- {
- String sresult=((Method) key).getDeclaringClass().getName();
- if(sresult.indexOf(".")!=-1)
- sresult=sresult.substring(sresult.lastIndexOf(".")+1);
- result=sresult;
- }
- }
-
- return result;
- }
- }
-
- /**
- * a tiny helper that does some default mapping of methods to method names
- */
-
- public static class DefaultMethodMap extends HashMap
- {
-
- /** no entries is the default */
- public DefaultMethodMap()
- {
- super(0);
- }
-
- /** returns default interface if no mapping is defined */
- public Object get(Object key)
- {
-
- Object result=super.get(key);
-
- if(result==null && key instanceof Method)
- {
- result=((Method) key).getName();
- }
-
- return result;
- }
- }
+ //
+ // Attributes
+ //
+
+ /** mapping of methods to interface names */
+ final protected Map methodToInterface;
+ /** mapping of methods to method names */
+ final protected Map methodToName;
+ /** the call object to which we delegate */
+ final protected Call call;
+
+ //
+ // Constructors
+ //
+
+ /**
+ * Creates a new AxisInvocationHandler
+ * @param call the Axis call object
+ * @param methodMap a map of Java method to service method names
+ * @param interfaceMap a map of Java interface to service names
+ */
+ public AxisInvocationHandler(Call call, Map methodMap, Map interfaceMap) {
+ this.call = call;
+ this.methodToInterface = interfaceMap;
+ this.methodToName = methodMap;
+ }
+
+ /**
+ * Creates a new AxisInvocationHandler
+ * @param endpoint target address of the service
+ * @param service an Axis service object
+ * @param methodMap a map of Java method to service method names
+ * @param interfaceMap a map of Java interface to service names
+ */
+ public AxisInvocationHandler(
+ URL endpoint,
+ Service service,
+ Map methodMap,
+ Map interfaceMap) {
+ this(new Call(service), methodMap, interfaceMap);
+ call.setTargetEndpointAddress(endpoint);
+ setBasicAuthentication(endpoint);
+ }
+
+ /**
+ * Creates a new AxisInvocationHandler
+ * @param endPoint target url of the web service
+ * @param methodMap a map of Java method to service method names
+ * @param interfaceMap a map of Java interface to service names
+ * @param maintainSession a flag that indicates whether this handler
+ * should keep a persistent session with the service endpoint
+ */
+ public AxisInvocationHandler(
+ URL endPoint,
+ Map methodMap,
+ Map interfaceMap,
+ boolean maintainSession) {
+ this(endPoint, new Service(), methodMap, interfaceMap);
+ call.setMaintainSession(maintainSession);
+ }
+
+ /**
+ * Creates a new AxisInvocationHandler that keeps a persistent session with
+ * the service endpoint
+ * @param endPoint target url of the web service
+ * @param methodMap a map of Java method to service method names
+ * @param interfaceMap a map of Java interface to service names
+ */
+ public AxisInvocationHandler(URL endPoint, Map methodMap, Map interfaceMap) {
+ this(endPoint, methodMap, interfaceMap, true);
+ }
+
+ /**
+ * Creates a new AxisInvocationHandler that keeps a persistent session with
+ * the service endpoint. The unqualified name of the
+ * intercepted Java interface will be the used service name.
+ * @param endPoint target url of the web service
+ * @param methodMap a map of Java method to service method names
+ */
+ public AxisInvocationHandler(URL endPoint, Map methodMap) {
+ this(endPoint, methodMap, new DefaultInterfaceMap());
+ }
+
+ /**
+ * Creates a new AxisInvocationHandler that keeps a persistent session with
+ * the service endpoint. The unqualified name of the
+ * intercepted Java interface will be the used service name.
+ * Intercepted methods are mapped straightforwardly to web service names.
+ * @param endPoint target url of the web service
+ * @param methodMap a map of Java method to service method names
+ */
+ public AxisInvocationHandler(URL endPoint) {
+ this(endPoint, new DefaultMethodMap());
+ }
+
+ //
+ // Helpers
+ //
+
+ /** helper to transfer url authentication information into engine */
+ protected void setBasicAuthentication(URL target) {
+ String userInfo = target.getUserInfo();
+ if (userInfo != null) {
+ java.util.StringTokenizer tok = new
java.util.StringTokenizer(userInfo, ":");
+ if (tok.hasMoreTokens()) {
+ call.setUsername(tok.nextToken());
+ if (tok.hasMoreTokens()) {
+ call.setPassword(tok.nextToken());
+ }
+ }
+ }
+ }
+
+ //
+ // Invocationhandling API
+ //
+
+ /** invoke given namespace+method+args */
+ public Object invoke(String serviceName, String methodName, Object[] args)
+ throws java.rmi.RemoteException {
+ return call.invoke(serviceName, methodName, args);
+ }
+
+ /** invoke with additional method parameter signature */
+ public Object invoke(
+ String serviceName,
+ String methodName,
+ Object[] args,
+ Class[] parameters)
+ throws java.rmi.RemoteException {
+ // classes are normally ignored
+ return invoke(serviceName, methodName, args);
+ }
+
+ /** generic invocation method */
+ public java.lang.Object invoke(
+ java.lang.Object target,
+ java.lang.reflect.Method method,
+ java.lang.Object[] args)
+ throws java.lang.Throwable {
+ return invoke(
+ (String) methodToInterface.get(method),
+ (String) methodToName.get(method),
+ args,
+ method.getParameterTypes());
+ }
+
+
+ //
+ // Static API
+ //
+
+ /** default creation of service */
+ public static Object createAxisService(Class _interface, URL endpoint)
+ {
+ return createAxisService(_interface, new
AxisInvocationHandler(endpoint));
+ }
+
+ /** default creation of service */
+ public static Object createAxisService(
+ Class _interface,
+ URL endpoint, Service service)
+ {
+ return createAxisService(
+ _interface,
+ new AxisInvocationHandler(endpoint, service, new
DefaultMethodMap(), new DefaultInterfaceMap()));
+ }
+
+ /** default creation of service */
+ public static Object createAxisService(
+ Class _interface,
+ Call call)
+ {
+ return createAxisService(
+ _interface,
+ new AxisInvocationHandler(call, new DefaultMethodMap(), new
DefaultInterfaceMap()));
+ }
+
+ /** default creation of service */
+ public static Object createAxisService(
+ Class _interface,
+ AxisInvocationHandler handler)
+ {
+ return Proxy.newProxyInstance(
+ _interface.getClassLoader(),
+ new Class[] { _interface },
+ handler);
+ }
+
+ /**
+ * a tiny helper that does some default mapping of methods to interface names
+ */
+
+ public static class DefaultInterfaceMap extends HashMap {
+
+ /** no entries is the default */
+ public DefaultInterfaceMap() {
+ super(0);
+ }
+
+ /** returns default interface if no mapping of method/interface is
defined */
+ public Object get(Object key) {
+
+ // first try a direct lookup
+ Object result = super.get(key);
+
+ if (result == null && key instanceof Method) {
+ // if that is unsuccessful, we try to
+ // lookup the class/interface itself
+ result = super.get(((Method) key).getDeclaringClass());
+
+ // if that is not specified, we simply extract the
+ // un-qualified classname
+ if (result == null) {
+ String sresult = ((Method)
key).getDeclaringClass().getName();
+ if (sresult.indexOf(".") != -1)
+ sresult =
sresult.substring(sresult.lastIndexOf(".") + 1);
+ result = sresult;
+ }
+ }
+
+ return result;
+ }
+ }
+
+ /**
+ * a tiny helper that does some default mapping of methods to method names
+ */
+
+ public static class DefaultMethodMap extends HashMap {
+
+ /** no entries is the default */
+ public DefaultMethodMap() {
+ super(0);
+ }
+
+ /** returns default interface if no mapping is defined */
+ public Object get(Object key) {
+
+ Object result = super.get(key);
+
+ if (result == null && key instanceof Method) {
+ result = ((Method) key).getName();
+ }
+
+ return result;
+ }
+ }
-}
+}
\ No newline at end of file
1.3 +74 -41
contrib/jboss.net/src/main/org/jboss/net/axis/XMLResourceProvider.java
Index: XMLResourceProvider.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/axis/XMLResourceProvider.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLResourceProvider.java 3 Oct 2001 13:20:31 -0000 1.2
+++ XMLResourceProvider.java 12 Mar 2002 11:04:45 -0000 1.3
@@ -1,57 +1,90 @@
/*
-* JBoss, the OpenSource J2EE webOS
-*
-* Distributable under LGPL license.
-* See terms of license at gnu.org.
-*/
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
-// $Id: XMLResourceProvider.java,v 1.2 2001/10/03 13:20:31 cgjung Exp $
+// $Id: XMLResourceProvider.java,v 1.3 2002/03/12 11:04:45 cgjung Exp $
package org.jboss.net.axis;
-import org.apache.axis.ConfigurationProvider;
import org.apache.axis.AxisEngine;
-import org.apache.axis.utils.Admin;
+import org.apache.axis.ConfigurationException;
+import org.apache.axis.configuration.FileProvider;
import org.apache.axis.utils.XMLUtils;
-import org.xml.sax.InputSource;
-import org.w3c.dom.Document;
import java.net.URL;
-import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.IOException;
/**
- * A ConfigurationProvider that accesses an immutable XML file given as a URL.
+ * A <code>FileProvider</code> that sits on a given URL and
+ * that hosts classloader-aware deployment information.
+ * <br>
+ * <h3>Change History</h3>
+ * <ul>
+ * <li> jung, 09.03.2002: Adopted to axis alpha 3. Mapped to
+ * FileProvider. Created own WsddDocument. </li>
+ * </ul>
* @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
* @created 28. September 2001
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
-public class XMLResourceProvider implements ConfigurationProvider {
-
- /* the resource we host */
- final URL resource;
-
- /**
- * construct a new one sitting on that resource
- */
- public XMLResourceProvider(URL resource) {
- this.resource = resource;
- }
-
- /** configure the given engine by parsing the xml-document */
- public void configureEngine(AxisEngine engine) throws Exception {
- if(resource!=null) {
- InputStreamReader reader=new InputStreamReader(resource.openStream());
- InputSource is = new InputSource(reader);
- Document doc = XMLUtils.newDocument(is);
- Admin.processEngineConfig(doc, engine);
- reader.close();
- }
- }
-
- /** not supported, yet */
- public void writeEngineConfig(AxisEngine engine) throws Exception
- {
- // NOOP
- }
+public class XMLResourceProvider extends FileProvider {
+
+ //
+ // Attributes
+ //
+
+ /** the original resource that we host */
+ final protected URL resource;
+
+ //
+ // Constructors
+ //
+
+ /**
+ * construct a new XmlResourceProvider
+ * @param resource url pointing to the deployment descriptor
+ */
+ public XMLResourceProvider(URL resource) {
+ super((InputStream) null);
+ this.resource = resource;
+ }
+
+ //
+ // Public API
+ //
+
+ /** configures the given AxisEngine with the given descriptor */
+ public void configureEngine(AxisEngine engine) throws ConfigurationException {
+ try {
+ if (myInputStream == null) {
+ myInputStream = resource.openStream();
+ }
+
+ deployment=new Deployment(XMLUtils.newDocument(myInputStream).
+ getDocumentElement());
+
+ deployment.configureEngine(engine);
+ engine.refreshGlobalOptions();
+
+ myInputStream = null;
+ } catch (Exception e) {
+ throw new ConfigurationException(e);
+ }
+ }
+
+ /** returns out special deployment */
+ public Deployment getMyDeployment() {
+ return (Deployment) deployment;
+ }
+
+ /** not supported, yet. Should we use http-push or what? */
+ public void writeEngineConfig(AxisEngine engine) {
+ // NOOP
+ }
+
}
1.3 +13 -47 contrib/jboss.net/src/main/org/jboss/net/axis/Constants.java
1.1 contrib/jboss.net/src/main/org/jboss/net/axis/Deployment.java
Index: Deployment.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
// $Id: Deployment.java,v 1.1 2002/03/12 11:04:45 cgjung Exp $
package org.jboss.net.axis;
// axis config and utils
import org.apache.axis.deployment.wsdd.WSDDDeployment;
import org.apache.axis.deployment.wsdd.WSDDService;
import org.apache.axis.deployment.wsdd.WSDDException;
import org.apache.axis.deployment.DeploymentException;
import org.w3c.dom.Element;
// JAXP
import javax.xml.rpc.namespace.QName;
// java utils
import java.util.Map;
import java.util.Iterator;
/**
* Represents a wsdd deployment descriptor/registry with
* special classloading features.
* <br>
* <h3>Change History</h3>
* <ul>
* </ul>
* @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
* @created 09.03.2002
* @version $Revision: 1.1 $
*/
public class Deployment extends WSDDDeployment {
/**
* holds a map of service q-names to classloaders
* this map must be initialised lazily, since accesses are already done
* in the super-constructor! Newbies!
*/
protected Map service2ClassLoader;
/**
* Constructor for Deployment.
* @param e root element of the deployment document
* @throws WSDDException
*/
public Deployment(Element e) throws WSDDException {
super(e);
}
/** lazily initialises the classloader map */
protected synchronized Map getService2ClassLoader() {
if(service2ClassLoader==null) {
service2ClassLoader=new java.util.HashMap();
}
return service2ClassLoader;
}
/**
* Put a WSDDService into this deployment, replacing any other
* WSDDService which might already be present with the same QName.
*
* @param service a WSDDHandler to insert in this deployment
*/
public void deployService(WSDDService service)
{
service.deployToRegistry(this);
getService2ClassLoader().put(service.getQName(),Thread.currentThread().getContextClassLoader());
}
public void deployToRegistry(WSDDDeployment target)
throws DeploymentException
{
super.deployToRegistry(target);
if(target instanceof Deployment) {
Map targetMap=((Deployment) target).getService2ClassLoader();
Iterator myEntries=getService2ClassLoader().entrySet().iterator();
while(myEntries.hasNext()) {
Map.Entry nextEntry=(Map.Entry) myEntries.next();
targetMap.put(nextEntry.getKey(),nextEntry.getValue());
}
}
}
/**
* retrieve the classloader that loaded the given service
*/
public ClassLoader getClassLoader(QName serviceName) {
return (ClassLoader) getService2ClassLoader().get(serviceName);
}
}
1.1
contrib/jboss.net/src/main/org/jboss/net/axis/ResetClassLoaderHandler.java
Index: ResetClassLoaderHandler.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
// $Id: ResetClassLoaderHandler.java,v 1.1 2002/03/12 11:04:45 cgjung Exp $
package org.jboss.net.axis;
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
/**
* This handler is to restore a previously changed classpath and
* should be put in most cases into a response chain.
* <br>
* <h3>Change notes</h3>
* <ul>
* </ul>
* @created 11.03.2002
* @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
* @version $Revision: 1.1 $
*/
public class ResetClassLoaderHandler extends BasicHandler {
//
// Protected Helpers
//
protected void resetClassLoader(MessageContext msgContext) {
ClassLoader loader = (ClassLoader)
msgContext.getProperty(Constants.OLD_CLASSLOADER_PROPERTY);
if (loader != null) {
msgContext.setProperty(Constants.OLD_CLASSLOADER_PROPERTY, null);
Thread.currentThread().setContextClassLoader(loader);
}
}
//
// API
//
/*
* @see Handler#invoke(MessageContext)
*/
public void invoke(MessageContext msgContext) {
resetClassLoader(msgContext);
}
/*
* @see Handler#onFault(MessageContext)
*/
public void onFault(MessageContext msgContext) {
resetClassLoader(msgContext);
}
}
1.1
contrib/jboss.net/src/main/org/jboss/net/axis/SetClassLoaderHandler.java
Index: SetClassLoaderHandler.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
// $Id: SetClassLoaderHandler.java,v 1.1 2002/03/12 11:04:45 cgjung Exp $
package org.jboss.net.axis;
import org.apache.axis.MessageContext;
import org.apache.axis.EngineConfiguration;
import javax.xml.rpc.namespace.QName;
/**
* This handler is to embed an incoming request into
* the right classloader and should be put into a request
* chain after the service detection handlers. It should be
* complemented by a seperate
* <code>org.jboss.net.axis.ResetClassLoaderHandler</code>
* in the response chain to reinstall the thread association
* in case of success.
* <br>
* <h3>Change notes</h3>
* <ul>
* </ul>
* @created 11.03.2002
* @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
* @version $Revision: 1.1 $
*/
public class SetClassLoaderHandler extends ResetClassLoaderHandler {
//
// API
//
/**
* reroutes the thread associated classloader to
* the one that deployed the corresponding service
* @see Handler#invoke(MessageContext)
*/
public void invoke(MessageContext msgContext) {
EngineConfiguration engineConfig=msgContext.getAxisEngine().getConfig();
if(engineConfig instanceof XMLResourceProvider) {
XMLResourceProvider config=(XMLResourceProvider) engineConfig;
ClassLoader newLoader=config.getMyDeployment().getClassLoader(new
QName(null,
msgContext.getTargetService()));
if(newLoader!=null) {
ClassLoader
currentLoader=Thread.currentThread().getContextClassLoader();
if(!newLoader.equals(currentLoader)) {
msgContext.setProperty(Constants.OLD_CLASSLOADER_PROPERTY,currentLoader);
Thread.currentThread().setContextClassLoader(newLoader);
}
}
}
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development