You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/02/27 02:13:56 UTC
svn commit: r512101 - in
/incubator/tuscany/branches/sca-java-integration/sca:
kernel/api/src/main/java/org/apache/tuscany/api/annotation/
kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/
kernel/core/src/test/java/org/apache/tuscany/...
Author: rfeng
Date: Mon Feb 26 17:13:55 2007
New Revision: 512101
URL: http://svn.apache.org/viewvc?view=rev&rev=512101
Log:
[sca-integration-branch] Use @IDLMapping to replace @WrapperStyle
Added:
incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/IDLMapping.java (with props)
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessor.java (with props)
Removed:
incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataContext.java
incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/WrapperStyle.java
Modified:
incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java
incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java
incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java
incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java
incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java
incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBContextHelper.java
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java
incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java
incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java Mon Feb 26 17:13:55 2007
@@ -18,11 +18,13 @@
*/
package org.apache.tuscany.api.annotation;
+import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.ElementType.FIELD;
-import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
@@ -30,7 +32,7 @@
*
* @version $Rev$ $Date$
*/
-@Target({TYPE, METHOD, FIELD})
+@Target({TYPE, METHOD, FIELD, PARAMETER})
@Retention(RUNTIME)
public @interface DataType {
@@ -39,23 +41,5 @@
* @return the unique name of the data binding
*/
String name();
-
- /**
- * Returns the logical data type
- * @return the logical data type
- */
- Class logicalType() default Object.class;
-
- /**
- * Returns the physical data type
- * @return the physical data type
- */
- Class physicalType() default Object.class;
-
- /**
- * Returns an array of extensibility elements
- * @return an array of extensibility elements
- */
- DataContext[] context() default {};
}
Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/IDLMapping.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/IDLMapping.java?view=auto&rev=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/IDLMapping.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/IDLMapping.java Mon Feb 26 17:13:55 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.api.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation that can be applied to interfaces or methods to provide IDL mapping metadata
+ *
+ * @version $Rev$ $Date$
+ */
+@Target( {METHOD, TYPE})
+@Retention(RUNTIME)
+public @interface IDLMapping {
+
+ /**
+ * The name of the databinding for the wrapper
+ */
+ String dataBinding() default "";
+
+ /**
+ * To indicate if the java interface/method is generated from a WSDL using wrapper style.
+ *
+ * @see javax.xml.ws.RequestWrapper
+ * @see javax.xml.ws.RequestWrapper
+ *
+ * @return
+ */
+ boolean wrapperStyle() default true;
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/IDLMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/IDLMapping.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java Mon Feb 26 17:13:55 2007
@@ -35,9 +35,8 @@
import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;
-import org.apache.tuscany.api.annotation.DataContext;
import org.apache.tuscany.api.annotation.DataType;
-import org.apache.tuscany.api.annotation.WrapperStyle;
+import org.apache.tuscany.api.annotation.IDLMapping;
import org.apache.tuscany.spi.annotation.Autowire;
import org.apache.tuscany.spi.databinding.DataBindingRegistry;
import org.apache.tuscany.spi.idl.InvalidServiceContractException;
@@ -81,14 +80,10 @@
private void processInterface(Class<?> clazz, JavaServiceContract contract,
Map<String, Operation<Type>> operations) {
- WrapperStyle interfaceWrapperStyle = clazz.getAnnotation(WrapperStyle.class);
+ IDLMapping interfaceMapping = clazz.getAnnotation(IDLMapping.class);
DataType interfaceDataType = clazz.getAnnotation(DataType.class);
if (interfaceDataType != null) {
contract.setDataBinding(interfaceDataType.name());
- // FIXME: [rfeng] Keep data context as metadata?
- for (DataContext c : interfaceDataType.context()) {
- contract.setMetaData(c.key(), c.value());
- }
}
for (Method method : clazz.getMethods()) {
Operation<?> operation = operations.get(method.getName());
@@ -100,18 +95,15 @@
if (operationDataType != null) {
operation.setDataBinding(operationDataType.name());
// FIXME: [rfeng] Keep data context as metadata?
- for (DataContext c : operationDataType.context()) {
- operation.setMetaData(c.key(), c.value());
- }
}
- WrapperStyle operationWrapperStyle = clazz.getAnnotation(WrapperStyle.class);
- if (operationWrapperStyle == null) {
- operationWrapperStyle = interfaceWrapperStyle;
+ IDLMapping operationMapping = clazz.getAnnotation(IDLMapping.class);
+ if (operationMapping == null) {
+ operationMapping = interfaceMapping;
}
- if (operationWrapperStyle != null) {
- operation.setDataBinding(operationWrapperStyle.value());
- operation.setWrapperStyle(true);
+ if (operationMapping != null) {
+ operation.setDataBinding(operationMapping.dataBinding());
+ operation.setWrapperStyle(operationMapping.wrapperStyle());
}
// String dataBinding = operation.getDataBinding();
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java Mon Feb 26 17:13:55 2007
@@ -28,7 +28,6 @@
import junit.framework.Assert;
import junit.framework.TestCase;
-import org.apache.tuscany.api.annotation.DataContext;
import org.apache.tuscany.api.annotation.DataType;
import org.apache.tuscany.spi.databinding.DataBindingRegistry;
import org.apache.tuscany.spi.idl.InvalidServiceContractException;
@@ -65,12 +64,11 @@
contract.setRemotable(true);
processor.visitInterface(MockInterface.class, null, contract);
Assert.assertEquals("org.w3c.dom.Node", contract.getDataBinding());
- Assert.assertEquals("element", (String)contract.getMetaData().get("nodeType"));
Assert.assertEquals("org.w3c.dom.Node", contract.getOperations().get("call").getDataBinding());
Assert.assertEquals("xml:string", contract.getOperations().get("call1").getDataBinding());
}
- @DataType(name = "org.w3c.dom.Node", context = {@DataContext(key = "nodeType", value = "element")})
+ @DataType(name = "org.w3c.dom.Node")
@Remotable
public static interface MockInterface {
Node call(Node msg);
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java Mon Feb 26 17:13:55 2007
@@ -23,7 +23,6 @@
import junit.framework.Assert;
import junit.framework.TestCase;
-import org.apache.tuscany.api.annotation.DataContext;
import org.apache.tuscany.api.annotation.DataType;
public class DataBindingTestCase extends TestCase {
@@ -32,18 +31,15 @@
Class<Test> testClass = Test.class;
DataType d = testClass.getAnnotation(DataType.class);
Assert.assertEquals(d.name(), "sdo");
- Assert.assertEquals(d.context().length, 0);
Method method = testClass.getMethod("test", new Class[] {Object.class});
DataType d2 = method.getAnnotation(DataType.class);
Assert.assertEquals(d2.name(), "jaxb");
- Assert.assertEquals(d2.context()[0].key(), "contextPath");
- Assert.assertEquals(d2.context()[0].value(), "com.example.ipo.jaxb");
}
@DataType(name = "sdo")
private static interface Test {
- @DataType(name = "jaxb", context = {@DataContext(key = "contextPath", value = "com.example.ipo.jaxb")})
+ @DataType(name = "jaxb")
Object test(Object object);
}
}
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java Mon Feb 26 17:13:55 2007
@@ -103,8 +103,6 @@
types1.add(customerIdType);
types1.add(orderType);
types1.add(flagType);
- DataType<List<DataType<XMLType>>> inputType =
- new DataType<List<DataType<XMLType>>>(IDL_INPUT, Object[].class, types1);
DataType<XMLType> statusType =
new DataType<XMLType>(null, Object.class, new XMLType(new QName(URI_ORDER_XSD, "status"), null));
@@ -158,7 +156,7 @@
responseType.setOperation(op);
WrapperInfo wrapperInfo =
- new WrapperInfo(inputElement, outputElement, inputElements, outputElements, inputType, statusType);
+ new WrapperInfo(DOMDataBinding.NAME, inputElement, outputElement, inputElements, outputElements);
op.setWrapper(wrapperInfo);
op.setDataBinding(DOMDataBinding.NAME);
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java Mon Feb 26 17:13:55 2007
@@ -19,24 +19,32 @@
package org.apache.tuscany.spi.model;
+import java.util.ArrayList;
import java.util.List;
import org.apache.tuscany.spi.idl.ElementInfo;
import org.apache.tuscany.spi.idl.XMLType;
/**
- * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based Web Services (JAX-WS) 2.0 specification,
- * section 2.3.1.2 Wrapper Style.
- * <p/>
- * A WSDL operation qualifies for wrapper style mapping only if the following criteria are met: <ul> <li>(i) The
- * operations input and output messages (if present) each contain only a single part <li>(ii) The input message part
- * refers to a global element declaration whose localname is equal to the operation name <li>(iii) The output message
- * part refers to a global element declaration <li>(iv) The elements referred to by the input and output message parts
- * (henceforth referred to as wrapper elements) are both complex types defined using the xsd:sequence compositor <li>(v)
- * The wrapper elements only contain child elements, they must not contain other structures such as wildcards (element
- * or attribute), xsd:choice, substitution groups (element references are not permitted) or attributes; furthermore,
- * they must not be nillable. </ul>
- *
+ * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based
+ * Web Services (JAX-WS) 2.0 specification, section 2.3.1.2 Wrapper Style. <p/>
+ * A WSDL operation qualifies for wrapper style mapping only if the following
+ * criteria are met:
+ * <ul>
+ * <li>(i) The operations input and output messages (if present) each contain
+ * only a single part
+ * <li>(ii) The input message part refers to a global element declaration whose
+ * localname is equal to the operation name
+ * <li>(iii) The output message part refers to a global element declaration
+ * <li>(iv) The elements referred to by the input and output message parts
+ * (henceforth referred to as wrapper elements) are both complex types defined
+ * using the xsd:sequence compositor
+ * <li>(v) The wrapper elements only contain child elements, they must not
+ * contain other structures such as wildcards (element or attribute),
+ * xsd:choice, substitution groups (element references are not permitted) or
+ * attributes; furthermore, they must not be nillable.
+ * </ul>
+ *
* @version $Rev$ $Date$
*/
public class WrapperInfo {
@@ -52,19 +60,19 @@
private DataType<XMLType> unwrappedOutputType;
- public WrapperInfo(ElementInfo inputWrapperElement,
+ private String dataBinding;
+
+ public WrapperInfo(String dataBinding,
+ ElementInfo inputWrapperElement,
ElementInfo outputWrapperElement,
List<ElementInfo> inputElements,
- List<ElementInfo> outputElements,
- DataType<List<DataType<XMLType>>> unwrappedInputType,
- DataType<XMLType> unwrappedOutputType) {
+ List<ElementInfo> outputElements) {
super();
+ this.dataBinding = dataBinding;
this.inputWrapperElement = inputWrapperElement;
this.outputWrapperElement = outputWrapperElement;
this.inputChildElements = inputElements;
this.outputChildElements = outputElements;
- this.unwrappedInputType = unwrappedInputType;
- this.unwrappedOutputType = unwrappedOutputType;
}
/**
@@ -99,6 +107,17 @@
* @return the unwrappedInputType
*/
public DataType<List<DataType<XMLType>>> getUnwrappedInputType() {
+ if (unwrappedInputType == null) {
+ List<DataType<XMLType>> childTypes = new ArrayList<DataType<XMLType>>();
+ for (ElementInfo element : getInputChildElements()) {
+ DataType<XMLType> type = new DataType<XMLType>(dataBinding, Object.class, new XMLType(element));
+ // type.setMetadata(ElementInfo.class.getName(),
+ // getElementInfo(element));
+ childTypes.add(type);
+ }
+ unwrappedInputType =
+ new DataType<List<DataType<XMLType>>>("idl:unwrapped.input", Object[].class, childTypes);
+ }
return unwrappedInputType;
}
@@ -106,6 +125,17 @@
* @return the unwrappedOutputType
*/
public DataType<XMLType> getUnwrappedOutputType() {
+ if (unwrappedOutputType == null) {
+ List<ElementInfo> elements = getOutputChildElements();
+ if (elements != null && elements.size() > 0) {
+ if (elements.size() > 1) {
+ // We don't support output with multiple parts
+ throw new IllegalArgumentException("Multi-part output is not supported");
+ }
+ ElementInfo element = elements.get(0);
+ unwrappedOutputType = new DataType<XMLType>(dataBinding, Object.class, new XMLType(element));
+ }
+ }
return unwrappedOutputType;
}
-}
\ No newline at end of file
+}
Modified: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBContextHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBContextHelper.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBContextHelper.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBContextHelper.java Mon Feb 26 17:13:55 2007
@@ -18,13 +18,17 @@
*/
package org.apache.tuscany.databinding.jaxb;
+import java.beans.Introspector;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
+import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchema;
+import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import org.apache.tuscany.spi.databinding.TransformationContext;
@@ -136,6 +140,53 @@
return (Class)pType.getRawType();
}
return null;
+ }
+
+ public static XMLType getXmlTypeName(Class<?> javaType) {
+ String namespace = null;
+ String name = null;
+ Package pkg = javaType.getPackage();
+ if (pkg != null) {
+ XmlSchema schema = pkg.getAnnotation(XmlSchema.class);
+ if (schema != null) {
+ namespace = schema.namespace();
+ }
+ }
+ XmlType type = javaType.getAnnotation(XmlType.class);
+ if (type != null) {
+ String typeNamespace = type.namespace();
+ String typeName = type.name();
+
+ if (typeNamespace.equals("##default") && typeName.equals("")) {
+ XmlRootElement rootElement = javaType.getAnnotation(XmlRootElement.class);
+ if (rootElement != null) {
+ namespace = rootElement.namespace();
+ } else {
+ // FIXME: The namespace should be from the referencing
+ // property
+ namespace = null;
+ }
+ } else if (typeNamespace.equals("##default")) {
+ // namespace is from the package
+ } else {
+ namespace = typeNamespace;
+ }
+
+ if (typeName.equals("##default")) {
+ name = Introspector.decapitalize(javaType.getSimpleName());
+ } else {
+ name = typeName;
+ }
+ } else {
+ XmlEnum xmlEnum = javaType.getAnnotation(XmlEnum.class);
+ if (xmlEnum != null) {
+ name = Introspector.decapitalize(javaType.getSimpleName());
+ }
+ }
+ if (name == null) {
+ return null;
+ }
+ return new XMLType(null, new QName(namespace, name));
}
}
Modified: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java Mon Feb 26 17:13:55 2007
@@ -19,17 +19,12 @@
package org.apache.tuscany.databinding.jaxb;
-import java.beans.Introspector;
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSchema;
-import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import org.apache.tuscany.spi.databinding.ExceptionHandler;
@@ -68,7 +63,7 @@
if (rawType == JAXBElement.class) {
Type actualType = parameterizedType.getActualTypeArguments()[0];
if (actualType instanceof Class) {
- XMLType xmlType = getXmlTypeName((Class)actualType);
+ XMLType xmlType = JAXBContextHelper.getXmlTypeName((Class)actualType);
dataType.setLogical(xmlType);
dataType.setDataBinding(getName());
return true;
@@ -80,60 +75,13 @@
return true;
}
- XMLType xmlType = getXmlTypeName(javaType);
+ XMLType xmlType = JAXBContextHelper.getXmlTypeName(javaType);
if (xmlType == null) {
return false;
}
dataType.setLogical(xmlType);
dataType.setDataBinding(getName());
return true;
- }
-
- public static XMLType getXmlTypeName(Class<?> javaType) {
- String namespace = null;
- String name = null;
- Package pkg = javaType.getPackage();
- if (pkg != null) {
- XmlSchema schema = pkg.getAnnotation(XmlSchema.class);
- if (schema != null) {
- namespace = schema.namespace();
- }
- }
- XmlType type = javaType.getAnnotation(XmlType.class);
- if (type != null) {
- String typeNamespace = type.namespace();
- String typeName = type.name();
-
- if (typeNamespace.equals("##default") && typeName.equals("")) {
- XmlRootElement rootElement = javaType.getAnnotation(XmlRootElement.class);
- if (rootElement != null) {
- namespace = rootElement.namespace();
- } else {
- // FIXME: The namespace should be from the referencing
- // property
- namespace = null;
- }
- } else if (typeNamespace.equals("##default")) {
- // namespace is from the package
- } else {
- namespace = typeNamespace;
- }
-
- if (typeName.equals("##default")) {
- name = Introspector.decapitalize(javaType.getSimpleName());
- } else {
- name = typeName;
- }
- } else {
- XmlEnum xmlEnum = javaType.getAnnotation(XmlEnum.class);
- if (xmlEnum != null) {
- name = Introspector.decapitalize(javaType.getSimpleName());
- }
- }
- if (name == null) {
- return null;
- }
- return new XMLType(null, new QName(namespace, name));
}
@SuppressWarnings("unchecked")
Added: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessor.java?view=auto&rev=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessor.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessor.java Mon Feb 26 17:13:55 2007
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.jaxb;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorExtension;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.WrapperInfo;
+
+/**
+ * The databinding annotation processor for java interfaces
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXWSJavaInterfaceProcessor extends JavaInterfaceProcessorExtension {
+
+ public JAXWSJavaInterfaceProcessor() {
+ super();
+ }
+
+ public void visitInterface(Class<?> clazz, Class<?> callbackClass, JavaServiceContract contract)
+ throws InvalidServiceContractException {
+ if (!contract.isRemotable()) {
+ return;
+ }
+ Map<String, Operation<Type>> operations = contract.getOperations();
+ processInterface(clazz, contract, operations);
+ if (callbackClass != null) {
+ Map<String, Operation<Type>> callbackOperations = contract.getCallbackOperations();
+ processInterface(callbackClass, contract, callbackOperations);
+ }
+ }
+
+ private static String getValue(String value, String defaultValue) {
+ return "".equals(value) ? defaultValue : value;
+ }
+
+ private void processInterface(Class<?> clazz, JavaServiceContract contract, Map<String, Operation<Type>> operations) {
+
+ for (Method method : clazz.getMethods()) {
+ Operation<?> operation = operations.get(method.getName());
+
+ WebMethod webMethod = method.getAnnotation(WebMethod.class);
+ if (webMethod == null) {
+ return;
+ }
+
+ String operationName = getValue(webMethod.operationName(), operation.getName());
+
+ RequestWrapper requestWrapper = method.getAnnotation(RequestWrapper.class);
+ ResponseWrapper responseWrapper = method.getAnnotation(ResponseWrapper.class);
+ if (requestWrapper == null) {
+ return;
+ }
+
+ WebService webService = clazz.getAnnotation(WebService.class);
+ String tns = "";
+ if (webService != null) {
+ tns = webService.targetNamespace();
+ }
+
+ String ns = getValue(requestWrapper.targetNamespace(), tns);
+ String name = getValue(requestWrapper.localName(), operationName);
+ QName inputWrapper = new QName(ns, name);
+
+ ns = getValue(responseWrapper.targetNamespace(), tns);
+ name = getValue(responseWrapper.localName(), operationName + "Response");
+
+ QName outputWrapper = new QName(ns, name);
+
+ WrapperInfo wrapperInfo =
+ new WrapperInfo(JAXBDataBinding.NAME, new ElementInfo(inputWrapper, null),
+ new ElementInfo(outputWrapper, null), null, null);
+ operation.setWrapperStyle(true);
+ operation.setWrapper(wrapperInfo);
+ }
+ }
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java Mon Feb 26 17:13:55 2007
@@ -59,7 +59,7 @@
public void setChild(Object wrapper, int i, ElementInfo childElement, Object value) {
DataObject wrapperDO =
(wrapper instanceof XMLDocument) ? ((XMLDocument)wrapper).getRootObject() : (DataObject)wrapper;
- wrapperDO.set(childElement.getQName().getLocalPart(), value);
+ wrapperDO.set(i, value);
}
public List getChildren(Object wrapper) {
Modified: incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java Mon Feb 26 17:13:55 2007
@@ -195,13 +195,14 @@
operationModel.setWrapperStyle(isWrapperStyle());
// operationModel.setMetaData(WSDLOperation.class.getName(), this);
if (isWrapperStyle()) {
- operationModel.setWrapper(getWrapper().getWrapperInfo());
+ WrapperInfo wrapperInfo = getWrapper().getWrapperInfo();
+ operationModel.setWrapper(wrapperInfo);
// Register the operation with the types
- for (DataType<?> d : wrapper.getUnwrappedInputType().getLogical()) {
+ for (DataType<?> d : wrapperInfo.getUnwrappedInputType().getLogical()) {
d.setOperation(operationModel);
}
- if (wrapper.getUnwrappedOutputType() != null) {
- wrapper.getUnwrappedOutputType().setOperation(operationModel);
+ if (wrapperInfo.getUnwrappedOutputType() != null) {
+ wrapperInfo.getUnwrappedOutputType().setOperation(operationModel);
}
}
}
@@ -445,6 +446,7 @@
return outputWrapperElement;
}
+ /*
public DataType<List<DataType<XMLType>>> getUnwrappedInputType() throws InvalidWSDLException {
if (unwrappedInputType == null) {
List<DataType<XMLType>> childTypes = new ArrayList<DataType<XMLType>>();
@@ -476,6 +478,7 @@
}
return unwrappedOutputType;
}
+ */
public WrapperInfo getWrapperInfo() throws InvalidServiceContractException {
if (wrapperInfo == null) {
@@ -492,7 +495,7 @@
}
}
wrapperInfo =
- new WrapperInfo(in, out, inChildren, outChildren, getUnwrappedInputType(), getUnwrappedOutputType());
+ new WrapperInfo(dataBinding, in, out, inChildren, outChildren);
}
return wrapperInfo;
}
Modified: incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java?view=diff&rev=512101&r1=512100&r2=512101
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java Mon Feb 26 17:13:55 2007
@@ -69,13 +69,13 @@
outputType.getLogical().getElementName());
Assert.assertTrue(op.isWrapperStyle());
- DataType<List<DataType<XMLType>>> unwrappedInputType = op.getWrapper().getUnwrappedInputType();
+ DataType<List<DataType<XMLType>>> unwrappedInputType = op.getWrapper().getWrapperInfo().getUnwrappedInputType();
List<DataType<XMLType>> childTypes = unwrappedInputType.getLogical();
Assert.assertEquals(1, childTypes.size());
DataType<XMLType> childType = childTypes.get(0);
Assert.assertEquals(new QName(null, "tickerSymbol"), childType.getLogical().getElementName());
- childType = op.getWrapper().getUnwrappedOutputType();
+ childType = op.getWrapper().getWrapperInfo().getUnwrappedOutputType();
Assert.assertEquals(new QName(null, "price"), childType.getLogical().getElementName());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org