gdaniels 02/02/13 12:55:42
Modified: java/src/org/apache/axis AxisServiceConfig.java
java/src/org/apache/axis/providers/java JavaProvider.java
java/test/functional AltStockQuoteService.jws
Added: java/src/org/apache/axis AxisServiceConfigImpl.java
Log:
Fix AxisServiceConfig to be implemented statically.
Now the JavaProvider looks for a static method called
"getAxisServiceConfig()" on the classes and objects it deals with. This
means we can provide metadata (just allowedMethods for now, more
later) for WSDL generation without needing an instance of the object
to be constructed.
Revision Changes Path
1.5 +1 -1 xml-axis/java/src/org/apache/axis/AxisServiceConfig.java
Index: AxisServiceConfig.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisServiceConfig.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AxisServiceConfig.java 30 Oct 2001 16:46:34 -0000 1.4
+++ AxisServiceConfig.java 13 Feb 2002 20:55:42 -0000 1.5
@@ -70,5 +70,5 @@
* @return a space-delimited list of method names which may be called
* via SOAP.
*/
- public String getMethods();
+ public String getAllowedMethods();
}
1.1 xml-axis/java/src/org/apache/axis/AxisServiceConfigImpl.java
Index: AxisServiceConfigImpl.java
===================================================================
/*
* Created by IntelliJ IDEA.
* User: Glen
* Date: Feb 13, 2002
* Time: 3:43:06 PM
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package org.apache.axis;
public class AxisServiceConfigImpl implements AxisServiceConfig {
private String methods;
/**
* Set the allowed method names.
*/
public void setAllowedMethods(String methods)
{
this.methods = methods;
}
/** Get the allowed method names.
*
* @return a space-delimited list of method names which may be called
* via SOAP.
*/
public String getAllowedMethods() {
return methods;
}
}
1.37 +47 -12
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.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- JavaProvider.java 12 Feb 2002 21:28:38 -0000 1.36
+++ JavaProvider.java 13 Feb 2002 20:55:42 -0000 1.37
@@ -72,6 +72,10 @@
import org.apache.log4j.Category;
import org.w3c.dom.Document;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.InvocationTargetException;
+
/**
* Base class for Java dispatching. Fetches various fields out of envelope,
* looks up service object (possibly using session state), and delegates
@@ -242,8 +246,9 @@
/** If the class knows what it should be exporting,
* respect its wishes.
*/
- if (obj instanceof AxisServiceConfig) {
- allowedMethods = ((AxisServiceConfig)obj).getMethods();
+ AxisServiceConfig axisConfig = getConfiguration(obj);
+ if (axisConfig != null) {
+ allowedMethods = axisConfig.getAllowedMethods();
}
processMessage(msgContext, clsName, allowedMethods, reqEnv,
@@ -290,22 +295,20 @@
if (allowedMethods.equals("*"))
allowedMethods = null;
- /** If the class knows what it should be exporting,
- * respect its wishes.
- * XXX - this system (AxisSeriviceConfig interface) is going to be
- * removed per the TODO list, so it wont work for WSDL right now
- * [EMAIL PROTECTED]
- */
-// if (obj instanceof AxisServiceConfig) {
-// allowedMethods = ((AxisServiceConfig)obj).getMethods();
-// }
-
try {
String url = msgContext.getStrProp(MessageContext.TRANS_URL);
String urn = (String)msgContext.getTargetService();
String description = "Service";
Class cls = getServiceClass(msgContext, getServiceClassName(service));
+
+ // If the class knows what it should be exporting, respect it's
+ // wishes.
+ AxisServiceConfig axisConfig = getConfiguration(cls);
+ if (axisConfig != null) {
+ allowedMethods = axisConfig.getAllowedMethods();
+ }
+
Emitter emitter = new Emitter();
emitter.setClsSmart(cls,url);
emitter.setAllowedMethods(allowedMethods);
@@ -386,4 +389,36 @@
return obj.getClass();
}
+ /**
+ * For a given object or class, if there is a static method called
+ * "getAxisServiceConfig()", we call it and return the value as an
+ * AxisServiceConfig object. This allows us to obtain metadata about
+ * a class' configuration without instantiating an object of that class.
+ *
+ * @param an object, which may be a Class
+ */
+ public AxisServiceConfig getConfiguration(Object obj)
+ {
+ Class cls;
+ if (obj instanceof Class) {
+ cls = (Class)obj;
+ } else {
+ cls = obj.getClass();
+ }
+
+ try {
+ Method method =
+ cls.getDeclaredMethod("getAxisServiceConfig", new Class [] {});
+ if (method != null && Modifier.isStatic(method.getModifiers())) {
+ return (AxisServiceConfig)method.invoke(null, null);
+ }
+ } catch (NoSuchMethodException e) {
+ } catch (SecurityException e) {
+ } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (InvocationTargetException e) {
+ }
+
+ return null;
+ }
}
1.3 +12 -4 xml-axis/java/test/functional/AltStockQuoteService.jws
Index: AltStockQuoteService.jws
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/AltStockQuoteService.jws,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AltStockQuoteService.jws 5 Sep 2001 17:23:01 -0000 1.2
+++ AltStockQuoteService.jws 13 Feb 2002 20:55:42 -0000 1.3
@@ -59,6 +59,7 @@
import org.w3c.dom.* ;
import org.apache.axis.AxisServiceConfig;
+import org.apache.axis.AxisServiceConfigImpl;
import org.apache.axis.utils.XMLUtils ;
@@ -69,11 +70,18 @@
* @author Sanjiva Weerawarana ([EMAIL PROTECTED])
* @author Doug Davis ([EMAIL PROTECTED])
*/
-public class AltStockQuoteService implements AxisServiceConfig {
- public String getMethods() {
- return "echo";
+public class AltStockQuoteService {
+ private static AxisServiceConfigImpl myConfig;
+
+ static {
+ myConfig = new AxisServiceConfigImpl();
+ myConfig.setAllowedMethods("echo");
+ }
+
+ public static AxisServiceConfig getAxisServiceConfig() {
+ return myConfig;
}
-
+
public String echo(String s)
{
return s;