You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2004/12/02 18:20:14 UTC
svn commit: r109508 - in incubator/beehive/trunk/wsm: drt/tests/org/apache/beehive/wsm/axis src/runtime/org/apache/beehive/wsm/axis src/runtime/org/apache/beehive/wsm/axis/util
Author: mmerz
Date: Thu Dec 2 09:20:11 2004
New Revision: 109508
URL: http://svn.apache.org/viewcvs?view=rev&rev=109508
Log:
Fix for BEEHIVE-95: OUT and INOUT parameters work with the @WebParam annotation (for Holder classes see JAX-RPC: javax.xml.rpc.holders package).
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/AxisTypeMappingUtil.java
Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java?view=diff&rev=109508&p1=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java&r1=109507&p2=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java&r2=109508
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java (original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/axis/AxisHookTest.java Thu Dec 2 09:20:11 2004
@@ -56,7 +56,7 @@
public static final String WM_ONEWAY = "Oneway";
public static final String WM_TWOWAYPARAM = "number";
public static final String WM_ONEWAYPARAM = "text";
-
+
ServiceDesc sd;
public void setUp() throws Exception {
@@ -101,7 +101,7 @@
assertNotNull(param);
if (param != null) {
assertEquals(WM_TWOWAYPARAM, param.getName());
- assertEquals(Integer.TYPE, param.getJavaType());
+ assertEquals(javax.xml.rpc.holders.IntHolder.class, param.getJavaType());
assertEquals(ParameterDesc.INOUT, param.getMode());
}
}
@@ -119,7 +119,7 @@
assertNotNull(param);
if (param != null) {
assertEquals(WM_ONEWAYPARAM, param.getName());
- assertEquals(String.class, param.getJavaType());
+ assertEquals(Boolean.class, param.getJavaType());
assertEquals(ParameterDesc.IN, param.getMode());
}
}
@@ -127,7 +127,7 @@
protected Jsr181TypeMetadata makeFakeMetadata() throws Exception {
Jsr181TypeMetadata wstm =
- new Jsr181TypeMetadataImpl(WS_CLASS.getName());
+ new Jsr181TypeMetadataImpl(WS_CLASS.getName());
wstm.setWsName(WS_NAME);
/*
* NOTE jcolwell@bea.com 2004-Sep-13 --
@@ -143,29 +143,29 @@
protected Jsr181MethodMetadata makeFakeOnewayMethod() {
Jsr181MethodMetadata wsmm =
- new Jsr181MethodMetadataImpl(WM_JAVAONEWAYMETHODNAME, Void.TYPE);
+ new Jsr181MethodMetadataImpl(WM_JAVAONEWAYMETHODNAME, Void.TYPE);
wsmm.setWmOperationName(WM_ONEWAY + WM_OPERATION);
wsmm.setWmAction(WM_ONEWAY + WM_ACTION);
wsmm.setOneWay(true);
Jsr181ParameterMetadata wspm = new Jsr181ParameterMetadataImpl();
- wspm.setJavaType(String.class);
wspm.setWpName(WM_ONEWAYPARAM);
wspm.setWpMode(WebParam.Mode.IN);
+ wspm.setJavaType(Boolean.class);
wsmm.addParam(wspm);
return wsmm;
}
protected Jsr181MethodMetadata makeFakeMethod() {
Jsr181MethodMetadata wsmm =
- new Jsr181MethodMetadataImpl(WM_JAVAMETHODNAME, String.class);
+ new Jsr181MethodMetadataImpl(WM_JAVAMETHODNAME, String.class);
wsmm.setWmOperationName(WM_OPERATION);
wsmm.setWmAction(WM_ACTION);
wsmm.setWrName(WM_RESULT);
wsmm.setOneWay(false);
Jsr181ParameterMetadata wspm = new Jsr181ParameterMetadataImpl();
- wspm.setJavaType(Integer.TYPE);
wspm.setWpName(WM_TWOWAYPARAM);
wspm.setWpMode(WebParam.Mode.INOUT);
+ wspm.setJavaType(javax.xml.rpc.holders.IntHolder.class);
wsmm.addParam(wspm);
return wsmm;
}
@@ -180,12 +180,12 @@
public static class FakeWebService {
- public String fakeWebMethod(int num) {
- return "You're number " + Integer.toString(num) + '!';
+ public String fakeWebMethod(javax.xml.rpc.holders.IntHolder num) {
+ return "You're number " + num.value + '!';
}
- public void fakeOneWayWebMethod(String text) {
+ public void fakeOneWayWebMethod(Boolean b) {
//do nothing
}
}
-}
+}
\ No newline at end of file
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java?view=diff&rev=109508&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java&r1=109507&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java&r2=109508
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java Thu Dec 2 09:20:11 2004
@@ -69,89 +69,113 @@
*/
public class AxisHook {
- public static ServiceDesc createServiceDesc(Jsr181TypeMetadata wsm,
- ClassLoader cl)
- throws ClassNotFoundException,
- NoSuchMethodException,
- InvalidTypeMappingException {
+ public static ServiceDesc createServiceDesc(
+ Jsr181TypeMetadata wsm,
+ ClassLoader cl
+ )
+ throws
+ ClassNotFoundException,
+ NoSuchMethodException,
+ InvalidTypeMappingException
+ {
JavaServiceDesc sd = new JavaServiceDesc();
- if (cl == null) {
+ if (null == cl)
+ {
/*
* NOTE jcolwell@bea.com 2004-Aug-30 -- if no classloader
* was provided, use the one that loaded this Class
*/
cl = AxisHook.class.getClassLoader();
}
- Class serviceClass = cl.loadClass(wsm.getServiceImplementationBean());
- String portType = wsm.getWsName();
- sd.setName(portType);
+ final Class serviceClass = cl.loadClass(wsm.getServiceImplementationBean());
+ sd.setName(wsm.getWsName());
sd.setImplClass(serviceClass);
- String targetNamespace = wsm.getWsTargetNamespace();
- sd.setDefaultNamespace(targetNamespace);
- SOAPBindingInfo sbi = wsm.getSoapBinding();
- configureSoapBinding(sd, sbi);
- Collection<Jsr181MethodMetadata> methods = wsm.getMethods();
+ sd.setDefaultNamespace(wsm.getWsTargetNamespace());
+ configureSoapBinding(sd, wsm.getSoapBinding());
List<String> allowedMethods = new ArrayList<String>();
- for (Jsr181MethodMetadata meth : methods) {
+ for (Jsr181MethodMetadata meth : wsm.getMethods())
+ {
String operationName = meth.getWmOperationName();
- if (operationName != null && operationName.length() > 0) {
+ if (null != operationName && 0 < operationName.length())
+ {
+ allowedMethods.add(operationName);
OperationDesc od = new OperationDesc();
- String javaMethodName = meth.getJavaMethodName();
od.setElementQName(new QName(operationName));
od.setName(operationName);
- allowedMethods.add(operationName);
od.setSoapAction(meth.getWmAction());
- if (meth.isOneWay()) {
+ if (meth.isOneWay())
+ {
od.setMep(OperationType.ONE_WAY);
- } else {
- od.setReturnQName(new QName(meth.getWrTargetNamespace(),
- meth.getWrName()));
- Class returnType = meth.getJavaReturnType();
- QName type = configureTypeMapping(sd, returnType);
- od.setReturnType(type);
+ }
+ else
+ {
+ od.setReturnQName(
+ new QName(meth.getWrTargetNamespace(), meth.getWrName())
+ );
+ final Class returnType = meth.getJavaReturnType();
+ od.setReturnType(configureTypeMapping(sd, returnType));
od.setReturnClass(returnType);
- //od.setReturnHeader(
}
- List<Jsr181ParameterMetadata> parameters = meth.getParams();
List<Class> paramClasses = new ArrayList<Class>();
- for (Jsr181ParameterMetadata param : parameters) {
+ for (Jsr181ParameterMetadata param : meth.getParams())
+ {
ParameterDesc pd = new ParameterDesc();
- pd.setQName(new QName(param.getWpTargetNamespace(),
- param.getWpName()));
- Class paramType = param.getJavaType();
- configureTypeMapping(sd, paramType);
- pd.setJavaType(paramType);
+ final Class paramType = param.getJavaType();
paramClasses.add(paramType);
- WebParam.Mode mo = param.getWpMode();
+ final QName dummy = configureTypeMapping(sd, paramType);
+
+ // set QName
+ pd.setQName(
+ new QName(param.getWpTargetNamespace(),
+ param.getWpName())
+ );
+
+ // set Mode
+ final boolean header = param.isWpHeader();
+ final WebParam.Mode mo = param.getWpMode();
switch (mo) {
+ case IN:
+ pd.setMode(ParameterDesc.IN);
+ pd.setInHeader(header);
+ pd.setOutHeader(false);
+ break;
case OUT:
pd.setMode(ParameterDesc.OUT);
pd.setInHeader(false);
- pd.setOutHeader(param.isWpHeader());
+ pd.setOutHeader(header);
break;
case INOUT:
pd.setMode(ParameterDesc.INOUT);
- boolean header = param.isWpHeader();
pd.setInHeader(header);
pd.setOutHeader(header);
break;
- case IN:
default:
- pd.setMode(ParameterDesc.IN);
- pd.setInHeader(param.isWpHeader());
- pd.setOutHeader(false);
+ throw new IllegalArgumentException("Illegal value for WebParam.Mode: " + mo);
}
+
+ // set JavaType
+ pd.setJavaType(paramType);
+
od.addParameter(pd);
}
- Method javaMethod = serviceClass
- .getMethod(meth.getJavaMethodName(),
- paramClasses.toArray(new Class[paramClasses.size()]));
- for (Class thrown : javaMethod.getExceptionTypes()) {
+
+ Method javaMethod =
+ serviceClass.getMethod(
+ meth.getJavaMethodName(),
+ paramClasses.toArray(new Class[paramClasses.size()])
+ );
+
+ // set Exceptions
+ for (Class thrown : javaMethod.getExceptionTypes())
+ {
FaultDesc fd = new FaultDesc();
fd.setClassName(thrown.getName());
od.addFault(fd);
}
+
+ // set Method
od.setMethod(javaMethod);
+
sd.addOperationDesc(od);
}
}
@@ -159,36 +183,48 @@
return sd;
}
- private static boolean isActivationEnabled() {
+ private static boolean isActivationEnabled()
+ {
return null != getDataHandlerClass() && null != getMultipartClass();
}
- private static Class getDataHandlerClass() {
- try {
- return AxisHook.class.getClassLoader()
- .loadClass("javax.activation.DataHandler");
- } catch (Exception e) {
+ private static Class getDataHandlerClass()
+ {
+ try
+ {
+ return AxisHook.class.getClassLoader().loadClass("javax.activation.DataHandler");
+ }
+ catch (Exception e)
+ {
}
return null;
}
- private static Class getMultipartClass() {
- try {
- return AxisHook.class.getClassLoader()
- .loadClass("javax.mail.internet.MimeMultipart");
- } catch (Exception e) {
+ private static Class getMultipartClass()
+ {
+ try
+ {
+ return AxisHook.class.getClassLoader().loadClass("javax.mail.internet.MimeMultipart");
+ }
+ catch (Exception e)
+ {
}
return null;
}
private static QName configureTypeMapping(ServiceDesc desc, Class type)
- throws InvalidTypeMappingException {
- if (Void.TYPE.equals(type)) {
+ throws InvalidTypeMappingException
+ {
+ if (Void.TYPE.equals(type))
+ {
return null;
- } else {
+ }
+ else
+ {
TypeMapping tm = desc.getTypeMapping();
QName q = tm.getTypeQName(type);
- if (Collection.class.isAssignableFrom(type)) {
+ if (Collection.class.isAssignableFrom(type))
+ {
/*
* NOTE jcolwell@bea.com 2004-Oct-11 --
* overriding the default Axis conversion of all Collections
@@ -196,27 +232,41 @@
* since the namespace prefix is left hanging with literal use
*/
q = generateQName(type, desc);
- tm.register(type, q,
- new CollectionSerializerFactory(type, q),
- new VectorDeserializerFactory(type, q));
- } else {
- if (q == null) {
+ tm.register(
+ type,
+ q,
+ new CollectionSerializerFactory(type, q),
+ new VectorDeserializerFactory(type, q));
+ }
+ else
+ {
+ if (null == q)
+ {
q = generateQName(type, desc);
}
- if (type.isArray()) {
- if (!tm.isRegistered(type, q)) {
- tm.register(type, q,
- new ArraySerializerFactory(type, q),
- new ArrayDeserializerFactory());
+ if (type.isArray())
+ {
+ if (! tm.isRegistered(type, q))
+ {
+ tm.register(
+ type,
+ q,
+ new ArraySerializerFactory(type, q),
+ new ArrayDeserializerFactory()
+ );
}
- q = configureTypeMapping(desc,
- type.getComponentType());
- } else if (!tm.isRegistered(type, q)) {
- if (XmlObject.class.isAssignableFrom(type)) {
+ q = configureTypeMapping(desc, type.getComponentType());
+ }
+ else if (! tm.isRegistered(type, q))
+ {
+ if (XmlObject.class.isAssignableFrom(type))
+ {
q = XmlBeans.typeForClass(type).getName();
- tm.register(type, q,
- new XmlBeanSerializerFactory(type, q),
- new XmlBeanDeserializerFactory(type, q));
+ tm.register(
+ type,
+ q,
+ new XmlBeanSerializerFactory(type, q),
+ new XmlBeanDeserializerFactory(type, q));
}
/*
* NOTE jcolwell@bea.com 2004-Oct-11 -- these datahandler
@@ -226,7 +276,8 @@
else if (isActivationEnabled() &&
(java.awt.Image.class.isAssignableFrom(type)
|| getMultipartClass().isAssignableFrom(type)
- || getDataHandlerClass().isAssignableFrom(type))) {
+ || getDataHandlerClass().isAssignableFrom(type)))
+ {
try {
/*
* NOTE jcolwell@bea.com 2004-Oct-08 -- doing
@@ -249,7 +300,9 @@
SerializerFactory sf = sfCon.newInstance(type, q);
DeserializerFactory dsf = dsfCon.newInstance(type, q);
tm.register(type, q, sf, dsf);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
/*
* FIXME jcolwell@bea.com 2004-Oct-08 --
* log this properly
@@ -263,57 +316,63 @@
* by the jax-rpc spec
*
* NOTE jcolwell@bea.com 2004-Oct-11 --
- * restricting against File since even though it
- * is technically serializable, it doesn't make
+ * restricting against File, since it doesn't make
* sense to serialize as a bean.
- * That and it causes an infinite
- * loop as it keeps returning itself from the
- * getAbsoluteFile and getCanonicalFile calls
+ * It causes an infinite loop as it keeps returning
+ * itself from the getAbsoluteFile and
+ * getCanonicalFile calls
*/
&& !File.class.isAssignableFrom(type)) {
TypeDesc td = TypeDesc.getTypeDescForClass(type);
TypeDesc superTd = null;
BeanPropertyDescriptor[] superPd = null;
- if (null == td) {
+ if (null == td)
+ {
td = new TypeDesc(type);
Class supa = type.getSuperclass();
if ((supa != null)
- && (supa != java.lang.Object.class)
- && (supa != java.lang.Exception.class)
- && (supa != java.lang.Throwable.class)
- && (supa != java.rmi.RemoteException.class)
- && (supa != org.apache.axis.AxisFault.class)) {
+ && (supa != java.lang.Object.class)
+ && (supa != java.lang.Exception.class)
+ && (supa != java.lang.Throwable.class)
+ && (supa != java.rmi.RemoteException.class)
+ && (supa != org.apache.axis.AxisFault.class))
+ {
configureTypeMapping(desc, supa);
}
- superTd = TypeDesc
- .getTypeDescForClass(supa);
- if (superTd != null) {
+ superTd = TypeDesc.getTypeDescForClass(supa);
+ if (superTd != null)
+ {
superPd = superTd.getPropertyDescriptors();
}
td.setXmlType(q);
TypeDesc.registerTypeDescForClass(type, td);
- } else {
+ }
+ else
+ {
td = null;
}
- tm.register(type, q,
- new BeanSerializerFactory(type, q),
- /*
- * NOTE jcolwell@bea.com 2004-Oct-11 --
- * should check that the type to deserialize
- * has a default contructor but with this
- * setup there is no way to know if it is
- * used only in serialization.
- */
- new BeanDeserializerFactory(type, q));
- Map serProps = BeanDeserializerFactory
- .getProperties(type, null);
- for (BeanPropertyDescriptor beanProps :
- (Collection<BeanPropertyDescriptor>) serProps
- .values()) {
+ tm.register(
+ type,
+ q,
+ new BeanSerializerFactory(type, q),
+ /*
+ * NOTE jcolwell@bea.com 2004-Oct-11 --
+ * should check that the type to deserialize
+ * has a default contructor but with this
+ * setup there is no way to know if it is
+ * used only in serialization.
+ */
+ new BeanDeserializerFactory(type, q)
+ );
+ Map serProps =
+ BeanDeserializerFactory.getProperties(type, null);
+ for (BeanPropertyDescriptor beanProps : (Collection<BeanPropertyDescriptor>) serProps.values())
+ {
Class subType = beanProps.getType();
- if (!(subType.isPrimitive()
+ if (! (subType.isPrimitive()
|| subType.getName().startsWith("java.")
- || subType.getName().startsWith("javax."))) {
+ || subType.getName().startsWith("javax.")))
+ {
configureTypeMapping(desc, subType);
}
if (td != null) {
@@ -340,11 +399,14 @@
td.addFieldDesc(fd);
}
}
- } else {
- throw new InvalidTypeMappingException
- ("failed to register " + type.getName()
- + " as a valid web service datatype,"
- + " consider using a custom type mapping");
+ }
+ else
+ {
+ throw new InvalidTypeMappingException(
+ "failed to register " + type.getName()
+ + " as a valid web service datatype,"
+ + " consider using a custom type mapping"
+ );
}
}
}
@@ -398,5 +460,4 @@
}
}
}
-}
-
+}
\ No newline at end of file
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/AxisTypeMappingUtil.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/AxisTypeMappingUtil.java?view=diff&rev=109508&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/AxisTypeMappingUtil.java&r1=109507&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/AxisTypeMappingUtil.java&r2=109508
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/AxisTypeMappingUtil.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/AxisTypeMappingUtil.java Thu Dec 2 09:20:11 2004
@@ -188,18 +188,16 @@
*/
e.printStackTrace();
}
- } else if (Serializable.class.isAssignableFrom(cls)
+ } else if (! Remote.class.isAssignableFrom(cls)
/*
* NOTE jcolwell@bea.com 2004-Oct-11 --
- * java.io.Serializable is required and
* java.rmi.Remote is prohibited
- * by the jax-rpc spec
+ * by the jax-rpc spec.
*/
- && !Remote.class.isAssignableFrom(cls)
+
/*
* NOTE jcolwell@bea.com 2004-Oct-11 --
- * restricting against File since even though it
- * is technically serializable, it doesn't make
+ * restricting against File since, it doesn't make
* sense to serialize as a bean.
* That and it causes an infinite
* loop as it keeps returning itself from the