You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by du...@apache.org on 2001/05/02 16:37:23 UTC
cvs commit: xml-axis/java/src/org/apache/axis/utils Admin.java AxisClassLoader.java
dug 01/05/02 07:37:22
Modified: java/src/org/apache/axis Constants.java MessageContext.java
java/src/org/apache/axis/handlers JWSProcessor.java
MsgDispatchHandler.java RPCDispatchHandler.java
java/src/org/apache/axis/server AxisServer.java
java/src/org/apache/axis/utils Admin.java
AxisClassLoader.java
Log:
Create a new classloader per jws file - and reuse 'em
Revision Changes Path
1.10 +1 -0 xml-axis/java/src/org/apache/axis/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Constants.java 2001/04/28 23:27:19 1.9
+++ Constants.java 2001/05/02 14:37:08 1.10
@@ -61,6 +61,7 @@
// not all Engines will have notion of registries but defining these
// here should allow people to ask if they exist)
//////////////////////////////////////////////////////////////////////////
+ public static String AXIS_ENGINE = "AxisEngine" ;
public static String HANDLER_REGISTRY = "HandlerRegistry" ;
public static String SERVICE_REGISTRY = "ServiceRegistry" ;
1.14 +22 -1 xml-axis/java/src/org/apache/axis/MessageContext.java
Index: MessageContext.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- MessageContext.java 2001/03/08 11:56:05 1.13
+++ MessageContext.java 2001/05/02 14:37:09 1.14
@@ -57,6 +57,7 @@
import java.util.* ;
import org.apache.axis.* ;
+import org.apache.axis.utils.AxisClassLoader ;
/**
* Some more general docs will go here.
@@ -98,9 +99,14 @@
* That unique key/name that the next router/dispatch handler should use
* to determine what to do next.
*/
- private String targetService ;
+ private String targetService ;
/**
+ * The default classloader that this service should use
+ */
+ private AxisClassLoader classLoader ;
+
+ /**
*
*/
private Hashtable bag ;
@@ -136,6 +142,21 @@
public void setResponseMessage(Message inMsg) {
outMessage = inMsg ;
};
+
+ public AxisClassLoader getClassLoader() {
+ if ( classLoader == null )
+ classLoader = AxisClassLoader.getClassLoader(null);
+ return( classLoader );
+ }
+
+ public AxisClassLoader getClassLoader(String name) {
+ if ( name == null ) return( getClassLoader() );
+ return( AxisClassLoader.getClassLoader(name) );
+ }
+
+ public void setClassLoader(AxisClassLoader cl ) {
+ classLoader = cl ;
+ }
public String getTargetService() {
return( targetService );
1.7 +13 -10 xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java
Index: JWSProcessor.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JWSProcessor.java 2001/04/22 01:08:55 1.6
+++ JWSProcessor.java 2001/05/02 14:37:14 1.7
@@ -58,8 +58,8 @@
import org.apache.axis.* ;
import org.apache.axis.utils.Debug ;
-import org.apache.axis.utils.AxisClassLoader ;
import org.apache.axis.utils.XMLUtils ;
+import org.apache.axis.utils.AxisClassLoader ;
import sun.tools.javac.Main;
import org.w3c.dom.* ;
@@ -97,6 +97,12 @@
File f1 = new File( cFile );
File f2 = new File( jwsFile );
+ /* Get the class */
+ /*****************/
+ String clsName = f2.getName();
+ clsName = clsName.substring( 0, clsName.length()-4 );
+ Debug.Print( 2, "ClsName: " + clsName );
+
/* Check to see if we need to recompile */
/****************************************/
if ( !f1.exists() || f2.lastModified() > f1.lastModified() ) {
@@ -135,7 +141,6 @@
/**************************************************************/
(new File(jFile)).delete();
- // if ( proc.exitValue() != 0 ) {
if ( !result ) {
/* Delete the *class file - sometimes it gets created even */
/* when there are errors - so erase it so it doesn't */
@@ -161,15 +166,13 @@
null, new Element[] { root } );
}
(new File(errFile)).delete();
- }
-
- /* Load the class */
- /******************/
- String clsName = f2.getName();
- clsName = clsName.substring( 0, clsName.length()-4 );
- Debug.Print( 2, "ClsName: " + clsName );
- (new AxisClassLoader()).registerClass( clsName, cFile );
+ AxisClassLoader.removeClassLoader( clsName );
+ }
+ AxisClassLoader cl = msgContext.getClassLoader( clsName );
+ if ( !cl.isClassRegistered(clsName) )
+ cl.registerClass( clsName, cFile );
+ msgContext.setClassLoader( cl );
/* Create a new RPCDispatchHandler - this will be the "service" */
/* that we invoke. */
1.20 +1 -1 xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java
Index: MsgDispatchHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- MsgDispatchHandler.java 2001/04/28 13:52:15 1.19
+++ MsgDispatchHandler.java 2001/05/02 14:37:14 1.20
@@ -97,7 +97,7 @@
Debug.Print( 2, "MethodName: " + methodName );
try {
- AxisClassLoader cl = new AxisClassLoader();
+ AxisClassLoader cl = msgContext.getClassLoader();
Class cls = cl.loadClass(clsName);
Object obj = cls.newInstance();
Class[] argClasses = new Class[2];
1.30 +1 -3 xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java
Index: RPCDispatchHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- RPCDispatchHandler.java 2001/04/30 23:50:06 1.29
+++ RPCDispatchHandler.java 2001/05/02 14:37:15 1.30
@@ -66,9 +66,6 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public class RPCDispatchHandler extends BasicHandler {
-
- private static AxisClassLoader cl = new AxisClassLoader();
-
private static final boolean DEBUG_LOG = false;
public void invoke(MessageContext msgContext) throws AxisFault {
@@ -89,6 +86,7 @@
/* SOAPBody as an RPCBody and process it accordingly. */
/*************************************************************/
int i ;
+ AxisClassLoader cl = msgContext.getClassLoader();
Class cls = cl.loadClass(clsName);
Object obj = cls.newInstance();
Message inMsg = msgContext.getRequestMessage();
1.6 +2 -1 xml-axis/java/src/org/apache/axis/server/AxisServer.java
Index: AxisServer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AxisServer.java 2001/05/01 15:42:38 1.5
+++ AxisServer.java 2001/05/02 14:37:18 1.6
@@ -127,6 +127,7 @@
HandlerRegistry sr =
(HandlerRegistry) getOption(Constants.SERVICE_REGISTRY);
+ msgContext.setProperty(Constants.AXIS_ENGINE, this );
msgContext.setProperty(Constants.HANDLER_REGISTRY, hr);
msgContext.setProperty(Constants.SERVICE_REGISTRY, sr);
@@ -134,7 +135,7 @@
hName = msgContext.getStrProp( MessageContext.ENGINE_HANDLER );
if ( hName != null ) {
if ( hr == null || (h = hr.find(hName)) == null ) {
- ClassLoader cl = new AxisClassLoader();
+ AxisClassLoader cl = msgContext.getClassLoader();
try {
Debug.Print( 2, "Trying to load class: " + hName );
Class cls = cl.loadClass( hName );
1.29 +2 -2 xml-axis/java/src/org/apache/axis/utils/Admin.java
Index: Admin.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Admin.java 2001/05/01 15:42:40 1.28
+++ Admin.java 2001/05/02 14:37:20 1.29
@@ -124,8 +124,8 @@
Document doc = null ;
try {
init();
- ClassLoader cl = new AxisClassLoader();
- String action = root.getLocalName();
+ AxisClassLoader cl = AxisClassLoader.getClassLoader();
+ String action = root.getLocalName();
if ( !action.equals("deploy") && !action.equals("undeploy") &&
!action.equals("list") )
1.5 +24 -1 xml-axis/java/src/org/apache/axis/utils/AxisClassLoader.java
Index: AxisClassLoader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/AxisClassLoader.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AxisClassLoader.java 2001/04/30 23:50:08 1.4
+++ AxisClassLoader.java 2001/05/02 14:37:21 1.5
@@ -68,12 +68,31 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public class AxisClassLoader extends ClassLoader {
- static Hashtable list = new Hashtable() ;
+ static Hashtable list = new Hashtable() ;
+ static Hashtable classLoaders = new Hashtable();
public AxisClassLoader() {
super();
}
+ static public AxisClassLoader getClassLoader() {
+ return( getClassLoader(null) );
+ }
+
+ static public AxisClassLoader getClassLoader(String name) {
+ AxisClassLoader cl = null ;
+ if ( name == null ) name = "<default_class_loader>" ;
+ cl = (AxisClassLoader) classLoaders.get( name );
+ if ( cl == null )
+ classLoaders.put( name, cl = new AxisClassLoader() );
+ return( cl );
+ }
+
+ static public void removeClassLoader(String name) {
+ if ( name != null )
+ classLoaders.remove( name );
+ }
+
public void registerClass( String name, String classFile )
throws FileNotFoundException, IOException
{
@@ -107,6 +126,10 @@
/* Deregister the passed in className */
/**************************************/
list.remove( name);
+ }
+
+ public boolean isClassRegistered( String name ) {
+ return( list != null && list.get(name) != null );
}
public Class loadClass(String name) throws ClassNotFoundException {