Author: mmerz
Date: Wed Mar 23 11:57:57 2005
New Revision: 158824
URL: http://svn.apache.org/viewcvs?view=rev&rev=158824
Log:
Fixed Handlers
build files generates the wsdltypes.jar at build time
Enhanced Samples
Fixed axis hook for exceptions
Enahnced wsdl processing
Fixed type registration for the service control
Contributor: Daryoush Mehrtash
Removed:
incubator/beehive/trunk/wsm/lib/wsdltypes.jar
Modified:
incubator/beehive/trunk/samples/wsm-addressbook/WEB-INF/src/org/apache/beehive/sample/AddressBookImpl.java
incubator/beehive/trunk/samples/wsm-samples/WEB-INF/build-svn.xml
incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamDocumentLiteralSample.jws
incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamRpcLiteralSample.jws
incubator/beehive/trunk/wsm/build.xml
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/registration/AxisTypeRegistrar.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsMethodMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/wsdl/XmlBeanWSDLProcessor.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/registration/TypeRegistrar.java
Modified:
incubator/beehive/trunk/samples/wsm-addressbook/WEB-INF/src/org/apache/beehive/sample/AddressBookImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-addressbook/WEB-INF/src/org/apache/beehive/sample/AddressBookImpl.java?view=diff&r1=158823&r2=158824
==============================================================================
---
incubator/beehive/trunk/samples/wsm-addressbook/WEB-INF/src/org/apache/beehive/sample/AddressBookImpl.java
(original)
+++
incubator/beehive/trunk/samples/wsm-addressbook/WEB-INF/src/org/apache/beehive/sample/AddressBookImpl.java
Wed Mar 23 11:57:57 2005
@@ -25,6 +25,14 @@
private static Map<String, Address> addresses = new Hashtable<String,
Address>();
+ static {
+ Phone testPhone = new Phone(200,"my exchange", "1234567");
+ StateType testState = new StateType("my state");
+ Address testAddress = new Address(100, "my street name", "my city",
testState, 11111, testPhone);
+ addresses.put("jack", testAddress);
+ }
+
+
public void addEntry(String name, Address address) {
System.out.println("addEntry() is called for: " + name );
if (null == name || null == address) {
@@ -32,6 +40,7 @@
return;
}
addresses.put(name, address);
+
}
public Address getAddressFromName(String name) {
Modified: incubator/beehive/trunk/samples/wsm-samples/WEB-INF/build-svn.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/build-svn.xml?view=diff&r1=158823&r2=158824
==============================================================================
--- incubator/beehive/trunk/samples/wsm-samples/WEB-INF/build-svn.xml (original)
+++ incubator/beehive/trunk/samples/wsm-samples/WEB-INF/build-svn.xml Wed Mar
23 11:57:57 2005
@@ -97,6 +97,8 @@
<delete file="${webservice.jar}" />
<delete file="velocity.log" />
<clean-webapp webappDir="${webapp.dir}" />
+ <delete file="${webservice.jar}" />
+ <delete file="${webservice.war}" />
</target>
Modified:
incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamDocumentLiteralSample.jws
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamDocumentLiteralSample.jws?view=diff&r1=158823&r2=158824
==============================================================================
---
incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamDocumentLiteralSample.jws
(original)
+++
incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamDocumentLiteralSample.jws
Wed Mar 23 11:57:57 2005
@@ -35,7 +35,7 @@
* This method shows the encoding of a parameter of simple type in the
message body.
*/
@WebMethod
- public String sayHelloInBody(@WebParam(name="name-in") String name) {
+ public String sayHelloInBody(@WebParam(name="name_in") String name) {
return "Hello, " + name + "!";
}
@@ -43,7 +43,7 @@
* This method shows the encoding of a parameter of simple type in the
message header.
*/
@WebMethod
- public String sayHelloInHeader(@WebParam(name="name-in", header=true)
String name) {
+ public String sayHelloInHeader(@WebParam(name="name_in", header=true)
String name) {
return "Hello, " + name + "!";
}
@@ -68,9 +68,10 @@
*/
@WebMethod
public Phone createPhoneNumberInHeader(
- @WebParam(name="area-code", header=true) int areaCode,
- @WebParam(name="phone-in", header=true) Phone phone
+ @WebParam(name="area_code", header=true) int areaCode,
+ @WebParam(name="phone_in", header=true) Phone phone
) {
+ System.out.println("Creating phone number with arguments in the
header");
return new Phone(areaCode, phone.getExchange(), phone.getNumber());
}
@@ -80,10 +81,21 @@
@WebMethod
public Phone createPhoneNumberInBodyHeader(
int areaCode,
- @WebParam(name="phone-in", header=true) Phone phone
+ @WebParam(name="phone_in", header=true) Phone phone
) {
return new Phone(areaCode, phone.getExchange(), phone.getNumber());
}
+
+ /**
+ * This method shows the encoding of multiple simple and complex
parameters in both message body and header.
+ */
+ @WebMethod
+ public Phone createPhoneNumberInBody(
+ int areaCode
+ ) {
+ return new Phone(areaCode, "", "");
+ }
+
/**
* This method shows the encoding of multiple simple and complex
parameters in both message body and header.
Modified:
incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamRpcLiteralSample.jws
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamRpcLiteralSample.jws?view=diff&r1=158823&r2=158824
==============================================================================
---
incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamRpcLiteralSample.jws
(original)
+++
incubator/beehive/trunk/samples/wsm-samples/WEB-INF/src/web/webparam/WebParamRpcLiteralSample.jws
Wed Mar 23 11:57:57 2005
@@ -36,7 +36,7 @@
* This method shows the encoding of a parameter of simple type in the
message body.
*/
@WebMethod
- public String sayHelloInBody(@WebParam(name="name-in") String name) {
+ public String sayHelloInBody(@WebParam(name="namein") String name) {
return "Hello, " + name + "!";
}
@@ -44,7 +44,7 @@
* This method shows the encoding of a parameter of simple type in the
message header.
*/
@WebMethod
- public String sayHelloInHeader(@WebParam(name="name-in", header=true)
String name) {
+ public String sayHelloInHeader(@WebParam(name="namein", header=true)
String name) {
return "Hello, " + name + "!";
}
@@ -69,8 +69,8 @@
*/
@WebMethod
public Phone createPhoneNumberInHeader(
- @WebParam(name="area-code", header=true) int areaCode,
- @WebParam(name="phone-in", header=true) Phone phone
+ @WebParam(name="areacode", header=true) int areaCode,
+ @WebParam(name="phonein", header=true) Phone phone
) {
return new Phone(areaCode, phone.getExchange(), phone.getNumber());
}
@@ -81,7 +81,7 @@
@WebMethod
public Phone createPhoneNumberInBodyHeader(
int areaCode,
- @WebParam(name="phone-in", header=true) Phone phone
+ @WebParam(name="phonein", header=true) Phone phone
) {
return new Phone(areaCode, phone.getExchange(), phone.getNumber());
}
Modified: incubator/beehive/trunk/wsm/build.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/build.xml?view=diff&r1=158823&r2=158824
==============================================================================
--- incubator/beehive/trunk/wsm/build.xml (original)
+++ incubator/beehive/trunk/wsm/build.xml Wed Mar 23 11:57:57 2005
@@ -38,6 +38,9 @@
<property name="xsd.schema.dir" location="src/runtime/schema" />
<property name="xsd.classes.dir" location="${build.dir}/xsd-classes" />
<property name="xsd.includes" value="*.xsd" />
+
+ <property name="wsdl.schema.dir" location="schemas" />
+ <property name="temp.wsdl.classes.dir"
location="${build.dir}/temp-wsdltypes" />
<path id="runtime.classpath">
<path refid="velocity.dependency.path"/>
@@ -190,11 +193,35 @@
<build-xbean schemaDir="${xsd.schema.dir}"
classgenDir="${xsd.classes.dir}"/>
</target>
+
+
+
+
+ <!-- ====================================================================
-->
+ <!-- Generate xml bean type for wsdl based on its schema
-->
+ <!-- ====================================================================
-->
+ <target name="wsdltypes" description="Generate the xml bean types wsdl
schema">
+ <fileset id="xwsdl.schema.source" dir="${wsdl.schema.dir}"
includes="${xsd.includes}"/>
+ <!-- checks whether classes have already been generated. -->
+ <uptodate property="wsdltypes.uptodate"
targetfile="${lib.dir}/wsdltypes.jar">
+ <srcfiles refid="xwsdl.schema.source"/>
+ </uptodate>
+ <antcall target="wsdltypes.generate"/>
+ </target>
+ <target name="wsdltypes.generate" unless="wsdltypes.uptodate">
+ <echo message="generate wsdl types"/>
+ <delete dir="${temp.wsdl.classes.dir}" />
+ <build-xbean schemaDir="${wsdl.schema.dir}"
classgenDir="${temp.wsdl.classes.dir}"/>
+ <jar jarfile="${lib.dir}/wsdltypes.jar">
+ <fileset dir="${temp.wsdl.classes.dir}" />
+ </jar>
+ </target>
+
<!-- ====================================================================
-->
<!-- Jars up the classes, libraries, and resources. -->
<!-- ====================================================================
-->
- <target name="build" depends="classes">
+ <target name="build" depends="wsdltypes, classes">
<echo message="--------------------------------------------------"/>
<echo message="| WSM build starting |"/>
<echo message="--------------------------------------------------"/>
@@ -255,6 +282,7 @@
<!-- ====================================================================
-->
<target name="clean">
<delete dir="${build.dir}"/>
+ <delete file="${lib.dir}/wsdltypes.jar" />
<ant dir="drt" target="clean" inheritAll="false"/>
</target>
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&r1=158823&r2=158824
==============================================================================
---
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
Wed Mar 23 11:57:57 2005
@@ -19,6 +19,8 @@
*/
package org.apache.beehive.wsm.axis;
+import java.util.ArrayList;
+
import javax.jws.WebParam;
import javax.jws.soap.SOAPBinding;
import javax.wsdl.OperationType;
@@ -47,6 +49,7 @@
public static final Class WS_CLASS = FakeWebService.class;
public static final String WM_JAVAMETHODNAME = "fakeWebMethod";
public static final String WM_JAVAONEWAYMETHODNAME = "fakeOneWayWebMethod";
+ public static final String WM_JAVAMETHODWITHEXCEPIONNAME=
"fakeWayWebMethodWithException";
public static final String WS_NAME = "WebServiceName";
//public static final String WS_SERVICENAME = WS_NAME + "Service";
public static final String WS_NAMESPACE = "http://web.service/namespace";
@@ -54,7 +57,8 @@
public static final String WM_ACTION = "Lights_Camera_Action!";
public static final String WM_RESULT = "ResultName";
public static final String WM_ONEWAY = "Oneway";
- public static final String WM_TWOWAYPARAM = "number";
+ public static final String WM_EXCEPTION = "WithException";
+ public static final String WM_TWOWAYPARAM = "number";
public static final String WM_ONEWAYPARAM = "text";
ServiceDesc sd;
@@ -107,6 +111,14 @@
}
}
+
+ public void testExceptions() throws Exception {
+ OperationDesc opWithException =
sd.getOperationByName(WM_JAVAMETHODWITHEXCEPIONNAME);
+ assertNotNull(opWithException);
+ ArrayList allFaults = opWithException.getFaults();
+ assertNotNull(allFaults);
+ assertTrue(allFaults.size() == 1 ); // note: it should ignore the
javax.... exception.
+ }
public void testOneWayOperation() throws Exception {
OperationDesc oneWayOp =
sd.getOperationByName(WM_JAVAONEWAYMETHODNAME);
assertNotNull(oneWayOp);
@@ -138,6 +150,7 @@
wstm.setSoapBinding(makeFakeSoapBinding());
wstm.addMethod(makeFakeMethod());
wstm.addMethod(makeFakeOnewayMethod());
+ wstm.addMethod(makeFakeMethodWithException());
return wstm;
}
@@ -155,6 +168,8 @@
return wsmm;
}
+
+
protected BeehiveWsMethodMetadata makeFakeMethod() {
BeehiveWsMethodMetadata wsmm =
new Jsr181MethodMetadataImpl(WM_JAVAMETHODNAME, String.class);
@@ -169,6 +184,21 @@
wsmm.addParam(wspm);
return wsmm;
}
+
+ protected BeehiveWsMethodMetadata makeFakeMethodWithException() {
+ BeehiveWsMethodMetadata wsmm =
+ new Jsr181MethodMetadataImpl(WM_JAVAMETHODWITHEXCEPIONNAME,
String.class);
+ wsmm.setWmOperationName(WM_EXCEPTION + WM_OPERATION);
+ wsmm.setWmAction(WM_EXCEPTION + WM_ACTION);
+ wsmm.setWrName(WM_RESULT);
+ wsmm.setOneWay(false);
+ BeehiveWsParameterMetadata wspm = new Jsr181ParameterMetadataImpl();
+ wspm.setWpName(WM_TWOWAYPARAM);
+ wspm.setWpMode(WebParam.Mode.INOUT);
+ wspm.setJavaType(javax.xml.rpc.holders.IntHolder.class);
+ wsmm.addParam(wspm);
+ return wsmm;
+ }
protected SOAPBindingInfo makeFakeSoapBinding() {
SOAPBindingInfo sbi = new SOAPBindingInfo();
@@ -179,6 +209,12 @@
}
public static class FakeWebService {
+
+
+ // a method with an exception just to test exception processing in
AxisHook
+ public String
fakeWayWebMethodWithException(javax.xml.rpc.holders.IntHolder num) throws
NumberFormatException, MyException {
+ return "You're number " + num.value + '!';
+ }
public String fakeWebMethod(javax.xml.rpc.holders.IntHolder num) {
return "You're number " + num.value + '!';
@@ -187,5 +223,9 @@
public void fakeOneWayWebMethod(Boolean b) {
//do nothing
}
+ }
+
+ public static class MyException extends Exception {
+
}
}
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&r1=158823&r2=158824
==============================================================================
---
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
Wed Mar 23 11:57:57 2005
@@ -33,6 +33,7 @@
import org.apache.beehive.wsm.jsr181.model.BeehiveWsSOAPBindingInfo;
import org.apache.beehive.wsm.jsr181.model.BeehiveWsTypeMetadata;
import org.apache.beehive.wsm.jsr181.util.InvalidTypeMappingException;
+import org.apache.log4j.Logger;
import org.apache.xmlbeans.XmlBeans;
import org.apache.xmlbeans.XmlObject;
@@ -50,25 +51,20 @@
/**
* ****************************************************************************
- *
+ *
* @author Jonathan Colwell
*/
public class AxisHook {
- public static ServiceDesc createServiceDesc(
- BeehiveWsTypeMetadata wsm,
- ClassLoader cl
- )
- throws
- ClassNotFoundException,
- NoSuchMethodException,
- InvalidTypeMappingException
- {
+ static Logger logger = Logger.getLogger(AxisHook.class);
+
+ public static ServiceDesc createServiceDesc(BeehiveWsTypeMetadata wsm,
+ ClassLoader cl) throws ClassNotFoundException,
+ NoSuchMethodException, InvalidTypeMappingException {
JavaServiceDesc sd = new JavaServiceDesc();
- if (null == cl)
- {
+ if (null == cl) {
/*
- * NOTE [EMAIL PROTECTED] 2004-Aug-30 -- if no classloader
- * was provided, use the one that loaded this Class
+ * NOTE [EMAIL PROTECTED] 2004-Aug-30 -- if no classloader was
+ * provided, use the one that loaded this Class
*/
cl = AxisHook.class.getClassLoader();
}
@@ -76,8 +72,7 @@
// Create a list of the allowed methods
List<String> allowedMethods = new ArrayList<String>();
- for (BeehiveWsMethodMetadata meth : wsm.getMethods())
- {
+ for (BeehiveWsMethodMetadata meth : wsm.getMethods()) {
String method = meth.getJavaMethodName();
allowedMethods.add(method);
}
@@ -88,102 +83,116 @@
String targetNamespace = wsm.getWsTargetNamespace();
sd.setDefaultNamespace(targetNamespace);
sd.setAllowedMethods(allowedMethods);
- configureSoapBinding(sd, wsm.getSoapBinding());
-
+ configureSoapBinding(sd, wsm.getSoapBinding());
+
TypeMappingRegistry tmr = new TypeMappingRegistryImpl(true);
- TypeMapping tm = tmr.getOrMakeTypeMapping(sd.getUse() == Use.ENCODED ?
"encoded" : "");
+ TypeMapping tm = tmr
+ .getOrMakeTypeMapping(sd.getUse() == Use.ENCODED ? "encoded"
+ : "");
sd.setTypeMappingRegistry(tmr);
sd.setTypeMapping(tm);
-
- /* [EMAIL PROTECTED] 2005-Mar-16 --
- * Use Axis's introspection feature instead of creating new
OperationDesc and ParameterDescs directly.
- * The introspected OperationDesc and ParameterDescs are overrided by
WSM.
- * When appropriate type mapping registry is set, Axis fills the
ParameterDesc's typeEntry from the preset typemapping registry,
- * which is required for Axis to work in wrapped/lit mode.
+
+ /*
+ * [EMAIL PROTECTED] 2005-Mar-16 -- Use Axis's introspection
+ * feature instead of creating new OperationDesc and ParameterDescs
+ * directly. The introspected OperationDesc and ParameterDescs are
+ * overrided by WSM. When appropriate type mapping registry is set,
Axis
+ * fills the ParameterDesc's typeEntry from the preset typemapping
+ * registry, which is required for Axis to work in wrapped/lit mode.
*/
sd.getOperations();
// Walk the methods
- for (BeehiveWsMethodMetadata meth : wsm.getMethods())
- {
+ for (BeehiveWsMethodMetadata meth : wsm.getMethods()) {
String operationName = meth.getWmOperationName();
- if (null != operationName && 0 < operationName.length())
- {
+ if (null != operationName && 0 < operationName.length()) {
// set the Operations properties
- OperationDesc od =
sd.getOperationByName(meth.getJavaMethodName());
+ OperationDesc od = sd.getOperationByName(meth
+ .getJavaMethodName());
od.setElementQName(new QName(targetNamespace, operationName));
od.setName(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()));
+ } else {
+ od.setReturnQName(new QName(meth.getWrTargetNamespace(),
+ meth.getWrName()));
final Class returnType = meth.getJavaReturnType();
- QName qn = configureTypeMapping(sd, returnType,
meth.getWrTargetNamespace());
+ QName qn = configureTypeMapping(sd, returnType, meth
+ .getWrTargetNamespace());
od.setReturnType(qn);
od.setReturnClass(returnType);
}
// process the parameters
int pcnt = 0;
- for (BeehiveWsParameterMetadata param : meth.getParams())
- {
+ for (BeehiveWsParameterMetadata param : meth.getParams()) {
ParameterDesc pd = od.getParameter(pcnt++);
final Class paramType = param.getJavaType();
-
- if (pd.getTypeQName() == null) { // set the typeQName
if it is not set already.
- QName typeQName = configureTypeMapping(sd, paramType,
param.getWpTargetNamespace());
- /* [EMAIL PROTECTED] 2005-Mar-16 --
- * The typeQName from configureTypeMapping() is not
dummy.
- * This is required to find ArrayDeserializer when the
document/literal bare array is deserialized.
- */
+
+ if (pd.getTypeQName() == null) { // set the typeQName if
+ // it is not set
+ // already.
+ QName typeQName = configureTypeMapping(sd, paramType,
+ param.getWpTargetNamespace());
+ /*
+ * [EMAIL PROTECTED] 2005-Mar-16 -- The typeQName
+ * from configureTypeMapping() is not dummy. This is
+ * required to find ArrayDeserializer when the
+ * document/literal bare array is deserialized.
+ */
pd.setTypeQName(typeQName);
}
// set QName
- QName paramQName = new QName(param.getWpTargetNamespace(),
param.getWpName());
+ QName paramQName = new QName(param.getWpTargetNamespace(),
+ param.getWpName());
pd.setQName(paramQName);
// set Mode
final boolean header = param.isWpHeader();
final WebParam.Mode mode = param.getWpMode();
switch (mode) {
- case IN:
- pd.setMode(ParameterDesc.IN);
- pd.setInHeader(header);
- pd.setOutHeader(false);
- break;
- case OUT:
- pd.setMode(ParameterDesc.OUT);
- pd.setInHeader(false);
- pd.setOutHeader(header);
- break;
- case INOUT:
- pd.setMode(ParameterDesc.INOUT);
- pd.setInHeader(header);
- pd.setOutHeader(header);
- break;
- default:
- throw new IllegalArgumentException("Illegal value
for WebParam.Mode: " + mode);
+ case IN:
+ pd.setMode(ParameterDesc.IN);
+ pd.setInHeader(header);
+ pd.setOutHeader(false);
+ break;
+ case OUT:
+ pd.setMode(ParameterDesc.OUT);
+ pd.setInHeader(false);
+ pd.setOutHeader(header);
+ break;
+ case INOUT:
+ pd.setMode(ParameterDesc.INOUT);
+ pd.setInHeader(header);
+ pd.setOutHeader(header);
+ break;
+ default:
+ throw new IllegalArgumentException(
+ "Illegal value for WebParam.Mode: " + mode);
}
// set JavaType
- pd.setJavaType(paramType);
+ pd.setJavaType(paramType);
}
-
// set Exceptions
Method javaMethod = od.getMethod();
- for (Class thrown : javaMethod.getExceptionTypes())
- {
+ for (Class thrown : javaMethod.getExceptionTypes()) {
FaultDesc fd = od.getFaultByClass(thrown);
- QName qname = configureTypeMapping(sd, thrown,
meth.getWrTargetNamespace());
+ if (null == fd) {
+ logger
+ .info("Exception: "
+ + thrown.getCanonicalName()
+ + " is not picked up by the Axis, only
non Remote and Application Specific exceptions are registed in Axis. This is
not a fatal error.");
+ continue;
+ }
+ QName qname = configureTypeMapping(sd, thrown, meth
+ .getWrTargetNamespace());
fd.setXmlType(qname);
fd.setQName(qname);
- fd.setComplex(true);
+ fd.setComplex(true);
}
}
}
@@ -191,234 +200,238 @@
}
/**
- * This method will return a boolean value indicating that Activation is
enabled.
- * Activation requires the DataHandler and the Multipart Classes to both
be found.
+ * This method will return a boolean value indicating that Activation is
+ * enabled. Activation requires the DataHandler and the Multipart Classes
to
+ * both be found.
+ *
* @return boolean indicating that Activation is enabled.
*/
- private static boolean isActivationEnabled()
- {
+ private static boolean isActivationEnabled() {
return null != getDataHandlerClass() && null != getMultipartClass();
}
/**
- * This will return the Class for the DataHandler. This will return null
- * if the DataHandler is not available.
+ * This will return the Class for the DataHandler. This will return null if
+ * the DataHandler is not available.
+ *
* @return The DataHandler Class or null if the DataHandler is not found
*/
- private static Class getDataHandlerClass()
- {
- try
- {
- return
AxisHook.class.getClassLoader().loadClass("javax.activation.DataHandler");
- }
- catch (ClassNotFoundException e)
- {
+ private static Class getDataHandlerClass() {
+ try {
+ return AxisHook.class.getClassLoader().loadClass(
+ "javax.activation.DataHandler");
+ } catch (ClassNotFoundException e) {
// ignore the class was not found
}
return null;
}
/**
- * This will return the Class for the MimeMultipart handler. It will
- * return null if the MimMultipart class is not available.
- * @return The MimeMultipart Class or null if the DataHandler is not
found.
+ * This will return the Class for the MimeMultipart handler. It will return
+ * null if the MimMultipart class is not available.
+ *
+ * @return The MimeMultipart Class or null if the DataHandler is not found.
*/
- private static Class getMultipartClass()
- {
- try
- {
- return
AxisHook.class.getClassLoader().loadClass("javax.mail.internet.MimeMultipart");
- }
- catch (ClassNotFoundException e)
- {
+ private static Class getMultipartClass() {
+ try {
+ return AxisHook.class.getClassLoader().loadClass(
+ "javax.mail.internet.MimeMultipart");
+ } catch (ClassNotFoundException e) {
// ignore the class was not found
}
return null;
}
- private static QName configureTypeMapping(ServiceDesc desc, Class type,
String defaultNameSpace)
- throws InvalidTypeMappingException
- {
- if (Void.TYPE.equals(type))
- {
+ private static QName configureTypeMapping(ServiceDesc desc, Class type,
+ String defaultNameSpace) throws InvalidTypeMappingException {
+ if (Void.TYPE.equals(type)) {
return null;
- }
- else
- {
+ } else {
TypeMapping tm = desc.getTypeMapping();
QName q = tm.getTypeQName(type);
- if (null == q)
- {
+ if (null == q) {
// q = generateQName(type, desc);
- q = new QName(defaultNameSpace,
- Types.getLocalNameFromFullName(type.getName()));
+ q = new QName(defaultNameSpace, Types
+ .getLocalNameFromFullName(type.getName()));
}
- if (type.isArray())
- {
- /* [EMAIL PROTECTED] 2005-Mar-16 --
- * don't register array serializer in document(bare or
wrapped)/literal mode.
+ if (type.isArray()) {
+ /*
+ * [EMAIL PROTECTED] 2005-Mar-16 -- don't register array
+ * serializer in document(bare or wrapped)/literal mode.
*/
- if (! tm.isRegistered(type, q) && desc.getStyle() == Style.RPC
&& desc.getUse() == Use.ENCODED)
- {
- tm.register(type,
- q,
- new ArraySerializerFactory(type, q),
- new ArrayDeserializerFactory());
+ if (!tm.isRegistered(type, q) && desc.getStyle() == Style.RPC
+ && desc.getUse() == Use.ENCODED) {
+ tm.register(type, q, new ArraySerializerFactory(type, q),
+ new ArrayDeserializerFactory());
}
- QName qcomp = configureTypeMapping(desc,
type.getComponentType(), defaultNameSpace);
+ QName qcomp = configureTypeMapping(desc, type
+ .getComponentType(), defaultNameSpace);
if (desc.getUse() == Use.LITERAL) {
q = qcomp;
}
- }
- else if (! tm.isRegistered(type, q))
- {
- if (XmlObject.class.isAssignableFrom(type))
- {
+ } 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 [EMAIL PROTECTED] 2004-Oct-11 -- these datahandler
- * using classes are generally already registered but
- * just in case...
+ * NOTE [EMAIL PROTECTED] 2004-Oct-11 -- these datahandler
using
+ * classes are generally already registered but just in case...
*/
- else if (isActivationEnabled() &&
- (java.awt.Image.class.isAssignableFrom(type)
- || getMultipartClass().isAssignableFrom(type)
- || getDataHandlerClass().isAssignableFrom(type)))
- {
+ else if (isActivationEnabled()
+ && (java.awt.Image.class.isAssignableFrom(type)
+ || getMultipartClass().isAssignableFrom(type)
|| getDataHandlerClass()
+ .isAssignableFrom(type))) {
try {
/*
- * NOTE [EMAIL PROTECTED] 2004-Oct-08 -- doing
- * reflection here in case AXIS was built without
- * attachment support.
+ * NOTE [EMAIL PROTECTED] 2004-Oct-08 -- doing
reflection
+ * here in case AXIS was built without attachment
+ * support.
*/
ClassLoader cl = AxisHook.class.getClassLoader();
- // Loadclass could have been done in import also, but
if there are no activation.jar then this would
- // cause error when the class is loaded. To prevent
that we load the class explicitly at this point.
- // if we had done the "new
org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory" then the class
- // would have had dependecies to the org.apache...
class which would not have worked in case activation was
+ // Loadclass could have been done in import also, but
if
+ // there are no activation.jar then this would
+ // cause error when the class is loaded. To prevent
that
+ // we load the class explicitly at this point.
+ // if we had done the "new
+ //
org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"
+ // then the class
+ // would have had dependecies to the org.apache...
class
+ // which would not have worked in case activation was
// not on the path.
- Class<SerializerFactory> sfClass =
- (Class<SerializerFactory>)
-
cl.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory");
- Class<DeserializerFactory> dsfClass =
- (Class<DeserializerFactory>)
-
cl.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory");
- Constructor<SerializerFactory> sfCon =
- sfClass.getConstructor(Class.class,
- QName.class);
- Constructor<DeserializerFactory> dsfCon =
- dsfClass.getConstructor(Class.class,
- QName.class);
+ Class<SerializerFactory> sfClass =
(Class<SerializerFactory>) cl
+
.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory");
+ Class<DeserializerFactory> dsfClass =
(Class<DeserializerFactory>) cl
+
.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory");
+ Constructor<SerializerFactory> sfCon = sfClass
+ .getConstructor(Class.class, QName.class);
+ Constructor<DeserializerFactory> dsfCon = dsfClass
+ .getConstructor(Class.class, QName.class);
SerializerFactory sf = sfCon.newInstance(type, q);
DeserializerFactory dsf = dsfCon.newInstance(type, q);
tm.register(type, q, sf, dsf);
+ } catch (Exception e) {
+ /*
+ * FIXME [EMAIL PROTECTED] 2004-Oct-08 -- log this
+ * properly
+ */
+ e.printStackTrace();
}
- catch (Exception e)
- {
- /*
- * FIXME [EMAIL PROTECTED] 2004-Oct-08 --
- * log this properly
- */
- e.printStackTrace();
- }
- } else if (!Remote.class.isAssignableFrom(type)
- /*
- * NOTE [EMAIL PROTECTED] 2004-Dec-01 --
- * java.rmi.Remote is prohibited
- * by the jax-rpc spec
- *
- * NOTE [EMAIL PROTECTED] 2004-Oct-11 --
- * restricting against File, since it doesn't make
- * sense to serialize as a bean.
- * It causes an infinite loop as it keeps returning
- * itself from the getAbsoluteFile and
- * getCanonicalFile calls
- */
- && !File.class.isAssignableFrom(type)) {
+ } else if (!Remote.class.isAssignableFrom(type)
+ /*
+ * NOTE [EMAIL PROTECTED] 2004-Dec-01 -- java.rmi.Remote is
+ * prohibited by the jax-rpc spec
+ *
+ * NOTE [EMAIL PROTECTED] 2004-Oct-11 -- restricting against
+ * File, since it doesn't make sense to serialize as a bean. 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;
- // type desc is used for java-xml mapping, make sure the
class and all its super classes have a type desc defined.
- if (null == td)
- {
- td = new TypeDesc(type); // create type descriptor
for this class --- NOT its super classes at this point.
+ // type desc is used for java-xml mapping, make sure the
+ // class and all its super classes have a type desc
defined.
+ if (null == td) {
+ td = new TypeDesc(type); // create type descriptor
+ // for this class --- NOT
+ // its super classes at
this
+ // point.
// add super class types.
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))
- {
+ 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)) {
configureTypeMapping(desc, supa, defaultNameSpace);
}
- // check to see if a type mapping was created for the
super class.
- superTd = TypeDesc.getTypeDescForClass(supa);
- if (superTd != null) // super class is a regular java
bean with axis typedesc.
+ // check to see if a type mapping was created for the
+ // super class.
+ superTd = TypeDesc.getTypeDescForClass(supa);
+ if (superTd != null) // super class is a regular java
+ // bean with axis typedesc.
{
- superPd = superTd.getPropertyDescriptors(); //
this is mapping for all my super classes.
+ superPd = superTd.getPropertyDescriptors(); // this
+ // is
+ //
mapping
+ // for
+ // all
+ // my
+ //
super
+ //
classes.
}
td.setXmlType(q);
TypeDesc.registerTypeDescForClass(type, td);
- // NOTE: this is partially finished td, so more
processing to follow that is why its td is not set to null as it is
- // for the case when it is already provided (when td
!=null)
- }
- else
- {
- td = null; // we don't need type desc. any more this
is a complete td
+ // NOTE: this is partially finished td, so more
+ // processing to follow that is why its td is not set
to
+ // null as it is
+ // for the case when it is already provided (when td
+ // !=null)
+ } else {
+ td = null; // we don't need type desc. any more this is
+ // a complete td
}
-
- // At this all parent bean classes and their properties
(attributes) have been registered with typedecriptor and type mapping.
+
+ // At this all parent bean classes and their properties
+ // (attributes) have been registered with typedecriptor and
+ // type mapping.
// next regidster type for this class.
- tm.register(type,
- q,
- new BeanSerializerFactory(type, q),
- /*
- * NOTE [EMAIL PROTECTED] 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));
-
- // now register the types for this bean properties
(attributes)
- // Note: we have to consider the case that one of the
properties may be XML bean
+ tm.register(type, q, new BeanSerializerFactory(type, q),
+ /*
+ * NOTE [EMAIL PROTECTED] 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));
+
+ // now register the types for this bean properties
+ // (attributes)
+ // Note: we have to consider the case that one of the
+ // properties may be XML bean
// or a class that can deal with its own serialization.
- Map serProps =
- BeanDeserializerFactory.getProperties(type, null); //
Note this is all of the bean properties
- for (BeanPropertyDescriptor beanProps :
(Collection<BeanPropertyDescriptor>) serProps.values())
- {
+ Map serProps = BeanDeserializerFactory.getProperties(type,
+ null); // Note this is all of the bean properties
+ for (BeanPropertyDescriptor beanProps :
(Collection<BeanPropertyDescriptor>) serProps
+ .values()) {
Class subType = beanProps.getType();
- // make sure the property type is configred with Type
mapping and its serializer information
- if (! (subType.isPrimitive()
- || subType.getName().startsWith("java.")
- || subType.getName().startsWith("javax.")))
- {
- configureTypeMapping(desc,
- subType,
- defaultNameSpace); // if
this was XML bean this recursion would take care of it
+ // make sure the property type is configred with Type
+ // mapping and its serializer information
+ if (!(subType.isPrimitive()
+ || subType.getName().startsWith("java.") ||
subType
+ .getName().startsWith("javax."))) {
+ configureTypeMapping(desc, subType,
+ defaultNameSpace); // if this was XML bean
+ // this recursion would
+ // take care of it
}
- if (td != null) { // if I didn't have type descriptor
when I came to this method... I created partially filled one above
- // now need to
complete this.
- String ns = q.getNamespaceURI(); // name space
for the class if there is no parent
- // find proper namespace for this element... we
need to find out whihc class in the hierarchy the element came from
- // once you know where the element came form
(which class) then you know the element's name space.
- if (superTd != null && superPd != null) { // if I
had a parent,
+ if (td != null) { // if I didn't have type descriptor
+ // when I came to this method... I
+ // created partially filled one
+ // above
+ // now need to complete this.
+ String ns = q.getNamespaceURI(); // name space
+ // for the
class
+ // if there is
+ // no parent
+ // find proper namespace for this element... we
need
+ // to find out whihc class in the hierarchy the
+ // element came from
+ // once you know where the element came form (which
+ // class) then you know the element's name space.
+ if (superTd != null && superPd != null) { // if I
+ // had
a
+ //
parent,
for (int j = 0; j < superPd.length; j++) {
- if (beanProps.getName()
- .equals(superPd[j]
- .getName())) {
+ if (beanProps.getName().equals(
+ superPd[j].getName())) {
ns = superTd.getXmlType()
- .getNamespaceURI();
+ .getNamespaceURI();
break;
}
}
@@ -426,48 +439,43 @@
FieldDesc fd = new ElementDesc();
fd.setJavaType(subType);
fd.setFieldName(beanProps.getName());
- fd.setXmlName(new QName(ns,
- beanProps.getName()));
+ fd.setXmlName(new QName(ns, beanProps.getName()));
// NOTE [EMAIL PROTECTED] 2004-Oct-28 -- might need
// to do more to ensure a useful type QName.
fd.setXmlType(tm.getTypeQName(subType));
((ElementDesc) fd).setNillable(true);
- // [EMAIL PROTECTED] 2005-Mar-09: required
since Axis 1.2RC3 to allow for null values in complex objects; note that there
is no (JSR-181) annotation that allows configuring this value.
+ // [EMAIL PROTECTED] 2005-Mar-09: required since
Axis
+ // 1.2RC3 to allow for null values in complex
+ // objects; note that there is no (JSR-181)
+ // annotation that allows configuring this value.
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");
}
}
return q;
}
}
-
private static QName generateQName(Class type, ServiceDesc desc) {
String namespace = Namespaces.makeNamespace(type.getName());
- if (namespace == null || namespace
- .endsWith("DefaultNamespace")) {
+ if (namespace == null || namespace.endsWith("DefaultNamespace")) {
namespace = desc.getDefaultNamespace();
}
- return new QName(namespace,
- Types.getLocalNameFromFullName(type.getName()));
+ return new QName(namespace, Types.getLocalNameFromFullName(type
+ .getName()));
}
protected static void configureSoapBinding(ServiceDesc sd,
- BeehiveWsSOAPBindingInfo sbi) {
- javax.jws.soap.SOAPBinding.Style style
- = javax.jws.soap.SOAPBinding.Style.DOCUMENT;
- javax.jws.soap.SOAPBinding.Use use
- = javax.jws.soap.SOAPBinding.Use.LITERAL;
- javax.jws.soap.SOAPBinding.ParameterStyle paramStyle
- = javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED;
+ BeehiveWsSOAPBindingInfo sbi) {
+ javax.jws.soap.SOAPBinding.Style style =
javax.jws.soap.SOAPBinding.Style.DOCUMENT;
+ javax.jws.soap.SOAPBinding.Use use =
javax.jws.soap.SOAPBinding.Use.LITERAL;
+ javax.jws.soap.SOAPBinding.ParameterStyle paramStyle =
javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED;
if (sbi != null) {
style = sbi.getStyle();
use = sbi.getUse();
@@ -482,12 +490,11 @@
}
} else {
/*
- * since DOCUMENT ENCODED is not valid so
- * force to use LITERAL
+ * since DOCUMENT ENCODED is not valid so force to use LITERAL
*/
sd.setUse(Use.LITERAL);
- // check if this is a wrapped document literal
+ // check if this is a wrapped document literal
if (paramStyle ==
javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED) {
sd.setStyle(Style.WRAPPED);
} else {
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/registration/AxisTypeRegistrar.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/registration/AxisTypeRegistrar.java?view=diff&r1=158823&r2=158824
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/registration/AxisTypeRegistrar.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/registration/AxisTypeRegistrar.java
Wed Mar 23 11:57:57 2005
@@ -19,17 +19,18 @@
*/
package org.apache.beehive.wsm.axis.registration;
-
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.rmi.Remote;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import javax.xml.namespace.QName;
+import org.apache.axis.Constants;
import org.apache.axis.description.ElementDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.description.TypeDesc;
@@ -41,6 +42,7 @@
import org.apache.axis.encoding.ser.ArraySerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
+import org.apache.axis.types.HexBinary;
import org.apache.axis.utils.BeanPropertyDescriptor;
import org.apache.beehive.wsm.axis.util.encoding.XmlBeanDeserializerFactory;
import org.apache.beehive.wsm.axis.util.encoding.XmlBeanSerializerFactory;
@@ -50,170 +52,395 @@
import org.apache.log4j.Logger;
import org.apache.xmlbeans.XmlObject;
-
-
public class AxisTypeRegistrar extends TypeRegistrar {
- static Logger logger = Logger.getLogger(AxisTypeRegistrar.class);
-
-
+ static Logger logger = Logger.getLogger(AxisTypeRegistrar.class);
- public AxisTypeRegistrar(TypeMapping tm, BindingLookupService
lookupService) {
- super(tm, lookupService);
- }
-
-
- // Class cls = super.q2Class(qType);
- // if (Object.class.equals(cls) && mTypeMapping != null) {
- // cls = mTypeMapping.getClassForQName(qType);
- // return cls;
- // }
- // else {
- // return null;
- // }
- // }
-
- /**
- * @param cls
- * @param q
- */
- protected void registerClassAsWithDefaultSearialization(Class cls,
QName q) {
- logger.debug("Register class: " + cls.getCanonicalName() + "
qname:" + q);
- TypeDesc td = TypeDesc.getTypeDescForClass(cls); // a class
can provide its own descriptors
- TypeDesc superTd = null;
- BeanPropertyDescriptor[] superPd = null;
- if (null == td) {
- td = new TypeDesc(cls);
- Class supa = cls.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)) {
- registerType(supa);
- }
- superTd = TypeDesc.getTypeDescForClass(supa);
- if (superTd != null) {
- superPd = superTd.getPropertyDescriptors();
- }
- td.setXmlType(q);
- TypeDesc.registerTypeDescForClass(cls, td);
- } else {
- td = null;
- }
- mTypeMapping.register(cls, q, new BeanSerializerFactory(cls, q),
- /*
- * NOTE [EMAIL PROTECTED] 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(cls, q));
- Map serProps = BeanDeserializerFactory.getProperties(cls, null);
- for (BeanPropertyDescriptor beanProps :
(Collection<BeanPropertyDescriptor>) serProps
- .values()) {
- Class subType = beanProps.getType();
- if (!(subType.isPrimitive()
- ||
subType.getName().startsWith("java.") || subType
- .getName().startsWith("javax."))) {
- registerType(subType);
- }
- if (td != null) {
- String ns = q.getNamespaceURI();
- if (superTd != null && superPd != null) {
- for (int j = 0; j < superPd.length;
j++) {
- if
(beanProps.getName().equals(superPd[j].getName())) {
- ns =
superTd.getXmlType().getNamespaceURI();
- break;
- }
- }
- }
- FieldDesc fd = new ElementDesc();
- fd.setJavaType(subType);
- fd.setFieldName(beanProps.getName());
- fd.setXmlName(new QName(ns,
beanProps.getName()));
- // NOTE [EMAIL PROTECTED] 2004-Oct-28 -- might
- // need
- // to do more to ensure a useful type QName.
- fd.setXmlType(getRegisteredQName(subType));
- ((ElementDesc) fd).setNillable(true);
- // [EMAIL PROTECTED] 2005-Mar-09: required
since Axis 1.2RC3 to allow for null values in complex objects; note that there
is no (JSR-181) annotation that allows configuring this value.
-
- td.addFieldDesc(fd);
- }
- }
- }
-
- /**
- * @param cls
- * @param q
- */
- protected void registerClassAsXMLBeans(Class cls, QName q) {
- mTypeMapping.register(cls, q, new XmlBeanSerializerFactory(cls,
q),
- new XmlBeanDeserializerFactory(cls, q));
- }
-
- /**
- * @param cls
- * @param q
- * @throws ClassNotFoundException
- * @throws NoSuchMethodException
- * @throws InstantiationException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- protected void registerClassAsDataHandler(Class cls, QName q)
- throws ClassNotFoundException, NoSuchMethodException,
- InstantiationException, IllegalAccessException,
- InvocationTargetException {
- /*
- * NOTE [EMAIL PROTECTED] 2004-Oct-08 -- doing reflection here
in case
- * AXIS was built without attachment support.
- */
- ClassLoader cl = getClass().getClassLoader();
- Class<SerializerFactory> sfClass = (Class<SerializerFactory>) cl
-
.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory");
- Class<DeserializerFactory> dsfClass =
(Class<DeserializerFactory>) cl
-
.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory");
- Constructor<SerializerFactory> sfCon = sfClass.getConstructor(
- Class.class, QName.class);
- Constructor<DeserializerFactory> dsfCon =
dsfClass.getConstructor(
- Class.class, QName.class);
- SerializerFactory sf = sfCon.newInstance(cls, q);
- DeserializerFactory dsf = dsfCon.newInstance(cls, q);
- mTypeMapping.register(cls, q, sf, dsf);
- }
-
- /**
- * @param cls
- * @param q
- */
- protected void registerClassAsArray(Class cls, QName q) {
- mTypeMapping.register(cls, q, new ArraySerializerFactory(cls,
q),
- new ArrayDeserializerFactory());
- }
-
- /**
- * @param cls
- * @param q
- * @return
- */
- protected boolean classIsRegistered(Class cls, QName q) {
- return mTypeMapping.isRegistered(cls, q);
- }
-
-
- /**
- * @param cls
- * @return
- */
- protected QName getRegisteredQName(Class cls) {
- QName currentQName =
((org.apache.axis.encoding.TypeMapping)mTypeMapping).getTypeQName(cls);
- return currentQName;
- }
- /**
- * @return
- */
- public QName getVoidType() {
- return XMLType.AXIS_VOID;
-
- }
+ public AxisTypeRegistrar(TypeMapping tm, BindingLookupService
lookupService) {
+ super(tm, lookupService);
+ initBuildInTypes();
+
+ }
+
+
+ /**
+ * @param cls
+ * @return
+ */
+ protected boolean isBuiltInType(Class cls) {
+ return (builtInTypes.containsKey(cls));
+ }
+
+
+ // Class cls = super.q2Class(qType);
+ // if (Object.class.equals(cls) && mTypeMapping != null) {
+ // cls = mTypeMapping.getClassForQName(qType);
+ // return cls;
+ // }
+ // else {
+ // return null;
+ // }
+ // }
+
+ /**
+ * @param cls
+ * @param q
+ */
+ protected void registerClassAsWithDefaultSearialization(Class cls, QName
q) {
+ try {
+ logger.debug("Register class: " + cls.getCanonicalName()
+ + " qname:" + q);
+ TypeDesc td = TypeDesc.getTypeDescForClass(cls); // a class can
+ // provide its
+ // own
+ // descriptors
+ TypeDesc superTd = null;
+ BeanPropertyDescriptor[] superPd = null;
+ if (null == td) {
+ td = new TypeDesc(cls);
+ Class supa = cls.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)) {
+ registerType(supa);
+ superTd = TypeDesc.getTypeDescForClass(supa);
+ if (superTd != null) {
+ superPd = superTd.getPropertyDescriptors();
+ }
+ }
+ td.setXmlType(q);
+ TypeDesc.registerTypeDescForClass(cls, td);
+ } else {
+ td = null;
+ }
+ mTypeMapping.register(cls, q, new BeanSerializerFactory(cls, q),
+ /*
+ * NOTE [EMAIL PROTECTED] 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(cls, q));
+ Map serProps = BeanDeserializerFactory.getProperties(cls, null);
+ for (BeanPropertyDescriptor beanProps :
(Collection<BeanPropertyDescriptor>) serProps
+ .values()) {
+ Class subType = beanProps.getType();
+ if (!(subType.isPrimitive()
+ || subType.getName().startsWith("java.") || subType
+ .getName().startsWith("javax."))) {
+ registerType(subType);
+ }
+ if (td != null) {
+ String ns = q.getNamespaceURI();
+ if (superTd != null && superPd != null) {
+ for (int j = 0; j < superPd.length; j++) {
+ if (beanProps.getName()
+ .equals(superPd[j].getName())) {
+ ns = superTd.getXmlType().getNamespaceURI();
+ break;
+ }
+ }
+ }
+ FieldDesc fd = new ElementDesc();
+ fd.setJavaType(subType);
+ fd.setFieldName(beanProps.getName());
+ fd.setXmlName(new QName(ns, beanProps.getName()));
+ // NOTE [EMAIL PROTECTED] 2004-Oct-28 -- might
+ // need
+ // to do more to ensure a useful type QName.
+ fd.setXmlType(getRegisteredQName(subType));
+ ((ElementDesc) fd).setNillable(true);
+ // [EMAIL PROTECTED] 2005-Mar-09: required since Axis
1.2RC3
+ // to allow for null values in complex objects; note that
+ // there is no (JSR-181) annotation that allows configuring
+ // this value.
+
+ td.addFieldDesc(fd);
+ }
+ }
+ } catch (RuntimeException e) {
+ logger.error("Error in registering class: "
+ + cls.getCanonicalName() + " qname:" + q);
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ /**
+ * @param cls
+ * @param q
+ */
+ protected void registerClassAsXMLBeans(Class cls, QName q) {
+ mTypeMapping.register(cls, q, new XmlBeanSerializerFactory(cls, q),
+ new XmlBeanDeserializerFactory(cls, q));
+ }
+
+ /**
+ * @param cls
+ * @param q
+ * @throws ClassNotFoundException
+ * @throws NoSuchMethodException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws InvocationTargetException
+ */
+ protected void registerClassAsDataHandler(Class cls, QName q)
+ throws ClassNotFoundException, NoSuchMethodException,
+ InstantiationException, IllegalAccessException,
+ InvocationTargetException {
+ /*
+ * NOTE [EMAIL PROTECTED] 2004-Oct-08 -- doing reflection here in case
+ * AXIS was built without attachment support.
+ */
+ ClassLoader cl = getClass().getClassLoader();
+ Class<SerializerFactory> sfClass = (Class<SerializerFactory>) cl
+
.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory");
+ Class<DeserializerFactory> dsfClass = (Class<DeserializerFactory>) cl
+
.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory");
+ Constructor<SerializerFactory> sfCon = sfClass.getConstructor(
+ Class.class, QName.class);
+ Constructor<DeserializerFactory> dsfCon = dsfClass.getConstructor(
+ Class.class, QName.class);
+ SerializerFactory sf = sfCon.newInstance(cls, q);
+ DeserializerFactory dsf = dsfCon.newInstance(cls, q);
+ mTypeMapping.register(cls, q, sf, dsf);
+ }
+
+ /**
+ * @param cls
+ * @param q
+ */
+ protected void registerClassAsArray(Class cls, QName q) {
+ mTypeMapping.register(cls, q, new ArraySerializerFactory(cls, q),
+ new ArrayDeserializerFactory());
+ }
+
+ /**
+ * @param cls
+ * @param q
+ * @return
+ */
+ protected boolean classIsRegistered(Class cls, QName q) {
+ return mTypeMapping.isRegistered(cls, q);
+ }
+
+ /**
+ * @param cls
+ * @return
+ */
+ protected QName getRegisteredQName(Class cls) {
+ QName currentQName = ((org.apache.axis.encoding.TypeMapping)
mTypeMapping)
+ .getTypeQName(cls);
+ return currentQName;
+ }
+
+ /**
+ * @return
+ */
+ public QName getVoidType() {
+ return XMLType.AXIS_VOID;
+
+ }
+
+
+ Map<Class, QName> builtInTypes = new HashMap<Class, QName>();
+
+ /**
+ *
+ */
+ private void initBuildInTypes() {
+ // HexBinary binary data needs to use the hex binary
+ // serializer/deserializer
+ addBuiltInType(Constants.XSD_HEXBIN, HexBinary.class);
+ addBuiltInType(Constants.XSD_HEXBIN, byte[].class);
+
+ addBuiltInType(Constants.XSD_BYTE, byte[].class);
+
+ addBuiltInType(Constants.XSD_BASE64, byte[].class);
+
+ // anySimpleType is mapped to java.lang.String according to JAX-RPC 1.1
+ // spec.
+ addBuiltInType(Constants.XSD_ANYSIMPLETYPE, java.lang.String.class);
+
+ // If SOAP 1.1 over the wire, map wrapper classes to XSD primitives.
+ addBuiltInType(Constants.XSD_STRING, java.lang.String.class);
+ addBuiltInType(Constants.XSD_BOOLEAN, java.lang.Boolean.class);
+ addBuiltInType(Constants.XSD_DOUBLE, java.lang.Double.class);
+ addBuiltInType(Constants.XSD_FLOAT, java.lang.Float.class);
+ addBuiltInType(Constants.XSD_INT, java.lang.Integer.class);
+ addBuiltInType(Constants.XSD_INTEGER, java.math.BigInteger.class);
+ addBuiltInType(Constants.XSD_DECIMAL, java.math.BigDecimal.class);
+ addBuiltInType(Constants.XSD_LONG, java.lang.Long.class);
+ addBuiltInType(Constants.XSD_SHORT, java.lang.Short.class);
+ addBuiltInType(Constants.XSD_BYTE, java.lang.Byte.class);
+
+ // The XSD Primitives are mapped to java primitives.
+ addBuiltInType(Constants.XSD_BOOLEAN, boolean.class);
+ addBuiltInType(Constants.XSD_DOUBLE, double.class);
+ addBuiltInType(Constants.XSD_FLOAT, float.class);
+ addBuiltInType(Constants.XSD_INT, int.class);
+ addBuiltInType(Constants.XSD_LONG, long.class);
+ addBuiltInType(Constants.XSD_SHORT, short.class);
+ addBuiltInType(Constants.XSD_BYTE, byte.class);
+
+ // Map QNAME to the jax rpc QName class
+ addBuiltInType(Constants.XSD_QNAME, javax.xml.namespace.QName.class);
+
+ // The closest match for anytype is Object
+ addBuiltInType(Constants.XSD_ANYTYPE, java.lang.Object.class);
+
+ // See the SchemaVersion classes for where the registration of
+ // dateTime (for 2001) and timeInstant (for 1999 & 2000) happen.
+ addBuiltInType(Constants.XSD_DATE, java.sql.Date.class);
+
+ // See the SchemaVersion classes for where the registration of
+ // dateTime (for 2001) and timeInstant (for 1999 & 2000) happen.
+ addBuiltInType(Constants.XSD_DATE, java.util.Date.class);
+
+ // Mapping for xsd:time. Map to Axis type Time
+ addBuiltInType(Constants.XSD_TIME, org.apache.axis.types.Time.class);
+ // These are the g* types (gYearMonth, etc) which map to Axis types
+ addBuiltInType(Constants.XSD_YEARMONTH,
+ org.apache.axis.types.YearMonth.class);
+ addBuiltInType(Constants.XSD_YEAR, org.apache.axis.types.Year.class);
+ addBuiltInType(Constants.XSD_MONTH, org.apache.axis.types.Month.class);
+ addBuiltInType(Constants.XSD_DAY, org.apache.axis.types.Day.class);
+ addBuiltInType(Constants.XSD_MONTHDAY,
+ org.apache.axis.types.MonthDay.class);
+
+ // Serialize all extensions of Map to SOAP_MAP
+ // Order counts here, HashMap should be last.
+ addBuiltInType(Constants.SOAP_MAP, java.util.Hashtable.class);
+ addBuiltInType(Constants.SOAP_MAP, java.util.Map.class);
+ // The SOAP_MAP will be deserialized into a HashMap by default.
+ addBuiltInType(Constants.SOAP_MAP, java.util.HashMap.class);
+
+ // Use the Element Serializeration for elements
+ addBuiltInType(Constants.SOAP_ELEMENT, org.w3c.dom.Element.class);
+
+ // Use the Document Serializeration for Document's
+ addBuiltInType(Constants.SOAP_DOCUMENT, org.w3c.dom.Document.class);
+
+ addBuiltInType(Constants.SOAP_VECTOR, java.util.Vector.class);
+
+ // if (JavaUtils.isAttachmentSupported()) {
+ // addBuiltInType(Constants.MIME_IMAGE, java.awt.Image.class);
+ // addBuiltInType(Constants.MIME_MULTIPART,
+ // javax.mail.internet.MimeMultipart.class);
+ // addBuiltInType(Constants.MIME_SOURCE,
+ // javax.xml.transform.Source.class);
+ // addBuiltInType(Constants.MIME_OCTETSTREAM, OctetStream.class);
+ // addBuiltInType(Constants.MIME_DATA_HANDLER,
+ // javax.activation.DataHandler.class);
+ // }
+
+ // xsd:token
+ addBuiltInType(Constants.XSD_TOKEN, org.apache.axis.types.Token.class);
+
+ // a xsd:normalizedString
+ addBuiltInType(Constants.XSD_NORMALIZEDSTRING,
+ org.apache.axis.types.NormalizedString.class);
+
+ // a xsd:unsignedLong
+ addBuiltInType(Constants.XSD_UNSIGNEDLONG,
+ org.apache.axis.types.UnsignedLong.class);
+
+ // a xsd:unsignedInt
+ addBuiltInType(Constants.XSD_UNSIGNEDINT,
+ org.apache.axis.types.UnsignedInt.class);
+
+ // a xsd:unsignedShort
+ addBuiltInType(Constants.XSD_UNSIGNEDSHORT,
+ org.apache.axis.types.UnsignedShort.class);
+
+ // a xsd:unsignedByte
+ addBuiltInType(Constants.XSD_UNSIGNEDBYTE,
+ org.apache.axis.types.UnsignedByte.class);
+
+ // a xsd:nonNegativeInteger
+ addBuiltInType(Constants.XSD_NONNEGATIVEINTEGER,
+ org.apache.axis.types.NonNegativeInteger.class);
+
+ // a xsd:negativeInteger
+ addBuiltInType(Constants.XSD_NEGATIVEINTEGER,
+ org.apache.axis.types.NegativeInteger.class);
+
+ // a xsd:positiveInteger
+ addBuiltInType(Constants.XSD_POSITIVEINTEGER,
+ org.apache.axis.types.PositiveInteger.class);
+
+ // a xsd:nonPositiveInteger
+ addBuiltInType(Constants.XSD_NONPOSITIVEINTEGER,
+ org.apache.axis.types.NonPositiveInteger.class);
+
+ // a xsd:Name
+ addBuiltInType(Constants.XSD_NAME, org.apache.axis.types.Name.class);
+
+ // a xsd:NCName
+ addBuiltInType(Constants.XSD_NCNAME,
org.apache.axis.types.NCName.class);
+
+ // a xsd:ID
+ addBuiltInType(Constants.XSD_ID, org.apache.axis.types.Id.class);
+
+ // a xml:lang
+ addBuiltInType(Constants.XML_LANG,
org.apache.axis.types.Language.class);
+
+ // a xsd:language
+ addBuiltInType(Constants.XSD_LANGUAGE,
+ org.apache.axis.types.Language.class);
+
+ // a xsd:NmToken
+ addBuiltInType(Constants.XSD_NMTOKEN,
+ org.apache.axis.types.NMToken.class);
+
+ // a xsd:NmTokens
+ addBuiltInType(Constants.XSD_NMTOKENS,
+ org.apache.axis.types.NMTokens.class);
+
+ // a xsd:NOTATION
+ addBuiltInType(Constants.XSD_NOTATION,
+ org.apache.axis.types.Notation.class);
+
+ // a xsd:XSD_ENTITY
+ addBuiltInType(Constants.XSD_ENTITY,
org.apache.axis.types.Entity.class);
+
+ // a xsd:XSD_ENTITIES
+ addBuiltInType(Constants.XSD_ENTITIES,
+ org.apache.axis.types.Entities.class);
+
+ // a xsd:XSD_IDREF
+ addBuiltInType(Constants.XSD_IDREF, org.apache.axis.types.IDRef.class);
+
+ // a xsd:XSD_XSD_IDREFS
+ addBuiltInType(Constants.XSD_IDREFS,
org.apache.axis.types.IDRefs.class);
+
+ // a xsd:Duration
+ addBuiltInType(Constants.XSD_DURATION,
+ org.apache.axis.types.Duration.class);
+
+ // a xsd:anyURI
+ addBuiltInType(Constants.XSD_ANYURI, org.apache.axis.types.URI.class);
+
+ // a xsd:schema
+ addBuiltInType(Constants.XSD_SCHEMA,
org.apache.axis.types.Schema.class);
+
+ addBuiltInType(Constants.SOAP_ARRAY, java.util.ArrayList.class);
+ }
+
+ /**
+ * @param xsd_hexbin
+ * @param name
+ */
+ private void addBuiltInType(QName q, Class c) {
+ builtInTypes.put(c, q);
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.apache.beehive.wsm.registration.TypeRegistrar#getBuiltInTypeQname(java.lang.Class)
+ */
+ protected QName getBuiltInTypeQname(Class cls) {
+ return builtInTypes.get(cls);
+ }
}
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsMethodMetadata.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsMethodMetadata.java?view=diff&r1=158823&r2=158824
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsMethodMetadata.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsMethodMetadata.java
Wed Mar 23 11:57:57 2005
@@ -17,6 +17,7 @@
*/
package org.apache.beehive.wsm.jsr181.model;
+
import java.util.List;
import javax.xml.namespace.QName;
@@ -47,6 +48,7 @@
List<BeehiveWsParameterMetadata> getParams();
void addParam(BeehiveWsParameterMetadata parameter);
void addParams(List<? extends BeehiveWsParameterMetadata> parameters);
+ BeehiveWsParameterMetadata findParam(String parmName);
String getJavaMethodName();
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java?view=diff&r1=158823&r2=158824
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java
Wed Mar 23 11:57:57 2005
@@ -356,4 +356,21 @@
this.javaReturnType = javaType;
}
+
+ /* (non-Javadoc)
+ * @see
org.apache.beehive.wsm.jsr181.model.BeehiveWsMethodMetadata#findParam(java.lang.String)
+ */
+ public BeehiveWsParameterMetadata findParam(String parmName) {
+ // walk the list of parameters until the parameter with paramName is
found
+ // there are small number of parameters, so walking the list should be
ok
+ if( null == parmName) return null;
+ BeehiveWsParameterMetadata res = null;
+ for(BeehiveWsParameterMetadata nxtParam : params) {
+ if( parmName.equals(nxtParam.getWpName())) {
+ res = nxtParam;
+ break;
+ }
+ }
+ return res;
+ }
}