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 Tom Jordahl <to...@macromedia.com> on 2002/08/02 16:04:26 UTC

RE: cvs commit: xml-axis/java/src/org/apache/axis/wsdl/fromJava E mitter.java

Sorry about that.  Thanks for fixing it Glen.
 
--
Tom Jordahl
Macromedia
 
-----Original Message-----
From: butek@us.ibm.com [mailto:butek@us.ibm.com]
Sent: Thursday, August 01, 2002 3:46 PM
To: axis-dev@xml.apache.org
Subject: Re: cvs commit: xml-axis/java/src/org/apache/axis/wsdl/fromJava Emitter.java


Aargh! With this commit I get:

[javac] C:\xml-axis\java\src\org\apache\axis\providers\java\EJBProvider.java:191: getServiceClass(org.apache.axis.MessageContext,java.lang.String) in org.apache.axis.providers.java.EJBProvider cannot override getServiceClass(org.apache.axis.MessageContext,java.lang.String) in org.apache.axis.providers.java.JavaProvider; overridden method does not throw java.lang.Exception
[javac] protected Class getServiceClass(MessageContext msgContext, String beanJndiName)
[javac] ^


Russell Butek
butek@us.ibm.com



Please respond to axis-dev@xml.apache.org 


To: xml-axis-cvs@apache.org
cc: 
Subject: cvs commit: xml-axis/java/src/org/apache/axis/wsdl/fromJava Emitter.java



tomj        2002/08/01 11:35:42



	Modified:    java/src/org/apache/axis/handlers/soap SOAPService.java
java/src/org/apache/axis/providers JWSProvider.java 

	ComProvider.java BSFProvider.java
BasicProvider.java

	java/src/org/apache/axis/providers/java JavaProvider.java
java/src/org/apache/axis/wsdl/fromJava Emitter.java

	Log:
Fix problems with the EJBProvider (bug 10864).
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10864 <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10864> 

The getInitializedServiceDesc() function in SOAPService was hard coded to
check the "className" parameter when in fact it should have using the
provider interfaces (which can be overridden) to get the implementation class
of the service for the ServiceDesc.

Added an abstract interface to the BasicProvider class for
getServiceDescription(), which will fill in the implementation class with the
right info.

Revision  Changes    Path
1.74      +11 -35    xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java

Index: SOAPService.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- SOAPService.java 10 Jul 2002 19:32:13 -0000 1.73
+++ SOAPService.java 1 Aug 2002 18:35:41 -0000 1.74
@@ -68,6 +68,7 @@
import org.apache.axis.encoding.DefaultTypeMappingImpl;
import org.apache.axis.enum.Style;
import org.apache.axis.providers.java.JavaProvider;
+import org.apache.axis.providers.BasicProvider;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPHeaderElement;
@@ -308,45 +309,20 @@
return serviceDescription; 

	}


	+    /**
+     * Returns a service description with the implementation class filled in.
+     *
+     * Syncronized to prevent simutaneous modification of serviceDescription.
+     */ 

	public synchronized ServiceDesc getInitializedServiceDesc(MessageContext msgContext) throws AxisFault {
if (serviceDescription.getImplClass() == null) {

	-            String clsName = (String)getOption(JavaProvider.OPTION_CLASSNAME);
-
-            if (clsName != null) {
-                ClassLoader cl = null;
-                if (msgContext == null) {
-                    cl = Thread.currentThread().getContextClassLoader();
-                } else {
-                    cl = msgContext.getClassLoader();
-                }
-                if (engine != null) {
-                    ClassCache cache     = engine.getClassCache();
-                    JavaClass       jc   = null;
-                    try {
-                        jc = cache.lookup(clsName, cl);
-                        serviceDescription.setImplClass(jc.getJavaClass());
-                    } catch (ClassNotFoundException e) {
-                        log.error(JavaUtils.getMessage("exception00"), e);
-                        throw new AxisFault(JavaUtils.getMessage("noClassForService00", clsName), e);
-                    }
-                } else {
-                    try {
-                        Class cls = ClassUtils.forName(clsName,true,cl);
-                        serviceDescription.setImplClass(cls);
-                    } catch (ClassNotFoundException e) {
-                        log.error(JavaUtils.getMessage("exception00"), e);
-                        throw new AxisFault(JavaUtils.getMessage("noClassForService00", clsName), e);
-                    }
-                }
-                TypeMapping tm;
-                if (msgContext == null) {
-                    tm = DefaultTypeMappingImpl.getSingleton();
-                } else {
-                    tm = msgContext.getTypeMapping();
-                }
-                serviceDescription.setTypeMapping(tm);
+            // Fill in the service class from the provider
+            if (pivotHandler instanceof BasicProvider) {
+                serviceDescription =
+                     ((BasicProvider)pivotHandler).getServiceDesc(msgContext, serviceDescription); 

	}
}

	+
return serviceDescription; 

	}





	1.4       +7 -0      xml-axis/java/src/org/apache/axis/providers/JWSProvider.java

Index: JWSProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/JWSProvider.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JWSProvider.java 10 Jan 2002 20:01:00 -0000 1.3
+++ JWSProvider.java 1 Aug 2002 18:35:42 -0000 1.4
@@ -56,9 +56,16 @@
package org.apache.axis.providers;

import org.apache.axis.MessageContext;
+import org.apache.axis.AxisFault;
+import org.apache.axis.description.ServiceDesc;

public class JWSProvider extends BasicProvider {

public void invoke(MessageContext msgContext) {
+    }
+
+    public ServiceDesc getServiceDesc(MessageContext msgContext, ServiceDesc serviceDesc)
+            throws AxisFault {
+        return serviceDesc;
}
}



1.4       +7 -1      xml-axis/java/src/org/apache/axis/providers/ComProvider.java

Index: ComProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/ComProvider.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ComProvider.java 10 Jan 2002 20:01:00 -0000 1.3
+++ ComProvider.java 1 Aug 2002 18:35:42 -0000 1.4
@@ -56,6 +56,8 @@
package org.apache.axis.providers;

import org.apache.axis.MessageContext;
+import org.apache.axis.AxisFault;
+import org.apache.axis.description.ServiceDesc;

public class ComProvider extends BasicProvider {

@@ -65,5 +67,9 @@


	public void invoke(MessageContext msgContext) {
}

	-
+
+    public ServiceDesc getServiceDesc(MessageContext msgContext, ServiceDesc serviceDesc)
+            throws AxisFault {
+        return serviceDesc;
+    }
}



1.4       +7 -0      xml-axis/java/src/org/apache/axis/providers/BSFProvider.java

Index: BSFProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/BSFProvider.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BSFProvider.java 10 Jan 2002 20:01:00 -0000 1.3
+++ BSFProvider.java 1 Aug 2002 18:35:42 -0000 1.4
@@ -56,6 +56,8 @@
package org.apache.axis.providers;

import org.apache.axis.MessageContext;
+import org.apache.axis.AxisFault;
+import org.apache.axis.description.ServiceDesc;

public class BSFProvider extends BasicProvider {

@@ -65,5 +67,10 @@


	public void invoke(MessageContext msgContext) {
System.out.println(getOption("Script"));

	+    }
+
+    public ServiceDesc getServiceDesc(MessageContext msgContext, ServiceDesc serviceDesc)
+            throws AxisFault {
+        return serviceDesc;
}
}



1.10      +10 -0     xml-axis/java/src/org/apache/axis/providers/BasicProvider.java

Index: BasicProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/BasicProvider.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- BasicProvider.java 11 Jun 2002 14:54:00 -0000 1.9
+++ BasicProvider.java 1 Aug 2002 18:35:42 -0000 1.10
@@ -56,6 +56,9 @@
package org.apache.axis.providers;

import org.apache.axis.handlers.BasicHandler;
+import org.apache.axis.MessageContext;
+import org.apache.axis.AxisFault;
+import org.apache.axis.description.ServiceDesc;

import javax.xml.namespace.QName;

@@ -67,6 +70,13 @@
* provider.  I'm not exactly married to this though.
*/
public abstract class BasicProvider extends BasicHandler {
+
+    /**
+     * This method returns a ServiceDesc that contains the correct
+     * implimentation class.
+     */
+    public abstract ServiceDesc getServiceDesc(MessageContext msgContext, ServiceDesc serviceDesc)
+            throws AxisFault;


	public void addOperation(String name, QName qname) {
Hashtable operations = (Hashtable)getOption("Operations");




	1.69      +79 -5     xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java

Index: JavaProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- JavaProvider.java 24 Jul 2002 18:01:05 -0000 1.68
+++ JavaProvider.java 1 Aug 2002 18:35:42 -0000 1.69
@@ -64,10 +64,12 @@
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.providers.BasicProvider;
import org.apache.axis.utils.JavaUtils;
+import org.apache.axis.utils.ClassUtils;
import org.apache.axis.utils.cache.JavaClass;
import org.apache.axis.utils.cache.ClassCache;
import org.apache.axis.wsdl.fromJava.Emitter;
import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.encoding.DefaultTypeMappingImpl;
import org.apache.axis.enum.Style;
import org.apache.axis.enum.Scope;
import org.apache.axis.Constants;
@@ -504,11 +506,39 @@
* Returns the Class info about the service class.
*/
protected Class getServiceClass(MessageContext msgContext, String clsName)
-            throws Exception {
-        ClassLoader cl     = msgContext.getClassLoader();
-        ClassCache cache   = msgContext.getAxisEngine().getClassCache();
-        JavaClass  jc      = cache.lookup(clsName, cl);
-        return jc.getJavaClass();
+            throws AxisFault {
+        AxisEngine engine = null;
+        ClassLoader cl = null;
+        Class serviceClass = null;
+
+        // If we have a message context, use that to get classloader and engine
+        // otherwise get the current threads classloader
+        if (msgContext == null) {
+            cl = Thread.currentThread().getContextClassLoader();
+        } else {
+            cl = msgContext.getClassLoader();
+            engine = msgContext.getAxisEngine();
+        }
+        // If we have an engine, use its class cache
+        if (engine != null) {
+            ClassCache cache     = engine.getClassCache();
+            try {
+                JavaClass jc = cache.lookup(clsName, cl);
+                serviceClass = jc.getJavaClass();
+            } catch (ClassNotFoundException e) {
+                log.error(JavaUtils.getMessage("exception00"), e);
+                throw new AxisFault(JavaUtils.getMessage("noClassForService00", clsName), e);
+            }
+        } else {
+            // if no engine, we don't have a cache, use Class.forName instead.
+            try {
+                serviceClass = ClassUtils.forName(clsName, true, cl);
+            } catch (ClassNotFoundException e) {
+                log.error(JavaUtils.getMessage("exception00"), e);
+                throw new AxisFault(JavaUtils.getMessage("noClassForService00", clsName), e);
+            }
+        }
+        return serviceClass; 

	}


	/**
@@ -543,4 +573,48 @@


	return null;
}

	+
+    /**
+     * Fill in a service description with the correct impl class
+     * and typemapping set.  This uses methods that can be overridden by
+     * other providers (like the EJBProvider) to get the class from the
+     * right place.
+     *
+     * @param msgContext message context
+     * @param serviceDescription service description to be updated
+     * @return updated service description
+     */
+    public ServiceDesc getServiceDesc(MessageContext msgContext, ServiceDesc serviceDescription)
+            throws AxisFault
+    {
+        // Set up the Implimentation class for the service
+
+        String clsName = null;
+        if (msgContext != null) {
+            SOAPService service = msgContext.getService();
+            clsName = getServiceClassName(service);
+        } else {
+            // no service, try the local options
+            clsName = (String) getOption(getServiceClassNameOptionName());
+        }
+
+        if (clsName != null) {
+            Class cls = getServiceClass(msgContext, clsName);
+            serviceDescription.setImplClass(cls);
+        }
+
+        // Set up the type mapping for the service
+        TypeMapping tm;
+        if (msgContext == null) {
+            tm = DefaultTypeMappingImpl.getSingleton();
+        } else {
+            tm = msgContext.getTypeMapping();
+        }
+        serviceDescription.setTypeMapping(tm);
+
+        // return the updated ServiceDesc
+        return serviceDescription;
+    }
+
+
}



1.54      +6 -0      xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java

Index: Emitter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- Emitter.java 23 Jul 2002 14:02:57 -0000 1.53
+++ Emitter.java 1 Aug 2002 18:35:42 -0000 1.54
@@ -395,6 +395,12 @@ 

	serviceDesc.setTypeMapping(defaultTM);
}

	}
+
+        // If the provided service description does NOT have the implementaion
+        // class and we do, make sure to fill it in.
+        if (serviceDesc.getImplClass() == null && cls != null) {
+            serviceDesc.setImplClass(cls);
+        }


	serviceDesc.setStopClasses(stopClasses);
serviceDesc.setAllowedMethods(allowedMethods);