You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2007/12/05 03:04:53 UTC
svn commit: r601187 [1/2] - in
/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis:
./ assembler/
Author: dain
Date: Tue Dec 4 18:04:51 2007
New Revision: 601187
URL: http://svn.apache.org/viewvc?rev=601187&view=rev
Log:
Added info objects for jaxrpc xml schema types and split building logic from use
Added:
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaInfoBuilder.java
- copied, changed from r600745, openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/SchemaInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaLoader.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlNestedElementInfo.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlSchemaInfo.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlTypeInfo.java
Removed:
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/SchemaInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/SchemaTypeKey.java
Modified:
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcServiceInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java?rev=601187&r1=601186&r2=601187&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java Tue Dec 4 18:04:51 2007
@@ -22,17 +22,23 @@
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.jee.JavaWsdlMapping;
+import org.apache.openejb.jee.PortComponent;
import org.apache.openejb.core.webservices.HandlerChainData;
import org.apache.openejb.core.webservices.HandlerData;
import org.apache.openejb.core.webservices.PortData;
import org.apache.openejb.server.axis.assembler.JaxRpcServiceInfo;
import org.apache.openejb.server.axis.assembler.JaxRpcServiceInfoBuilder;
+import org.apache.openejb.server.axis.assembler.XmlBeansSchemaInfoBuilder;
+import org.apache.openejb.server.axis.assembler.XmlSchemaInfo;
import org.apache.openejb.server.httpd.HttpListener;
import org.apache.openejb.server.webservices.WsService;
import javax.naming.Context;
import javax.xml.namespace.QName;
import javax.xml.rpc.handler.HandlerInfo;
+import javax.wsdl.Port;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -47,12 +53,25 @@
return "axis";
}
+ private JaxRpcServiceInfo getJaxRpcServiceInfo(ClassLoader classLoader) throws OpenEJBException {
+ JavaWsdlMapping mapping = null; // the java to wsdl mapping file
+ XmlBeansSchemaInfoBuilder xmlBeansSchemaInfoBuilder = new XmlBeansSchemaInfoBuilder(null, null); // the schema data from the wsdl file
+ PortComponent portComponent = null; // webservice.xml declaration of this service
+ Port port = null; // wsdl.xml declaration of this service
+ String wsdlFile = null;
+
+ XmlSchemaInfo schemaInfo = xmlBeansSchemaInfoBuilder.createSchemaInfo();
+
+ JaxRpcServiceInfoBuilder serviceInfoBuilder = new JaxRpcServiceInfoBuilder(mapping, schemaInfo, portComponent, port, wsdlFile, classLoader);
+ JaxRpcServiceInfo serviceInfo = serviceInfoBuilder.createServiceInfo();
+ return serviceInfo;
+ }
+
protected HttpListener createEjbWsContainer(URL moduleBaseUrl, PortData port, DeploymentInfo deploymentInfo) throws Exception {
ClassLoader classLoader = deploymentInfo.getClassLoader();
// todo build JaxRpcServiceInfo in assembler
- JaxRpcServiceInfoBuilder serviceInfoBuilder = new JaxRpcServiceInfoBuilder(null, null, null, null, null, classLoader);
- JaxRpcServiceInfo serviceInfo = serviceInfoBuilder.createServiceDesc();
+ JaxRpcServiceInfo serviceInfo = getJaxRpcServiceInfo(classLoader);
// Build java service descriptor
JavaServiceDescBuilder javaServiceDescBuilder = new JavaServiceDescBuilder(serviceInfo, classLoader);
@@ -84,8 +103,7 @@
ClassLoader classLoader = target.getClassLoader();
// todo build JaxRpcServiceInfo in assembler
- JaxRpcServiceInfoBuilder serviceInfoBuilder = new JaxRpcServiceInfoBuilder(null, null, null, null, null, classLoader);
- JaxRpcServiceInfo serviceInfo = serviceInfoBuilder.createServiceDesc();
+ JaxRpcServiceInfo serviceInfo = getJaxRpcServiceInfo(classLoader);
// Build java service descriptor
JavaServiceDescBuilder javaServiceDescBuilder = new JavaServiceDescBuilder(serviceInfo, classLoader);
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java?rev=601187&r1=601186&r2=601187&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java Tue Dec 4 18:04:51 2007
@@ -28,9 +28,6 @@
import org.apache.openejb.jee.WsdlMessageMapping;
import org.apache.openejb.jee.WsdlReturnValueMapping;
import static org.apache.openejb.server.axis.assembler.JaxRpcParameterInfo.Mode;
-import org.apache.xmlbeans.SchemaParticle;
-import org.apache.xmlbeans.SchemaProperty;
-import org.apache.xmlbeans.SchemaType;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
@@ -80,7 +77,7 @@
private final JavaWsdlMapping mapping;
private final ServiceEndpointMethodMapping methodMapping;
- private final SchemaInfoBuilder schemaInfoBuilder;
+ private final XmlSchemaInfo schemaInfo;
private final BindingStyle bindingStyle;
//
@@ -109,7 +106,7 @@
private JaxRpcOperationInfo operationInfo;
- public HeavyweightOperationInfoBuilder(BindingOperation bindingOperation, ServiceEndpointMethodMapping methodMapping, JavaWsdlMapping mapping, SchemaInfoBuilder schemaInfoBuilder) throws OpenEJBException {
+ public HeavyweightOperationInfoBuilder(BindingOperation bindingOperation, ServiceEndpointMethodMapping methodMapping, JavaWsdlMapping mapping, XmlSchemaInfo schemaInfo) throws OpenEJBException {
Operation operation = bindingOperation.getOperation();
this.operationName = operation.getName();
this.operationStyle = JaxRpcOperationInfo.OperationStyle.valueOf(operation.getStyle().toString());
@@ -123,7 +120,7 @@
this.mapping = mapping;
this.methodMapping = methodMapping;
- this.schemaInfoBuilder = schemaInfoBuilder;
+ this.schemaInfo = schemaInfo;
// index types - used to process build exception class constructor args
for (JavaXmlTypeMapping javaXmlTypeMapping : mapping.getJavaXmlTypeMapping()) {
@@ -143,14 +140,14 @@
} else {
BindingInput bindingInput = bindingOperation.getBindingInput();
- SOAPOperation soapOperation = SchemaInfoBuilder.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
+ SOAPOperation soapOperation = JaxRpcServiceInfoBuilder.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
String styleString = soapOperation.getStyle();
if (styleString == null) {
- SOAPBinding soapBinding = SchemaInfoBuilder.getExtensibilityElement(SOAPBinding.class, bindingInput.getExtensibilityElements());
+ SOAPBinding soapBinding = JaxRpcServiceInfoBuilder.getExtensibilityElement(SOAPBinding.class, bindingInput.getExtensibilityElements());
styleString = soapBinding.getStyle();
}
- SOAPBody soapBody = SchemaInfoBuilder.getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
+ SOAPBody soapBody = JaxRpcServiceInfoBuilder.getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
String useString = soapBody.getUse();
bindingStyle = BindingStyle.getBindingStyle(styleString, useString);
@@ -195,22 +192,10 @@
if (outputMessage != null && bindingStyle.isWrapped()) {
Part inputPart = getWrappedPart(outputMessage);
QName name = inputPart.getElementName();
- SchemaType operationType = schemaInfoBuilder.getComplexTypesInWsdl().get(name);
Set<String> expectedOutParams = new HashSet<String>();
-
- // schemaType should be complex using xsd:sequence compositor
- SchemaParticle parametersType = operationType.getContentModel();
- //again, no output can give null parametersType
- if (parametersType != null) {
- if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
- expectedOutParams.add(parametersType.getName().getLocalPart());
- } else if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
- SchemaParticle[] parameters = parametersType.getParticleChildren();
- for (SchemaParticle parameter : parameters) {
- expectedOutParams.add(parameter.getName().getLocalPart());
- }
- }
+ for (XmlNestedElementInfo expectedOutParam : schemaInfo.types.get(name).nestedElements.values()) {
+ expectedOutParams.add(expectedOutParam.qname.getLocalPart());
}
if (!outParamNames.equals(expectedOutParams)) {
throw new OpenEJBException("Not all wrapper children were mapped to parameters or a return value for operation " + operationName);
@@ -261,28 +246,10 @@
// verify that all child elements have a parameter mapping
Part inputPart = getWrappedPart(inputMessage);
QName name = inputPart.getElementName();
- SchemaType operationType = schemaInfoBuilder.getComplexTypesInWsdl().get(name);
Set<String> expectedInParams = new HashSet<String>();
-
- // schemaType should be complex using xsd:sequence compositor
- SchemaParticle parametersType = operationType.getContentModel();
-
- // parametersType can be null if the element has empty content such as
- // <element name="getMarketSummary">
- // <complexType>
- // <sequence/>
- // </complexType>
- // </element>
- if (parametersType != null) {
- if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
- expectedInParams.add(parametersType.getName().getLocalPart());
- } else if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
- SchemaParticle[] parameters = parametersType.getParticleChildren();
- for (SchemaParticle parameter : parameters) {
- expectedInParams.add(parameter.getName().getLocalPart());
- }
- }
+ for (XmlNestedElementInfo expectedInParam : schemaInfo.types.get(name).nestedElements.values()) {
+ expectedInParams.add(expectedInParam.qname.getLocalPart());
}
if (!inParamNames.equals(expectedInParams)) {
throw new OpenEJBException("Not all wrapper children were mapped for operation name" + operationName);
@@ -322,7 +289,7 @@
}
Part part = null;
- SchemaParticle inParameter = null;
+ XmlNestedElementInfo inParameter = null;
if (bindingStyle.isWrapped()) {
Part inPart = getWrappedPart(inputMessage);
// the local name of the global element refered by the part is equal to the operation name
@@ -333,8 +300,8 @@
}
inParameter = getWrapperChild(inPart, wsdlMessagePartName);
- paramQName = new QName("", inParameter.getName().getLocalPart());
- paramXmlType = inParameter.getType().getName();
+ paramQName = new QName("", inParameter.qname.getLocalPart());
+ paramXmlType = inParameter.xmlType;
} else if (bindingStyle.isRpc()) {
part = inputMessage.getPart(wsdlMessagePartName);
if (part == null) {
@@ -361,8 +328,8 @@
if (bindingStyle.isWrapped()) {
// Verify output message supports this inout parameter
Part outPart = getWrappedPart(outputMessage);
- SchemaParticle outParameter = getWrapperChild(outPart, wsdlMessagePartName);
- if (inParameter.getType() != outParameter.getType()) {
+ XmlNestedElementInfo outParameter = getWrapperChild(outPart, wsdlMessagePartName);
+ if (inParameter.xmlType != outParameter.xmlType) {
throw new OpenEJBException("The wrapper children " + wsdlMessagePartName + " do not have the same type for operation " + operationName);
}
} else if (bindingStyle.isRpc()) {
@@ -403,10 +370,10 @@
if (bindingStyle.isWrapped()) {
Part outPart = getWrappedPart(outputMessage);
- SchemaParticle outParameter = getWrapperChild(outPart, wsdlMessagePartName);
+ XmlNestedElementInfo outParameter = getWrapperChild(outPart, wsdlMessagePartName);
- paramQName = new QName("", outParameter.getName().getLocalPart());
- paramXmlType = outParameter.getType().getName();
+ paramQName = new QName("", outParameter.qname.getLocalPart());
+ paramXmlType = outParameter.xmlType;
} else if (bindingStyle.isRpc()) {
Part part = outputMessage.getPart(wsdlMessagePartName);
if (part == null) {
@@ -441,13 +408,9 @@
// holderClass == ${packageName}.holders.${typeName}Holder
String packageName;
String typeName;
- if (schemaInfoBuilder.getComplexTypesInWsdl().containsKey(paramXmlType)) {
- // This is a complex type, so package name is determined from namespace mapping
- String namespace = paramXmlType.getNamespaceURI();
- PackageMapping packageMapping = mapping.getPackageMappingMap().get(namespace);
- if (packageMapping == null) {
- throw new OpenEJBException("Namespace " + namespace + " was not mapped in jaxrpc mapping file");
- }
+
+ PackageMapping packageMapping = mapping.getPackageMappingMap().get(paramXmlType.getNamespaceURI());
+ if (packageMapping != null) {
packageName = packageMapping.getPackageType();
// Type name is typeQName local part, but make sure it is capitalized correctly
@@ -501,10 +464,10 @@
if (bindingStyle.isWrapped()) {
Part outPart = getWrappedPart(outputMessage);
- SchemaParticle returnParticle = getWrapperChild(outPart, wsdlMessagePartName);
+ XmlNestedElementInfo returnParticle = getWrapperChild(outPart, wsdlMessagePartName);
- returnQName = new QName("", returnParticle.getName().getLocalPart());
- returnXmlType = returnParticle.getType().getName();
+ returnQName = new QName("", returnParticle.qname.getLocalPart());
+ returnXmlType = returnParticle.xmlType;
} else if (bindingStyle.isRpc()) {
Part part = outputMessage.getPart(wsdlMessagePartName);
if (part == null) {
@@ -554,88 +517,82 @@
// Determine the fault qname and xml schema type
QName faultQName;
- QName faultXmlType;
+ XmlTypeInfo faultTypeInfo;
if (part.getElementName() == null) {
- faultQName = new QName("", fault.getName());
- faultXmlType = part.getTypeName();
- if (faultXmlType == null) {
+ if (part.getTypeName() == null) {
throw new OpenEJBException("Neither type nor element name supplied for part: " + part);
}
+ faultQName = new QName("", fault.getName());
+ faultTypeInfo = schemaInfo.types.get(part.getTypeName());
} else {
faultQName = part.getElementName();
- faultXmlType = schemaInfoBuilder.getElementToTypeMap().get(part.getElementName());
- if (faultXmlType == null) {
- throw new OpenEJBException("Can not find type for: element: " + part.getElementName() + ", known elements: " + schemaInfoBuilder.getElementToTypeMap());
- }
+ faultTypeInfo = schemaInfo.types.get(part.getElementName());
}
- // Get the xml schema declaration of the type
- SchemaType complexType = schemaInfoBuilder.getComplexTypesInWsdl().get(faultXmlType);
+ if (faultTypeInfo == null) {
+ throw new OpenEJBException("Can not find type for: element: " + part.getElementName() + ", known elements: " + schemaInfo.types.keySet());
+ }
//
// Build the fault info
//
JaxRpcFaultInfo faultInfo = new JaxRpcFaultInfo();
faultInfo.qname = faultQName;
- faultInfo.xmlType = faultXmlType;
+ faultInfo.xmlType = faultTypeInfo.xmlType;
faultInfo.javaType = exceptionMapping.getExceptionType();
- faultInfo.complex = complexType != null;
+ faultInfo.complex = !faultTypeInfo.simpleType;
//
// Map exception class constructor args
//
if (exceptionMapping.getConstructorParameterOrder() != null) {
if (!faultInfo.complex) {
- throw new OpenEJBException("ConstructorParameterOrder can only be set for complex types, not " + faultXmlType);
+ throw new OpenEJBException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeInfo.xmlType);
}
- // Map xmlType properties by name
- Map<String,SchemaType> elementMap = new HashMap<String,SchemaType>();
- SchemaProperty[] properties = complexType.getProperties();
- for (SchemaProperty property : properties) {
- QName elementName = property.getName();
- SchemaType elementType = property.getType();
- elementMap.put(elementName.getLocalPart(), elementType);
+ Map<String, XmlNestedElementInfo> elements = new HashMap<String, XmlNestedElementInfo>();
+ for (XmlNestedElementInfo element : faultTypeInfo.nestedElements.values()) {
+ elements.put(element.qname.getLocalPart(), element);
}
ConstructorParameterOrder constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
for (int i = 0; i < constructorParameterOrder.getElementName().size(); i++) {
String elementName = constructorParameterOrder.getElementName().get(i);
- SchemaType elementType = elementMap.get(elementName);
- QName argXmlType = elementType.getName();
+ XmlNestedElementInfo elementType = elements.get(elementName);
+ QName argXmlType = elementType.qname;
// Determine argument java type
String argJavaType;
if (argXmlType != null) {
- if (schemaInfoBuilder.getComplexTypesInWsdl().containsKey(argXmlType)) {
- // Complex type, so java type mapping must be declared
- argJavaType= publicTypes.get(argXmlType);
- if (argJavaType == null) {
- throw new OpenEJBException("No class mapped for element type: " + elementType);
- }
- } else {
+ if (elementType.simpleType) {
// Simple type with a spec defined java class mapping
argJavaType = qnameToJavaType.get(argXmlType);
if (argJavaType == null) {
throw new OpenEJBException("Unknown type: " + elementType + " of name: " + elementName + " and QName: " + argXmlType);
}
+ } else {
+ // Complex type, so java type mapping must be declared
+ argJavaType= publicTypes.get(argXmlType);
+ if (argJavaType == null) {
+ throw new OpenEJBException("No class mapped for element type: " + elementType);
+ }
}
} else {
// anonymous type
// qname is constructed using rules 1.b and 2.b
- String anonymousQName = complexType.getName().getNamespaceURI() + ":>" + complexType.getName().getLocalPart() + ">" + elementName;
+ String anonymousQName = faultTypeInfo.xmlType.getNamespaceURI() + ":>" + faultTypeInfo.xmlType.getLocalPart() + ">" + elementName;
// Check for a declared type mapping for this anonymous type
argJavaType = anonymousTypes.get(anonymousQName);
if (argJavaType == null) {
// this must be a simple type...
- if (!elementType.isSimpleType()) {
+ if (!elementType.simpleType) {
throw new OpenEJBException("No class mapped for anonymous type: " + anonymousQName);
}
// and must have a spec defined java class mapping
- QName simpleTypeQName = elementType.getBaseType().getName();
+ QName simpleTypeQName = elementType.baseType;
argJavaType = qnameToJavaType.get(simpleTypeQName);
if (argJavaType == null) {
throw new OpenEJBException("Unknown simple type: " + elementType + " of name: " + elementName + " and QName: " + simpleTypeQName);
@@ -645,7 +602,7 @@
JaxRpcParameterInfo parameterInfo = new JaxRpcParameterInfo();
// todo faultTypeQName is speculative
- parameterInfo.qname = faultXmlType;
+ parameterInfo.qname = faultTypeInfo.xmlType;
parameterInfo.mode = Mode.OUT;
// todo could be a soap header
parameterInfo.soapHeader = false;
@@ -674,42 +631,23 @@
return (Part) parts.iterator().next();
}
- private SchemaParticle getWrapperChild(Part part, String wsdlMessagePartName) throws OpenEJBException {
+ private XmlNestedElementInfo getWrapperChild(Part part, String wsdlMessagePartName) throws OpenEJBException {
// get the part name
QName name = part.getElementName();
wrapperElementQNames.add(name);
// get the part type
- SchemaType operationType = schemaInfoBuilder.getComplexTypesInWsdl().get(name);
- if (operationType == null) {
+ XmlTypeInfo operationTypeInfo = schemaInfo.types.get(name);
+ if (operationTypeInfo == null) {
throw new OpenEJBException("No global element named " + name + " for operation " + operationName);
}
- SchemaParticle parametersType = operationType.getContentModel();
- // if this is a plain element, the type is the part type
- if (parametersType.getParticleType() == SchemaParticle.ELEMENT) {
- // verify qname matches expected message part name
- if (!parametersType.getName().getLocalPart().equals(wsdlMessagePartName)) {
- throw new OpenEJBException("Global element named " + name + " does not define a child element named " + wsdlMessagePartName + " required by the operation " + operationName);
- }
- return parametersType;
- }
-
- // if this is a sequence, find the element in the sequence with the specified wsdlMessagePartName
- if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
- for (SchemaParticle parameter : parametersType.getParticleChildren()) {
- QName element = parameter.getName();
- if (element.getLocalPart().equals(wsdlMessagePartName)) {
- return parameter;
- }
+ for (XmlNestedElementInfo element : operationTypeInfo.nestedElements.values()) {
+ if (element.qname.getLocalPart().equals(wsdlMessagePartName)) {
+ return element;
}
-
- throw new OpenEJBException("Global element named " + name +
- " does not define a child element named " + wsdlMessagePartName +
- " required by the operation " + operationName);
}
-
- throw new OpenEJBException("Global element named " + name + " is not a sequence for operation " + operationName);
+ throw new OpenEJBException("Global element named " + name + " does not define a child element named " + wsdlMessagePartName + " required by the operation " + operationName);
}
//see jaxrpc 1.1 4.2.1
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java?rev=601187&r1=601186&r2=601187&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java Tue Dec 4 18:04:51 2007
@@ -24,12 +24,6 @@
import org.apache.openejb.jee.JavaXmlTypeMapping;
import org.apache.openejb.jee.VariableMapping;
import static org.apache.openejb.server.axis.assembler.JaxRpcTypeInfo.SerializerType;
-import org.apache.xmlbeans.SchemaLocalAttribute;
-import org.apache.xmlbeans.SchemaParticle;
-import org.apache.xmlbeans.SchemaProperty;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.soap.SOAPArrayType;
-import org.apache.xmlbeans.soap.SchemaWSDLArrayType;
import javax.xml.namespace.QName;
import java.beans.IntrospectionException;
@@ -55,15 +49,15 @@
private final JavaWsdlMapping mapping;
private final ClassLoader classLoader;
- private final Map<SchemaTypeKey, SchemaType> schemaTypeKeyToSchemaTypeMap;
+ private final XmlSchemaInfo schemaInfo;
private final Set wrapperElementQNames;
private final Collection<JaxRpcOperationInfo> operations;
private final boolean hasEncoded;
- public HeavyweightTypeInfoBuilder(JavaWsdlMapping mapping, Map<SchemaTypeKey, SchemaType> schemaTypeKeyToSchemaTypeMap, ClassLoader classLoader, Set wrapperElementQNames, Collection<JaxRpcOperationInfo> operations, boolean hasEncoded) {
+ public HeavyweightTypeInfoBuilder(JavaWsdlMapping mapping, XmlSchemaInfo schemaInfo, ClassLoader classLoader, Set wrapperElementQNames, Collection<JaxRpcOperationInfo> operations, boolean hasEncoded) {
this.mapping = mapping;
this.classLoader = classLoader;
- this.schemaTypeKeyToSchemaTypeMap = schemaTypeKeyToSchemaTypeMap;
+ this.schemaInfo = schemaInfo;
this.wrapperElementQNames = wrapperElementQNames;
this.operations = operations;
this.hasEncoded = hasEncoded;
@@ -78,16 +72,17 @@
// Map types with explicity Java to XML mappings
//
for (JavaXmlTypeMapping javaXmlTypeMapping : mapping.getJavaXmlTypeMapping()) {
- SchemaTypeKey key;
+ QName typeQName;
+ XmlTypeInfo xmlTypeInfo;
if (javaXmlTypeMapping.getRootTypeQname() != null) {
- QName typeQName = javaXmlTypeMapping.getRootTypeQname();
+ typeQName = javaXmlTypeMapping.getRootTypeQname();
// Skip the wrapper elements.
if (wrapperElementQNames.contains(typeQName)) {
continue;
}
- key = new SchemaTypeKey(typeQName, javaXmlTypeMapping.isElement(), javaXmlTypeMapping.isSimpleType(), false, null);
+ xmlTypeInfo = schemaInfo.types.get(typeQName);
} else if (javaXmlTypeMapping != null) {
String anonTypeQNameString = javaXmlTypeMapping.getAnonymousTypeQname();
@@ -96,7 +91,7 @@
if (pos == -1) {
throw new OpenEJBException("anon QName is invalid, no final ':' " + anonTypeQNameString);
}
- QName typeQName = new QName(anonTypeQNameString.substring(0, pos), anonTypeQNameString.substring(pos + 1));
+ typeQName = new QName(anonTypeQNameString.substring(0, pos), anonTypeQNameString.substring(pos + 1));
// Skip the wrapper elements.
// todo why is this +2
@@ -104,21 +99,21 @@
continue;
}
- key = new SchemaTypeKey(typeQName, javaXmlTypeMapping.isElement(), javaXmlTypeMapping.isSimpleType(), true, null);
+ xmlTypeInfo = schemaInfo.types.get(typeQName);
} else {
throw new OpenEJBException("either root type qname or anonymous type qname must be set");
}
- SchemaType schemaType = schemaTypeKeyToSchemaTypeMap.get(key);
- if (schemaType == null) {
+// SchemaType schemaType = schemaTypeKeyToSchemaTypeMap.get(key);
+ if (xmlTypeInfo == null) {
// if this is a built in type then assume this is a redundant mapping
- if (WebserviceNameSpaces.contains(key.getQName().getNamespaceURI())) {
+ if (WebserviceNameSpaces.contains(xmlTypeInfo.qname.getNamespaceURI())) {
continue;
}
- log.warn("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
+ log.warn("Schema type QName [" + typeQName + "] not been found in schema: " + schemaInfo.types.keySet());
continue;
}
- mappedTypeQNames.add(key.getQName());
+ mappedTypeQNames.add(xmlTypeInfo.qname);
Class clazz;
try {
@@ -127,23 +122,18 @@
throw new OpenEJBException("Could not load java type " + javaXmlTypeMapping.getJavaType(), e);
}
- JaxRpcTypeInfo typeInfo = createTypeInfo(schemaType, clazz);
+ JaxRpcTypeInfo typeInfo = createTypeInfo(xmlTypeInfo, clazz);
- typeInfo.qname = key.getElementQName();
+ typeInfo.qname = xmlTypeInfo.elementQName;
if (typeInfo.qname == null) {
- typeInfo.qname = key.getQName();
+ typeInfo.qname = xmlTypeInfo.qname;
}
- mapFields(clazz, key, schemaType, javaXmlTypeMapping, typeInfo);
+ mapFields(clazz, xmlTypeInfo, javaXmlTypeMapping, typeInfo);
typeInfos.add(typeInfo);
}
- Map<QName, SchemaTypeKey> qnameToKey = new HashMap<QName, SchemaTypeKey>();
- for (SchemaTypeKey key : schemaTypeKeyToSchemaTypeMap.keySet()) {
- qnameToKey.put(key.getQName(), key);
- }
-
//
// Map types used in operations
//
@@ -170,13 +160,13 @@
continue;
}
- SchemaTypeKey key = qnameToKey.get(xmlType);
- if (key == null) {
- log.warn("Type QName [" + xmlType + "] defined by operation [" + operationInfo + "] has not been found in schema: " + schemaTypeKeyToSchemaTypeMap);
+
+ XmlTypeInfo xmlTypeInfo = schemaInfo.types.get(xmlType);
+ if (xmlTypeInfo == null) {
+ log.warn("Type QName [" + xmlType + "] defined by operation [" + operationInfo + "] has not been found in schema: " + schemaInfo.types.keySet());
continue;
}
- SchemaType schemaType = schemaTypeKeyToSchemaTypeMap.get(key);
- mappedTypeQNames.add(key.getQName());
+ mappedTypeQNames.add(xmlTypeInfo.qname);
Class<?> javaType;
try {
@@ -185,18 +175,18 @@
throw new OpenEJBException("Could not load paramter");
}
- if (!schemaType.isSimpleType() && !javaType.isArray()) {
- if (!mappedTypeQNames.contains(schemaType.getName())) {
+ if (!xmlTypeInfo.simpleType && !javaType.isArray()) {
+ if (!mappedTypeQNames.contains(xmlTypeInfo.xmlType)) {
// TODO: this lookup is not enough: the jaxrpc mapping file may define an anonymous mapping
- log.warn("Operation " + operationInfo.name + "] uses XML type [" + schemaType + "], whose mapping is not declared by the jaxrpc mapping file.\n Continuing deployment; " + "yet, the deployment is not-portable.");
+ log.warn("Operation " + operationInfo.name + "] uses XML type [" + xmlTypeInfo + "], whose mapping is not declared by the jaxrpc mapping file.\n Continuing deployment; " + "yet, the deployment is not-portable.");
}
continue;
}
- JaxRpcTypeInfo typeInfo = createTypeInfo(schemaType, javaType);
- typeInfo.qname = key.getElementQName();
+ JaxRpcTypeInfo typeInfo = createTypeInfo(xmlTypeInfo, javaType);
+ typeInfo.qname = xmlTypeInfo.elementQName;
if (typeInfo.qname == null) {
- typeInfo.qname = key.getQName();
+ typeInfo.qname = xmlTypeInfo.qname;
}
typeInfos.add(typeInfo);
@@ -208,123 +198,48 @@
/**
* Creates a JaxRpcTypeInfo based on the information contained in the XML Schema Type and Java Class.
- * @param schemaType the xml schema for the type
+ * @param xmlTypeInfo the xml schema for the type
* @param clazz the java class for the type
* @return the JaxRpcTypeInfo object
* @throws OpenEJBException if the schema is invalid
*/
- private JaxRpcTypeInfo createTypeInfo(SchemaType schemaType, Class clazz) throws OpenEJBException {
+ private JaxRpcTypeInfo createTypeInfo(XmlTypeInfo xmlTypeInfo, Class clazz) throws OpenEJBException {
SerializerType serializerType;
QName xmlType = null;
- if (schemaType.isSimpleType()) {
- if (schemaType.getSimpleVariety() == SchemaType.ATOMIC) {
- if (clazz.isArray()) {
- serializerType = SerializerType.ARRAY;
- } else if (schemaType.getEnumerationValues() != null) {
- serializerType = SerializerType.ENUM;
- } else {
- serializerType = SerializerType.OTHER;
- xmlType = schemaType.getPrimitiveType().getName();
- }
- } else if (schemaType.getSimpleVariety() == SchemaType.LIST) {
- serializerType = SerializerType.LIST;
- } else {
- throw new OpenEJBException("Schema type [" + schemaType + "] is invalid.");
- }
+ if (xmlTypeInfo.listType) {
+ serializerType = SerializerType.LIST;
+ } else if (clazz.isArray()) {
+ serializerType = SerializerType.ARRAY;
+ } else if (xmlTypeInfo.enumType) {
+ serializerType = SerializerType.ENUM;
} else {
- if (clazz.isArray()) {
- serializerType = SerializerType.ARRAY;
- } else {
- serializerType = SerializerType.OTHER;
- if (SchemaType.SIMPLE_CONTENT == schemaType.getContentType()) {
- xmlType = schemaType.getBaseType().getName();
- } else if (SchemaType.EMPTY_CONTENT == schemaType.getContentType() ||
- SchemaType.ELEMENT_CONTENT == schemaType.getContentType() ||
- SchemaType.MIXED_CONTENT == schemaType.getContentType()) {
- xmlType = schemaType.getName();
- } else {
- throw new OpenEJBException("Schema type [" + schemaType + "] is invalid.");
- }
- }
+ serializerType = SerializerType.OTHER;
+ xmlType = xmlTypeInfo.baseType;
}
JaxRpcTypeInfo typeInfo = new JaxRpcTypeInfo();
typeInfo.javaType = clazz.getName();
typeInfo.serializerType = serializerType;
typeInfo.xmlType = xmlType;
- typeInfo.canSearchParents = schemaType.getDerivationType() == SchemaType.DT_RESTRICTION;
+ typeInfo.canSearchParents = xmlTypeInfo.restriction;
// If we understand the axis comments correctly, componentQName is never set for j2ee ws.
if (serializerType == SerializerType.ARRAY) {
- typeInfo.componentType = getArrayComponentType(schemaType);
+ typeInfo.componentType = xmlTypeInfo.arrayComponentType;
}
return typeInfo;
}
/**
- * Extract the nested component type of an Array from the XML Schema Type.
- * @param schemaType the XML Schema Type to inspect
- * @return the QName of the nested component type or null if the schema type can not be determined
- * @throws OpenEJBException if the XML Schema Type can not represent an Array
- */
- private QName getArrayComponentType(SchemaType schemaType) throws OpenEJBException {
- //First, handle case that looks like this:
- // <complexType name="ArrayOfstring">
- // <complexContent>
- // <restriction base="soapenc:Array">
- // <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
- // </restriction>
- // </complexContent>
- // </complexType>
- SchemaLocalAttribute arrayTypeAttribute = schemaType.getAttributeModel().getAttribute(new QName(SOAP_ENCODING_NS, "arrayType"));
- if (arrayTypeAttribute != null) {
- SchemaWSDLArrayType wsdlArrayType = (SchemaWSDLArrayType) arrayTypeAttribute;
- SOAPArrayType soapArrayType = wsdlArrayType.getWSDLArrayType();
- if (soapArrayType != null) {
- QName componentType = soapArrayType.getQName();
- log.debug("Extracted componentType " + componentType + " from schemaType " + schemaType);
- return componentType;
- } else {
- log.info("No SOAPArrayType for component from schemaType " + schemaType);
- }
- } else {
- log.warn("No soap array info for schematype: " + schemaType);
- }
-
- // If that didn't work, try to handle case like this:
- // <complexType name="ArrayOfstring1">
- // <complexContent>
- // <restriction base="soapenc:Array">
- // <sequence>
- // <element name="string1" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- // </sequence>
- // </restriction>
- // </complexContent>
- // </complexType>
- if (schemaType.getBaseType().getName().equals(new QName(SOAP_ENCODING_NS, "Array"))) {
- SchemaProperty[] properties = schemaType.getDerivedProperties();
- if (properties.length != 1) {
- throw new OpenEJBException("more than one element inside array definition: " + schemaType);
- }
- QName componentType = properties[0].getType().getName();
- log.debug("determined component type from element type");
- return componentType;
- }
-
- return null;
- }
-
- /**
* Map the (nested) fields of a XML Schema Type to Java Beans properties or public fields of the specified Java Class.
* @param javaClass the java class to map
- * @param key
- * @param schemaType
+ * @param xmlTypeInfo the xml schema for the type
* @param javaXmlTypeMapping the java to xml type mapping metadata
* @param typeInfo the JaxRpcTypeInfo for this type
* @throws OpenEJBException if the XML Schema Type can not be mapped to the Java Class
*/
- private void mapFields(Class javaClass, SchemaTypeKey key, SchemaType schemaType, JavaXmlTypeMapping javaXmlTypeMapping, JaxRpcTypeInfo typeInfo) throws OpenEJBException {
+ private void mapFields(Class javaClass, XmlTypeInfo xmlTypeInfo, JavaXmlTypeMapping javaXmlTypeMapping, JaxRpcTypeInfo typeInfo) throws OpenEJBException {
// Skip arrays since they can't define a variable-mapping element
if (!javaClass.isArray()) {
// if there is a variable-mapping, log a warning
@@ -334,35 +249,6 @@
return;
}
- // Index particles by name
- Map<QName,SchemaParticle> paramNameToType = new HashMap<QName,SchemaParticle>();
- if (schemaType.getContentModel() != null) {
- int particleType = schemaType.getContentModel().getParticleType();
- if (SchemaParticle.ELEMENT == particleType) {
- SchemaParticle parameter = schemaType.getContentModel();
- paramNameToType.put(parameter.getName(), parameter);
- } else if (particleType == SchemaParticle.SEQUENCE || particleType == SchemaParticle.ALL) {
- SchemaParticle[] properties = schemaType.getContentModel().getParticleChildren();
- for (SchemaParticle parameter : properties) {
- paramNameToType.put(parameter.getName(), parameter);
- }
- } else {
- throw new OpenEJBException("Only element, sequence, and all particle types are supported. SchemaType name =" + schemaType.getName());
- }
- }
-
- // Index attributes by name
- Map<String,SchemaLocalAttribute> attNameToType = new HashMap<String,SchemaLocalAttribute>();
- if (schemaType.getAttributeModel() != null) {
- SchemaLocalAttribute[] attributes = schemaType.getAttributeModel().getAttributes();
- for (SchemaLocalAttribute attribute : attributes) {
- Object old = attNameToType.put(attribute.getName().getLocalPart(), attribute);
- if (old != null) {
- throw new OpenEJBException("Complain to your expert group member, spec does not support attributes with the same local name and differing namespaces: original: " + old + ", duplicate local name: " + attribute);
- }
- }
- }
-
// Index Java bean properties by name
Map<String,Class> properties = new HashMap<String,Class>();
try {
@@ -391,11 +277,10 @@
QName xmlName = new QName("", attributeLocalName);
fieldInfo.xmlName = xmlName;
- SchemaLocalAttribute attribute = attNameToType.get(attributeLocalName);
- if (null == attribute) {
- throw new OpenEJBException("attribute " + xmlName + " not found in schema " + schemaType.getName());
+ fieldInfo.xmlType = xmlTypeInfo.attributeTypes.get(attributeLocalName);
+ if (fieldInfo.xmlType == null) {
+ throw new OpenEJBException("attribute " + xmlName + " not found in schema " + xmlTypeInfo.qname);
}
- fieldInfo.xmlType = attribute.getType().getName();
typeInfo.fields.add(fieldInfo);
} else {
@@ -417,40 +302,38 @@
QName xmlName = new QName("", variableMapping.getXmlElementName());
- SchemaParticle particle = paramNameToType.get(xmlName);
- if (particle == null) {
- String ns = key.getQName().getNamespaceURI();
+ XmlNestedElementInfo nestedElement = xmlTypeInfo.nestedElements.get(xmlName);
+ if (nestedElement == null) {
+ String ns = xmlTypeInfo.qname.getNamespaceURI();
xmlName = new QName(ns, variableMapping.getXmlElementName());
- particle = paramNameToType.get(xmlName);
- if (particle == null) {
- throw new OpenEJBException("element " + xmlName + " not found in schema " + schemaType.getName());
+ nestedElement = xmlTypeInfo.nestedElements.get(xmlName);
+ if (nestedElement == null) {
+ throw new OpenEJBException("element " + xmlName + " not found in schema " + xmlTypeInfo.qname);
}
- } else if (SchemaParticle.ELEMENT != particle.getParticleType()) {
- throw new OpenEJBException(xmlName + " is not an element in schema " + schemaType.getName());
}
- fieldInfo.isNillable = particle.isNillable() || hasEncoded;
+ fieldInfo.isNillable = nestedElement.nillable || hasEncoded;
fieldInfo.xmlName = xmlName;
// xml type
- if (particle.getType().getName() != null) {
- fieldInfo.xmlType = particle.getType().getName();
+ if (nestedElement.xmlType != null) {
+ fieldInfo.xmlType = nestedElement.xmlType;
} else {
QName anonymousName;
- if (key.isAnonymous()) {
- anonymousName = new QName(key.getQName().getNamespaceURI(), key.getQName().getLocalPart() +
- ">" + particle.getName().getLocalPart());
+ if (xmlTypeInfo.anonymous) {
+ anonymousName = new QName(xmlTypeInfo.qname.getNamespaceURI(), xmlTypeInfo.qname.getLocalPart() +
+ ">" + nestedElement.qname.getLocalPart());
} else {
- anonymousName = new QName(key.getQName().getNamespaceURI(),
- ">" + key.getQName().getLocalPart() + ">" + particle.getName().getLocalPart());
+ anonymousName = new QName(xmlTypeInfo.qname.getNamespaceURI(),
+ ">" + xmlTypeInfo.qname.getLocalPart() + ">" + nestedElement.qname.getLocalPart());
}
fieldInfo.xmlType = anonymousName;
}
if (javaType.isArray()) {
- fieldInfo.minOccurs = particle.getIntMinOccurs();
- fieldInfo.maxOccurs = particle.getIntMaxOccurs();
+ fieldInfo.minOccurs = nestedElement.minOccurs;
+ fieldInfo.maxOccurs = nestedElement.maxOccurs;
//TODO axis seems to have the wrong name for this property based on how it is used
- fieldInfo.maxOccursUnbounded = particle.getIntMaxOccurs() > 1;
+ fieldInfo.maxOccursUnbounded = nestedElement.maxOccurs > 1;
}
typeInfo.fields.add(fieldInfo);
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcServiceInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcServiceInfoBuilder.java?rev=601187&r1=601186&r2=601187&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcServiceInfoBuilder.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcServiceInfoBuilder.java Tue Dec 4 18:04:51 2007
@@ -22,7 +22,6 @@
import org.apache.openejb.jee.PortComponent;
import org.apache.openejb.jee.ServiceEndpointInterfaceMapping;
import org.apache.openejb.jee.ServiceEndpointMethodMapping;
-import org.apache.xmlbeans.SchemaType;
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
@@ -31,33 +30,33 @@
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap.SOAPBinding;
import javax.wsdl.extensions.soap.SOAPBody;
+import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
public class JaxRpcServiceInfoBuilder {
private final JavaWsdlMapping javaWsdlMapping;
- private final SchemaInfoBuilder schemaInfoBuilder;
+ private final XmlSchemaInfo schemaInfo;
private final PortComponent portComponent;
private final Port port;
private final String wsdlFile;
private final ClassLoader classLoader;
private JaxRpcServiceInfo serviceInfo;
- public JaxRpcServiceInfoBuilder(JavaWsdlMapping javaWsdlMapping, SchemaInfoBuilder schemaInfoBuilder, PortComponent portComponent, Port port, String wsdlFile, ClassLoader classLoader) {
+ public JaxRpcServiceInfoBuilder(JavaWsdlMapping javaWsdlMapping, XmlSchemaInfo schemaInfo, PortComponent portComponent, Port port, String wsdlFile, ClassLoader classLoader) {
this.javaWsdlMapping = javaWsdlMapping;
- this.schemaInfoBuilder = schemaInfoBuilder;
+ this.schemaInfo = schemaInfo;
this.portComponent = portComponent;
this.port = port;
this.wsdlFile = wsdlFile;
this.classLoader = classLoader;
}
- public JaxRpcServiceInfo createServiceDesc() throws OpenEJBException {
+ public JaxRpcServiceInfo createServiceInfo() throws OpenEJBException {
Class serviceEndpointInterface;
try {
serviceEndpointInterface = classLoader.loadClass(portComponent.getServiceEndpointInterface());
@@ -65,8 +64,6 @@
throw new OpenEJBException("Unable to load the service-endpoint interface for port-component " + portComponent.getPortComponentName(), e);
}
- Map<SchemaTypeKey, SchemaType> schemaTypeKeyToSchemaTypeMap = schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap();
-
serviceInfo = new JaxRpcServiceInfo();
serviceInfo.name = portComponent.getWsdlPort().toString();
serviceInfo.serviceEndpointInterface = portComponent.getServiceEndpointInterface();
@@ -87,10 +84,10 @@
//
Collection<JaxRpcTypeInfo> types;
if (isLightweight) {
- LightweightTypeInfoBuilder builder = new LightweightTypeInfoBuilder(javaWsdlMapping, schemaTypeKeyToSchemaTypeMap, classLoader);
+ LightweightTypeInfoBuilder builder = new LightweightTypeInfoBuilder(javaWsdlMapping, schemaInfo, classLoader);
types = builder.buildTypeInfo();
} else {
- HeavyweightTypeInfoBuilder builder = new HeavyweightTypeInfoBuilder(javaWsdlMapping, schemaTypeKeyToSchemaTypeMap, classLoader, wrapperElementQNames, serviceInfo.operations, serviceInfo.defaultBindingStyle.isEncoded());
+ HeavyweightTypeInfoBuilder builder = new HeavyweightTypeInfoBuilder(javaWsdlMapping, schemaInfo, classLoader, wrapperElementQNames, serviceInfo.operations, serviceInfo.defaultBindingStyle.isEncoded());
types = builder.buildTypeInfo();
}
serviceInfo.types.addAll(types);
@@ -119,7 +116,7 @@
ServiceEndpointMethodMapping methodMapping = getMethodMappingForOperation(operationName, serviceEndpointInterface);
// Build the operation info using the Java to XML method mapping
- HeavyweightOperationInfoBuilder operationInfoBuilder = new HeavyweightOperationInfoBuilder(bindingOperation, methodMapping, javaWsdlMapping, schemaInfoBuilder);
+ HeavyweightOperationInfoBuilder operationInfoBuilder = new HeavyweightOperationInfoBuilder(bindingOperation, methodMapping, javaWsdlMapping, schemaInfo);
JaxRpcOperationInfo operationInfo = operationInfoBuilder.buildOperationInfo();
serviceInfo.operations.add(operationInfo);
@@ -133,11 +130,11 @@
}
private BindingStyle getStyle(Binding binding) throws OpenEJBException {
- SOAPBinding soapBinding = SchemaInfoBuilder.getExtensibilityElement(SOAPBinding.class, binding.getExtensibilityElements());
+ SOAPBinding soapBinding = getExtensibilityElement(SOAPBinding.class, binding.getExtensibilityElements());
String styleString = soapBinding.getStyle();
BindingInput bindingInput = ((BindingOperation) binding.getBindingOperations().get(0)).getBindingInput();
- SOAPBody soapBody = SchemaInfoBuilder.getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
+ SOAPBody soapBody = getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
String useString = soapBody.getUse();
BindingStyle bindingStyle = BindingStyle.getBindingStyle(styleString, useString);
@@ -145,7 +142,7 @@
}
private String getAddressLocation(List extensibilityElements) throws OpenEJBException {
- SOAPAddress soapAddress = SchemaInfoBuilder.getExtensibilityElement(SOAPAddress.class, extensibilityElements);
+ SOAPAddress soapAddress = getExtensibilityElement(SOAPAddress.class, extensibilityElements);
String locationURIString = soapAddress.getLocationURI();
return locationURIString;
}
@@ -187,5 +184,15 @@
availOps.append(methodMapping.getWsdlOperation());
}
throw new OpenEJBException("No method found for operation named '" + operationName + "'. Available operations: " + availOps);
+ }
+
+ public static <T extends ExtensibilityElement> T getExtensibilityElement(Class<T> clazz, List extensibilityElements) throws OpenEJBException {
+ for (Object o : extensibilityElements) {
+ ExtensibilityElement extensibilityElement = (ExtensibilityElement) o;
+ if (clazz.isAssignableFrom(extensibilityElement.getClass())) {
+ return clazz.cast(extensibilityElement);
+ }
+ }
+ throw new OpenEJBException("No element of class " + clazz.getName() + " found");
}
}
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java?rev=601187&r1=601186&r2=601187&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java Tue Dec 4 18:04:51 2007
@@ -20,8 +20,6 @@
import org.apache.openejb.OpenEJBException;
import org.apache.openejb.jee.JavaWsdlMapping;
import org.apache.openejb.jee.PackageMapping;
-import org.apache.xmlbeans.SchemaParticle;
-import org.apache.xmlbeans.SchemaType;
import javax.xml.namespace.QName;
import java.beans.IntrospectionException;
@@ -34,24 +32,21 @@
public class LightweightTypeInfoBuilder {
private final JavaWsdlMapping mapping;
- private final Map<SchemaTypeKey, SchemaType> schemaTypeKeyToSchemaTypeMap;
+ private final XmlSchemaInfo schemaInfo;
private final ClassLoader classLoader;
- public LightweightTypeInfoBuilder(JavaWsdlMapping mapping, Map<SchemaTypeKey, SchemaType> schemaTypeKeyToSchemaTypeMap, ClassLoader classLoader) {
+ public LightweightTypeInfoBuilder(JavaWsdlMapping mapping, XmlSchemaInfo schemaInfo, ClassLoader classLoader) {
this.mapping = mapping;
this.classLoader = classLoader;
- this.schemaTypeKeyToSchemaTypeMap = schemaTypeKeyToSchemaTypeMap;
+ this.schemaInfo = schemaInfo;
}
public List<JaxRpcTypeInfo> buildTypeInfo() throws OpenEJBException {
List<JaxRpcTypeInfo> typeInfoList = new ArrayList<JaxRpcTypeInfo>();
- for (Map.Entry<SchemaTypeKey, SchemaType> entry : schemaTypeKeyToSchemaTypeMap.entrySet()) {
- SchemaTypeKey key = entry.getKey();
- SchemaType schemaType = entry.getValue();
-
- if (!key.isElement() && !key.isAnonymous()) {
- QName typeQName = key.getQName();
+ for (XmlTypeInfo xmlTypeInfo : schemaInfo.types.values()) {
+ if (!(xmlTypeInfo.elementQName != null) && !xmlTypeInfo.anonymous) {
+ QName typeQName = xmlTypeInfo.qname;
Class clazz = loadClass(typeQName, mapping);
JaxRpcTypeInfo.SerializerType serializerType = JaxRpcTypeInfo.SerializerType.OTHER;
@@ -64,9 +59,9 @@
typeInfo.javaType = clazz.getName();
typeInfo.serializerType = serializerType;
typeInfo.xmlType = typeQName;
- typeInfo.canSearchParents = schemaType.getDerivationType() == SchemaType.DT_RESTRICTION;
+ typeInfo.canSearchParents = xmlTypeInfo.restriction;
- mapFields(clazz, schemaType, typeInfo);
+ mapFields(clazz, xmlTypeInfo, typeInfo);
typeInfoList.add(typeInfo);
}
@@ -75,24 +70,7 @@
return typeInfoList;
}
- private void mapFields(Class javaClass, SchemaType schemaType, JaxRpcTypeInfo typeInfo) throws OpenEJBException {
- // Map type QName to declaration (including nested types)
- Map<QName, SchemaParticle> paramNameToType = new HashMap<QName, SchemaParticle>();
- if (schemaType.getContentModel() != null) {
- int particleType = schemaType.getContentModel().getParticleType();
- if (SchemaParticle.ELEMENT == particleType) {
- SchemaParticle parameter = schemaType.getContentModel();
- paramNameToType.put(parameter.getName(), parameter);
- } else if (particleType == SchemaParticle.SEQUENCE || particleType == SchemaParticle.ALL) {
- SchemaParticle[] properties = schemaType.getContentModel().getParticleChildren();
- for (SchemaParticle parameter : properties) {
- paramNameToType.put(parameter.getName(), parameter);
- }
- } else {
- throw new OpenEJBException("Only all, choice and sequence particle types are supported." + " SchemaType name =" + schemaType.getName());
- }
- }
-
+ private void mapFields(Class javaClass, XmlTypeInfo xmlTypeInfo, JaxRpcTypeInfo typeInfo) throws OpenEJBException {
// Map JavaBean property name to propertyType
Map<String, Class> propertyToClass = new HashMap<String, Class>();
try {
@@ -104,11 +82,8 @@
}
// Map the elements nexted in the XML Schema Type
- for (Map.Entry<QName, SchemaParticle> entry : paramNameToType.entrySet()) {
- QName fieldQName = entry.getKey();
- SchemaParticle particle = entry.getValue();
-
- String fieldName = fieldQName.getLocalPart();
+ for (XmlNestedElementInfo nestedElement : xmlTypeInfo.nestedElements.values()) {
+ String fieldName = nestedElement.qname.getLocalPart();
Class javaType = propertyToClass.get(fieldName);
if (javaType == null) {
throw new OpenEJBException("Field " + fieldName + " is not defined by class " + javaClass.getName());
@@ -116,14 +91,14 @@
JaxRpcFieldInfo fieldInfo = new JaxRpcFieldInfo();
fieldInfo.name = fieldName;
- fieldInfo.isNillable = particle.isNillable();
- fieldInfo.xmlName = fieldQName;
- fieldInfo.xmlType = particle.getType().getName();
+ fieldInfo.isNillable = nestedElement.nillable;
+ fieldInfo.xmlName = nestedElement.qname;
+ fieldInfo.xmlType = nestedElement.xmlType;
if (javaType.isArray()) {
- fieldInfo.minOccurs = particle.getIntMinOccurs();
- fieldInfo.maxOccurs = particle.getIntMaxOccurs();
- fieldInfo.maxOccursUnbounded = particle.getIntMaxOccurs() > 1;
+ fieldInfo.minOccurs = nestedElement.minOccurs;
+ fieldInfo.maxOccurs = nestedElement.maxOccurs;
+ fieldInfo.maxOccursUnbounded = nestedElement.maxOccurs > 1;
}
typeInfo.fields.add(fieldInfo);