cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r630381 [2/8] - in /incubator/cxf/trunk/rt: bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/ core/src/main/java/org/apache/cxf/databinding/source/mime/ core/src/main/java/org/apache/cxf/interceptor/ core/src/main/java/org/ap...
Date Sat, 23 Feb 2008 02:56:00 GMT
Propchange: incubator/cxf/trunk/rt/databinding/jaxb/src/test/resources/wsdl/jaxb/form_test.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/jaxb/src/test/resources/wsdl/jaxb/form_test.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/databinding/jaxb/src/test/resources/wsdl/jaxb/form_test.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointReferenceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointReferenceBuilder.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointReferenceBuilder.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointReferenceBuilder.java Fri Feb 22 18:55:53 2008
@@ -1,66 +1,66 @@
-/**
- * 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.cxf.jaxws;
-
-import java.util.logging.Logger;
-import javax.xml.ws.EndpointReference;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.wsaddressing.W3CEndpointReference;
-import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
-
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
-import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
-
-public class EndpointReferenceBuilder {
-    private static final Logger LOG = LogUtils.getL7dLogger(EndpointReferenceBuilder.class);
-    private final JaxWsEndpointImpl endpoint;
-
-    public EndpointReferenceBuilder(JaxWsEndpointImpl e) {
-        this.endpoint = e;
-    }
-    public EndpointReference getEndpointReference() {
-        String bindingId = endpoint.getJaxwsBinding().getBindingID();   
-        
-        if (!SOAPBindingImpl.isSoapBinding(bindingId)) {
-            throw new UnsupportedOperationException(new Message("GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING",
-                                                                LOG, bindingId).toString());
-        }
-        
-        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
-        
-        builder.address(this.endpoint.getEndpointInfo().getAddress());
-        builder.serviceName(this.endpoint.getService().getName());
-        builder.endpointName(this.endpoint.getEndpointInfo().getName());
-        
-        //TODO: get wsdlDocumentLocation
-        //builder.wsdlDocumentLocation(endpoint.getService().getServiceInfos().toString());        
-        
-        return builder.build();
-    }
-
-    public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
-        if (clazz != W3CEndpointReference.class) {
-            throw new WebServiceException("Unsupported EPR type: " + clazz);
-        }
-        return clazz.cast(getEndpointReference());
-    }
-}
+/**
+ * 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.cxf.jaxws;
+
+import java.util.logging.Logger;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
+import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
+
+public class EndpointReferenceBuilder {
+    private static final Logger LOG = LogUtils.getL7dLogger(EndpointReferenceBuilder.class);
+    private final JaxWsEndpointImpl endpoint;
+
+    public EndpointReferenceBuilder(JaxWsEndpointImpl e) {
+        this.endpoint = e;
+    }
+    public EndpointReference getEndpointReference() {
+        String bindingId = endpoint.getJaxwsBinding().getBindingID();   
+        
+        if (!SOAPBindingImpl.isSoapBinding(bindingId)) {
+            throw new UnsupportedOperationException(new Message("GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING",
+                                                                LOG, bindingId).toString());
+        }
+        
+        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
+        
+        builder.address(this.endpoint.getEndpointInfo().getAddress());
+        builder.serviceName(this.endpoint.getService().getName());
+        builder.endpointName(this.endpoint.getEndpointInfo().getName());
+        
+        //TODO: get wsdlDocumentLocation
+        //builder.wsdlDocumentLocation(endpoint.getService().getServiceInfos().toString());        
+        
+        return builder.build();
+    }
+
+    public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
+        if (clazz != W3CEndpointReference.class) {
+            throw new WebServiceException("Unsupported EPR type: " + clazz);
+        }
+        return clazz.cast(getEndpointReference());
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointReferenceBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointReferenceBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java Fri Feb 22 18:55:53 2008
@@ -1,337 +1,337 @@
-/**
- * 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.cxf.jaxws;
-
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Array;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import javax.xml.bind.annotation.XmlAttachmentRef;
-import javax.xml.bind.annotation.XmlList;
-import javax.xml.bind.annotation.XmlMimeType;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import javax.xml.namespace.QName;
-
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.JavaUtils;
-import org.apache.cxf.jaxws.util.ASMHelper;
-import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
-import org.apache.cxf.service.model.InterfaceInfo;
-import org.apache.cxf.service.model.MessageInfo;
-import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.cxf.service.model.OperationInfo;
-import org.apache.cxf.tools.common.ToolConstants;
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-public final class WrapperClassGenerator extends ASMHelper {
-    private static final Logger LOG = LogUtils.getL7dLogger(WrapperClassGenerator.class);
-    private Set<Class<?>> wrapperBeans = new LinkedHashSet<Class<?>>();
-    private InterfaceInfo interfaceInfo;
-    private boolean qualified;
-    
-    public WrapperClassGenerator(InterfaceInfo inf, boolean q) {
-        interfaceInfo = inf;
-        qualified = q;
-    }
-
-    private String getPackageName(Method method) {
-        Package pkg = method.getDeclaringClass().getPackage();
-        if (pkg == null) {
-            return ToolConstants.DEFAULT_PACKAGE_NAME;
-        }
-        return pkg.getName();
-    }
-
-    private Annotation[] getMethodParameterAnnotations(final MessagePartInfo mpi) {
-        Annotation[] a = (Annotation[])mpi.getProperty(ReflectionServiceFactoryBean.PARAM_ANNOTATION);
-        if (a != null) {
-            return a;
-        }
-        
-        Annotation[][] paramAnno = (Annotation[][])mpi
-            .getProperty(ReflectionServiceFactoryBean.METHOD_PARAM_ANNOTATIONS);
-        int index = mpi.getIndex();
-        if (paramAnno != null && index < paramAnno.length && index >= 0) {
-            return paramAnno[index];
-        }
-        return null;
-    }
-
-    private List<Annotation> getJaxbAnnos(MessagePartInfo mpi) {
-        List<Annotation> list = new java.util.concurrent.CopyOnWriteArrayList<Annotation>();
-        Annotation[] anns = getMethodParameterAnnotations(mpi);
-        if (anns != null) {
-            for (Annotation anno : anns) {
-                if (anno.annotationType() == XmlList.class 
-                    || anno.annotationType() == XmlAttachmentRef.class
-                    || anno.annotationType() == XmlJavaTypeAdapter.class
-                    || anno.annotationType() == XmlMimeType.class) {
-                    list.add(anno);
-                }
-            }
-        }
-        return list;
-    }
-
-    public Set<Class<?>> generate() {
-        try {
-            createClassWriter();
-        } catch (Throwable t) {
-            for (OperationInfo opInfo : interfaceInfo.getOperations()) {
-                if (opInfo.isUnwrappedCapable()
-                    && (opInfo.getUnwrappedOperation()
-                        .getProperty(ReflectionServiceFactoryBean.WRAPPERGEN_NEEDED) != null)) {
-                    LOG.warning(opInfo.getName() + "requires a wrapper bean but problems with"
-                                + " ASM has prevented creating one.  Operation may not work correctly.");
-                }
-            }
-            return wrapperBeans;
-        }
-        for (OperationInfo opInfo : interfaceInfo.getOperations()) {
-            if (opInfo.isUnwrappedCapable()) {
-                Method method = (Method)opInfo.getProperty(ReflectionServiceFactoryBean.METHOD);
-                if (method == null) {
-                    continue;
-                }
-                MessagePartInfo inf = opInfo.getInput().getMessageParts().get(0);
-                if (inf.getTypeClass() == null) {
-                    MessageInfo messageInfo = opInfo.getUnwrappedOperation().getInput();
-                    createWrapperClass(inf,
-                                       messageInfo, 
-                                       opInfo,
-                                       method, 
-                                       true);
-                }
-                MessageInfo messageInfo = opInfo.getUnwrappedOperation().getOutput();
-                if (messageInfo != null) {
-                    inf = opInfo.getOutput().getMessageParts().get(0);
-                    if (inf.getTypeClass() == null) {
-                        createWrapperClass(inf,
-                                           messageInfo,
-                                           opInfo,
-                                           method, 
-                                           false);
-                    }
-                }
-            }
-        }
-        return wrapperBeans;
-    }
-
-    private void createWrapperClass(MessagePartInfo wrapperPart,
-                                        MessageInfo messageInfo,
-                                        OperationInfo op,
-                                        Method method, 
-                                        boolean isRequest) {
-
-        QName wrapperElement = messageInfo.getName();
-
-        ClassWriter cw = createClassWriter();
-        String className = getPackageName(method) + ".jaxws." 
-            + StringUtils.capitalize(op.getName().getLocalPart());
-        if (!isRequest) {
-            className = className + "Response";
-        }
-        String pname = getPackageName(method) + ".jaxws.package-info";
-        Class<?> def = findClass(pname, method.getDeclaringClass());
-        if (def == null) {
-            generatePackageInfo(pname, wrapperElement.getNamespaceURI(),
-                                method.getDeclaringClass());
-        }
-        
-        def = findClass(className, method.getDeclaringClass());
-        if (def != null) {
-            wrapperPart.setTypeClass(def);
-            wrapperBeans.add(def);
-            return;
-        }
-        String classFileName = periodToSlashes(className);
-        cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, classFileName, null,
-                 "java/lang/Object", null);
-
-        AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlRootElement;", true);
-        av0.visit("name", wrapperElement.getLocalPart());
-        av0.visit("namespace", wrapperElement.getNamespaceURI());
-        av0.visitEnd();
-
-        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlAccessorType;", true);
-        av0.visitEnum("value", "Ljavax/xml/bind/annotation/XmlAccessType;", "FIELD");
-        av0.visitEnd();
-
-        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlType;", true);
-        av0.visit("name", wrapperElement.getLocalPart());
-        av0.visit("namespace", wrapperElement.getNamespaceURI());
-        av0.visitEnd();
-
-        // add constructor
-        MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
-        mv.visitCode();
-        Label lbegin = new Label();
-        mv.visitLabel(lbegin);
-        mv.visitVarInsn(Opcodes.ALOAD, 0);
-        mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
-        mv.visitInsn(Opcodes.RETURN);
-        Label lend = new Label();
-        mv.visitLabel(lend);
-        mv.visitLocalVariable("this", "L" + classFileName + ";", null, lbegin, lend, 0);
-        mv.visitMaxs(1, 1);
-        mv.visitEnd();
-
-        for (MessagePartInfo mpi : messageInfo.getMessageParts()) {
-            generateMessagePart(cw, mpi, method, classFileName);
-        }
-
-        cw.visitEnd();
-
-        Class<?> clz = loadClass(className, method.getDeclaringClass(), cw.toByteArray());
-        wrapperPart.setTypeClass(clz);
-        wrapperBeans.add(clz);
-    }
-
-    private void generatePackageInfo(String className, String ns, Class clz) {
-        ClassWriter cw = createClassWriter();
-        String classFileName = periodToSlashes(className);
-        cw.visit(Opcodes.V1_5, Opcodes.ACC_ABSTRACT + Opcodes.ACC_INTERFACE, classFileName, null,
-                 "java/lang/Object", null);
-        
-        
-        AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlSchema;", true);
-        av0.visit("namespace", ns);
-        av0.visitEnum("elementFormDefault",
-                      getClassCode(XmlNsForm.class),
-                      qualified ? "QUALIFIED" : "UNQUALIFIED");
-        av0.visitEnd();
-        cw.visitEnd();
-
-        loadClass(className, clz, cw.toByteArray());
-    }
-
-    private void generateMessagePart(ClassWriter cw, MessagePartInfo mpi, Method method, String className) {
-        if (Boolean.TRUE.equals(mpi.getProperty(ReflectionServiceFactoryBean.HEADER))) {
-            return;
-        }
-        String classFileName = periodToSlashes(className);
-        String name = mpi.getName().getLocalPart();
-        Class clz = mpi.getTypeClass();
-        Object obj = mpi.getProperty(ReflectionServiceFactoryBean.RAW_CLASS);
-        if (obj != null) {
-            clz = (Class)obj;
-        }
-        Class genericTypeClass = null;
-        Type genericType = (Type)mpi.getProperty(ReflectionServiceFactoryBean.GENERIC_TYPE);
-        if (genericType instanceof ParameterizedType
-            && Collection.class.isAssignableFrom(clz)) {
-            ParameterizedType ptype = (ParameterizedType)genericType;
-
-            Type[] types = ptype.getActualTypeArguments();
-            // TODO: more complex Parameterized type
-            if (types.length > 0) {
-                if (types[0] instanceof Class) {
-                    genericTypeClass = (Class)types[0];
-                } else if (types[0] instanceof GenericArrayType) {
-                    genericTypeClass = (Class)((GenericArrayType)types[0]).getGenericComponentType();
-                    genericTypeClass = Array.newInstance(genericTypeClass, 0).getClass();
-                }
-            }
-        }
-        String classCode = getClassCode(clz);
-
-        String filedDescriptor = null;
-        if (genericTypeClass != null
-            && Collection.class.isAssignableFrom(clz)) {
-            filedDescriptor = classCode.substring(0, classCode.lastIndexOf(";")) + "<"
-                              + getClassCode(genericTypeClass) + ">;";
-        }
-        String fieldName = JavaUtils.isJavaKeyword(name) ? JavaUtils.makeNonJavaKeyword(name) : name;
-        
-        FieldVisitor fv = cw.visitField(Opcodes.ACC_PRIVATE, fieldName, 
-                                        classCode, filedDescriptor, null);
-        AnnotationVisitor av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
-        av0.visit("name", name);
-        av0.visitEnd();
-
-        List<Annotation> jaxbAnnos = getJaxbAnnos(mpi);
-        for (Annotation ann : jaxbAnnos) {
-            if (ann instanceof XmlMimeType) {
-                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlMimeType;", true);
-                av0.visit("value", ((XmlMimeType)ann).value());
-                av0.visitEnd();
-            } else if (ann instanceof XmlJavaTypeAdapter) {
-                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
-                XmlJavaTypeAdapter adapter = (XmlJavaTypeAdapter)ann;
-                if (adapter.value() != null) {
-                    av0.visit("value", org.objectweb.asm.Type.getType(getClassCode(adapter.value())));
-                }
-                if (adapter.type() != javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT.class) {
-                    av0.visit("type", org.objectweb.asm.Type.getType(getClassCode(adapter.type())));
-                }
-                av0.visitEnd();
-            } else if (ann instanceof XmlAttachmentRef) {
-                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlAttachmentRef;", true);
-                av0.visitEnd();
-            } else if (ann instanceof XmlList) {
-                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
-                av0.visitEnd();
-            }
-
-        }
-
-        fv.visitEnd();
-
-        String methodName = StringUtils.capitalize(name);
-
-        MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "get" + methodName, "()" + classCode, null,
-                                          null);
-        mv.visitCode();
-
-        mv.visitVarInsn(Opcodes.ALOAD, 0);
-        mv.visitFieldInsn(Opcodes.GETFIELD, classFileName, fieldName, classCode);
-        mv.visitInsn(org.objectweb.asm.Type.getType(classCode).getOpcode(Opcodes.IRETURN));
-        mv.visitMaxs(0, 0);
-        mv.visitEnd();
-        
-        mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "set" + methodName, "(" + classCode + ")V", null, null);
-        mv.visitCode();
-        mv.visitVarInsn(Opcodes.ALOAD, 0);
-        org.objectweb.asm.Type setType = org.objectweb.asm.Type.getType(classCode);
-        mv.visitVarInsn(setType.getOpcode(Opcodes.ILOAD), 1);
-        mv.visitFieldInsn(Opcodes.PUTFIELD, className, fieldName, classCode);       
-        mv.visitInsn(Opcodes.RETURN);
-        mv.visitMaxs(0, 0);
-        mv.visitEnd();
-
-    }
-}
+/**
+ * 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.cxf.jaxws;
+
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.xml.bind.annotation.XmlAttachmentRef;
+import javax.xml.bind.annotation.XmlList;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.helpers.JavaUtils;
+import org.apache.cxf.jaxws.util.ASMHelper;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.tools.common.ToolConstants;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+public final class WrapperClassGenerator extends ASMHelper {
+    private static final Logger LOG = LogUtils.getL7dLogger(WrapperClassGenerator.class);
+    private Set<Class<?>> wrapperBeans = new LinkedHashSet<Class<?>>();
+    private InterfaceInfo interfaceInfo;
+    private boolean qualified;
+    
+    public WrapperClassGenerator(InterfaceInfo inf, boolean q) {
+        interfaceInfo = inf;
+        qualified = q;
+    }
+
+    private String getPackageName(Method method) {
+        Package pkg = method.getDeclaringClass().getPackage();
+        if (pkg == null) {
+            return ToolConstants.DEFAULT_PACKAGE_NAME;
+        }
+        return pkg.getName();
+    }
+
+    private Annotation[] getMethodParameterAnnotations(final MessagePartInfo mpi) {
+        Annotation[] a = (Annotation[])mpi.getProperty(ReflectionServiceFactoryBean.PARAM_ANNOTATION);
+        if (a != null) {
+            return a;
+        }
+        
+        Annotation[][] paramAnno = (Annotation[][])mpi
+            .getProperty(ReflectionServiceFactoryBean.METHOD_PARAM_ANNOTATIONS);
+        int index = mpi.getIndex();
+        if (paramAnno != null && index < paramAnno.length && index >= 0) {
+            return paramAnno[index];
+        }
+        return null;
+    }
+
+    private List<Annotation> getJaxbAnnos(MessagePartInfo mpi) {
+        List<Annotation> list = new java.util.concurrent.CopyOnWriteArrayList<Annotation>();
+        Annotation[] anns = getMethodParameterAnnotations(mpi);
+        if (anns != null) {
+            for (Annotation anno : anns) {
+                if (anno.annotationType() == XmlList.class 
+                    || anno.annotationType() == XmlAttachmentRef.class
+                    || anno.annotationType() == XmlJavaTypeAdapter.class
+                    || anno.annotationType() == XmlMimeType.class) {
+                    list.add(anno);
+                }
+            }
+        }
+        return list;
+    }
+
+    public Set<Class<?>> generate() {
+        try {
+            createClassWriter();
+        } catch (Throwable t) {
+            for (OperationInfo opInfo : interfaceInfo.getOperations()) {
+                if (opInfo.isUnwrappedCapable()
+                    && (opInfo.getUnwrappedOperation()
+                        .getProperty(ReflectionServiceFactoryBean.WRAPPERGEN_NEEDED) != null)) {
+                    LOG.warning(opInfo.getName() + "requires a wrapper bean but problems with"
+                                + " ASM has prevented creating one.  Operation may not work correctly.");
+                }
+            }
+            return wrapperBeans;
+        }
+        for (OperationInfo opInfo : interfaceInfo.getOperations()) {
+            if (opInfo.isUnwrappedCapable()) {
+                Method method = (Method)opInfo.getProperty(ReflectionServiceFactoryBean.METHOD);
+                if (method == null) {
+                    continue;
+                }
+                MessagePartInfo inf = opInfo.getInput().getMessageParts().get(0);
+                if (inf.getTypeClass() == null) {
+                    MessageInfo messageInfo = opInfo.getUnwrappedOperation().getInput();
+                    createWrapperClass(inf,
+                                       messageInfo, 
+                                       opInfo,
+                                       method, 
+                                       true);
+                }
+                MessageInfo messageInfo = opInfo.getUnwrappedOperation().getOutput();
+                if (messageInfo != null) {
+                    inf = opInfo.getOutput().getMessageParts().get(0);
+                    if (inf.getTypeClass() == null) {
+                        createWrapperClass(inf,
+                                           messageInfo,
+                                           opInfo,
+                                           method, 
+                                           false);
+                    }
+                }
+            }
+        }
+        return wrapperBeans;
+    }
+
+    private void createWrapperClass(MessagePartInfo wrapperPart,
+                                        MessageInfo messageInfo,
+                                        OperationInfo op,
+                                        Method method, 
+                                        boolean isRequest) {
+
+        QName wrapperElement = messageInfo.getName();
+
+        ClassWriter cw = createClassWriter();
+        String className = getPackageName(method) + ".jaxws." 
+            + StringUtils.capitalize(op.getName().getLocalPart());
+        if (!isRequest) {
+            className = className + "Response";
+        }
+        String pname = getPackageName(method) + ".jaxws.package-info";
+        Class<?> def = findClass(pname, method.getDeclaringClass());
+        if (def == null) {
+            generatePackageInfo(pname, wrapperElement.getNamespaceURI(),
+                                method.getDeclaringClass());
+        }
+        
+        def = findClass(className, method.getDeclaringClass());
+        if (def != null) {
+            wrapperPart.setTypeClass(def);
+            wrapperBeans.add(def);
+            return;
+        }
+        String classFileName = periodToSlashes(className);
+        cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, classFileName, null,
+                 "java/lang/Object", null);
+
+        AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlRootElement;", true);
+        av0.visit("name", wrapperElement.getLocalPart());
+        av0.visit("namespace", wrapperElement.getNamespaceURI());
+        av0.visitEnd();
+
+        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlAccessorType;", true);
+        av0.visitEnum("value", "Ljavax/xml/bind/annotation/XmlAccessType;", "FIELD");
+        av0.visitEnd();
+
+        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlType;", true);
+        av0.visit("name", wrapperElement.getLocalPart());
+        av0.visit("namespace", wrapperElement.getNamespaceURI());
+        av0.visitEnd();
+
+        // add constructor
+        MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
+        mv.visitCode();
+        Label lbegin = new Label();
+        mv.visitLabel(lbegin);
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
+        mv.visitInsn(Opcodes.RETURN);
+        Label lend = new Label();
+        mv.visitLabel(lend);
+        mv.visitLocalVariable("this", "L" + classFileName + ";", null, lbegin, lend, 0);
+        mv.visitMaxs(1, 1);
+        mv.visitEnd();
+
+        for (MessagePartInfo mpi : messageInfo.getMessageParts()) {
+            generateMessagePart(cw, mpi, method, classFileName);
+        }
+
+        cw.visitEnd();
+
+        Class<?> clz = loadClass(className, method.getDeclaringClass(), cw.toByteArray());
+        wrapperPart.setTypeClass(clz);
+        wrapperBeans.add(clz);
+    }
+
+    private void generatePackageInfo(String className, String ns, Class clz) {
+        ClassWriter cw = createClassWriter();
+        String classFileName = periodToSlashes(className);
+        cw.visit(Opcodes.V1_5, Opcodes.ACC_ABSTRACT + Opcodes.ACC_INTERFACE, classFileName, null,
+                 "java/lang/Object", null);
+        
+        
+        AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlSchema;", true);
+        av0.visit("namespace", ns);
+        av0.visitEnum("elementFormDefault",
+                      getClassCode(XmlNsForm.class),
+                      qualified ? "QUALIFIED" : "UNQUALIFIED");
+        av0.visitEnd();
+        cw.visitEnd();
+
+        loadClass(className, clz, cw.toByteArray());
+    }
+
+    private void generateMessagePart(ClassWriter cw, MessagePartInfo mpi, Method method, String className) {
+        if (Boolean.TRUE.equals(mpi.getProperty(ReflectionServiceFactoryBean.HEADER))) {
+            return;
+        }
+        String classFileName = periodToSlashes(className);
+        String name = mpi.getName().getLocalPart();
+        Class clz = mpi.getTypeClass();
+        Object obj = mpi.getProperty(ReflectionServiceFactoryBean.RAW_CLASS);
+        if (obj != null) {
+            clz = (Class)obj;
+        }
+        Class genericTypeClass = null;
+        Type genericType = (Type)mpi.getProperty(ReflectionServiceFactoryBean.GENERIC_TYPE);
+        if (genericType instanceof ParameterizedType
+            && Collection.class.isAssignableFrom(clz)) {
+            ParameterizedType ptype = (ParameterizedType)genericType;
+
+            Type[] types = ptype.getActualTypeArguments();
+            // TODO: more complex Parameterized type
+            if (types.length > 0) {
+                if (types[0] instanceof Class) {
+                    genericTypeClass = (Class)types[0];
+                } else if (types[0] instanceof GenericArrayType) {
+                    genericTypeClass = (Class)((GenericArrayType)types[0]).getGenericComponentType();
+                    genericTypeClass = Array.newInstance(genericTypeClass, 0).getClass();
+                }
+            }
+        }
+        String classCode = getClassCode(clz);
+
+        String filedDescriptor = null;
+        if (genericTypeClass != null
+            && Collection.class.isAssignableFrom(clz)) {
+            filedDescriptor = classCode.substring(0, classCode.lastIndexOf(";")) + "<"
+                              + getClassCode(genericTypeClass) + ">;";
+        }
+        String fieldName = JavaUtils.isJavaKeyword(name) ? JavaUtils.makeNonJavaKeyword(name) : name;
+        
+        FieldVisitor fv = cw.visitField(Opcodes.ACC_PRIVATE, fieldName, 
+                                        classCode, filedDescriptor, null);
+        AnnotationVisitor av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
+        av0.visit("name", name);
+        av0.visitEnd();
+
+        List<Annotation> jaxbAnnos = getJaxbAnnos(mpi);
+        for (Annotation ann : jaxbAnnos) {
+            if (ann instanceof XmlMimeType) {
+                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlMimeType;", true);
+                av0.visit("value", ((XmlMimeType)ann).value());
+                av0.visitEnd();
+            } else if (ann instanceof XmlJavaTypeAdapter) {
+                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
+                XmlJavaTypeAdapter adapter = (XmlJavaTypeAdapter)ann;
+                if (adapter.value() != null) {
+                    av0.visit("value", org.objectweb.asm.Type.getType(getClassCode(adapter.value())));
+                }
+                if (adapter.type() != javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT.class) {
+                    av0.visit("type", org.objectweb.asm.Type.getType(getClassCode(adapter.type())));
+                }
+                av0.visitEnd();
+            } else if (ann instanceof XmlAttachmentRef) {
+                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlAttachmentRef;", true);
+                av0.visitEnd();
+            } else if (ann instanceof XmlList) {
+                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
+                av0.visitEnd();
+            }
+
+        }
+
+        fv.visitEnd();
+
+        String methodName = StringUtils.capitalize(name);
+
+        MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "get" + methodName, "()" + classCode, null,
+                                          null);
+        mv.visitCode();
+
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        mv.visitFieldInsn(Opcodes.GETFIELD, classFileName, fieldName, classCode);
+        mv.visitInsn(org.objectweb.asm.Type.getType(classCode).getOpcode(Opcodes.IRETURN));
+        mv.visitMaxs(0, 0);
+        mv.visitEnd();
+        
+        mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "set" + methodName, "(" + classCode + ")V", null, null);
+        mv.visitCode();
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        org.objectweb.asm.Type setType = org.objectweb.asm.Type.getType(classCode);
+        mv.visitVarInsn(setType.getOpcode(Opcodes.ILOAD), 1);
+        mv.visitFieldInsn(Opcodes.PUTFIELD, className, fieldName, classCode);       
+        mv.visitInsn(Opcodes.RETURN);
+        mv.visitMaxs(0, 0);
+        mv.visitEnd();
+
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/util/ASMHelper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/util/ASMHelper.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/util/ASMHelper.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/util/ASMHelper.java Fri Feb 22 18:55:53 2008
@@ -1,183 +1,183 @@
-/**
- * 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.cxf.jaxws.util;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.cxf.common.util.WeakIdentityHashMap;
-import org.objectweb.asm.ClassWriter;
-
-public class ASMHelper {
-    protected static final Map<Class<?>, String> PRIMITIVE_MAP = new HashMap<Class<?>, String>();
-    protected static final Map<Class<?>, String> NONPRIMITIVE_MAP = new HashMap<Class<?>, String>();
-    
-    protected static final Map<Class<?>, TypeHelperClassLoader> LOADER_MAP 
-        = new WeakIdentityHashMap<Class<?>, TypeHelperClassLoader>();
-    
-    protected static boolean oldASM;
-    
-    static {
-        PRIMITIVE_MAP.put(Byte.TYPE, "B");
-        PRIMITIVE_MAP.put(Boolean.TYPE, "Z");
-        PRIMITIVE_MAP.put(Long.TYPE, "J");
-        PRIMITIVE_MAP.put(Integer.TYPE, "I");
-        PRIMITIVE_MAP.put(Short.TYPE, "S");
-        PRIMITIVE_MAP.put(Character.TYPE, "C");
-        PRIMITIVE_MAP.put(Float.TYPE, "F");
-        PRIMITIVE_MAP.put(Double.TYPE, "D");
-
-        NONPRIMITIVE_MAP.put(Byte.TYPE, Byte.class.getName().replaceAll("\\.", "/"));
-        NONPRIMITIVE_MAP.put(Boolean.TYPE, Boolean.class.getName().replaceAll("\\.", "/"));
-        NONPRIMITIVE_MAP.put(Long.TYPE, Long.class.getName().replaceAll("\\.", "/"));
-        NONPRIMITIVE_MAP.put(Integer.TYPE, Integer.class.getName().replaceAll("\\.", "/"));
-        NONPRIMITIVE_MAP.put(Short.TYPE, Short.class.getName().replaceAll("\\.", "/"));
-        NONPRIMITIVE_MAP.put(Character.TYPE, Character.class.getName().replaceAll("\\.", "/"));
-        NONPRIMITIVE_MAP.put(Float.TYPE, Float.class.getName().replaceAll("\\.", "/"));
-        NONPRIMITIVE_MAP.put(Double.TYPE, Double.class.getName().replaceAll("\\.", "/"));
-    }
-    
-    protected static String getMethodSignature(Method m) {
-        StringBuffer buf = new StringBuffer("(");
-        for (Class<?> cl : m.getParameterTypes()) {
-            buf.append(getClassCode(cl));
-        }
-        buf.append(")");
-        buf.append(getClassCode(m.getReturnType()));
-        
-        return buf.toString();
-    }
-    
-    protected static String periodToSlashes(String s) {
-        char ch[] = s.toCharArray();
-        for (int x = 0; x < ch.length; x++) {
-            if (ch[x] == '.') {
-                ch[x] = '/';
-            }
-        }
-        return new String(ch);
-    }
-    
-    
-    public static String getClassCode(Class<?> cl) {
-        if (cl == Void.TYPE) {
-            return "V";
-        }
-        if (cl.isPrimitive()) {
-            return PRIMITIVE_MAP.get(cl);
-        }
-        if (cl.isArray()) {
-            return "[" + getClassCode(cl.getComponentType());
-        }
-        return "L" + periodToSlashes(cl.getName()) + ";";
-    }
-    
-    
-    public ClassWriter createClassWriter() {
-        ClassWriter newCw = null;
-        if (!oldASM) {
-            Class<ClassWriter> cls = ClassWriter.class;
-            try {
-                // ASM 1.5.x/2.x
-                Constructor<ClassWriter> cons = cls.getConstructor(new Class<?>[] {Boolean.TYPE});
-                
-                try {
-                    // got constructor, now check if it's 1.x which is very
-                    // different from 2.x and 3.x
-                    cls.getMethod("newConstInt", new Class<?>[] {Integer.TYPE});               
-                    // newConstInt was removed in 2.x, if we get this far, we're
-                    // using 1.5.x,
-                    // set to null so we don't attempt to use it.
-                    newCw = null;    
-                    oldASM = true;
-                } catch (Throwable t) {
-                    newCw = cons.newInstance(new Object[] {Boolean.TRUE});
-                }
-                
-            } catch (Throwable e) {
-                // ASM 3.x
-                try {
-                    Constructor<ClassWriter> cons = cls.getConstructor(new Class<?>[] {Integer.TYPE});
-                    int i = cls.getField("COMPUTE_MAXS").getInt(null);
-                    i |= cls.getField("COMPUTE_FRAMES").getInt(null);
-                    newCw = cons.newInstance(new Object[] {Integer.valueOf(i)});
-                } catch (Throwable e1) {
-                    // ignore
-                }
-                
-            }
-        }
-        return newCw;
-    }
-    
-    
-    public Class<?> loadClass(String className, Class clz , byte[] bytes) { 
-        TypeHelperClassLoader loader = getTypeHelperClassLoader(clz);
-        return loader.defineClass(className, bytes);
-    }
-    public Class<?> findClass(String className, Class clz) { 
-        TypeHelperClassLoader loader = getTypeHelperClassLoader(clz);
-        return loader.lookupDefinedClass(className);
-    }
-    
-    private static synchronized TypeHelperClassLoader getTypeHelperClassLoader(Class<?> l) {
-        TypeHelperClassLoader ret = LOADER_MAP.get(l);
-        if (ret == null) {
-            ret = new TypeHelperClassLoader(l.getClassLoader());
-            LOADER_MAP.put(l, ret);
-        }
-        return ret;
-    }
-    
-    public static class TypeHelperClassLoader extends ClassLoader {
-        Map<String, Class<?>> defined = new ConcurrentHashMap<String, Class<?>>();
-        
-        TypeHelperClassLoader(ClassLoader parent) {
-            super(parent);
-        }
-        public Class<?> lookupDefinedClass(String name) {
-            return defined.get(name);
-        }
-        
-        public Class<?> defineClass(String name, byte bytes[]) {
-            if (name.endsWith("package-info")) {
-                Package p = super.getPackage(name.substring(0, name.length() - 13));
-                if (p == null) {
-                    definePackage(name.substring(0, name.length() - 13),
-                                    null,
-                                    null,
-                                    null, 
-                                    null,
-                                    null,
-                                    null,
-                                    null);
-                }
-            }
-            
-            Class<?> ret = super.defineClass(name, bytes, 0, bytes.length);
-            defined.put(name, ret);
-            return ret;
-        }
-    }
-    
-}
+/**
+ * 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.cxf.jaxws.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.cxf.common.util.WeakIdentityHashMap;
+import org.objectweb.asm.ClassWriter;
+
+public class ASMHelper {
+    protected static final Map<Class<?>, String> PRIMITIVE_MAP = new HashMap<Class<?>, String>();
+    protected static final Map<Class<?>, String> NONPRIMITIVE_MAP = new HashMap<Class<?>, String>();
+    
+    protected static final Map<Class<?>, TypeHelperClassLoader> LOADER_MAP 
+        = new WeakIdentityHashMap<Class<?>, TypeHelperClassLoader>();
+    
+    protected static boolean oldASM;
+    
+    static {
+        PRIMITIVE_MAP.put(Byte.TYPE, "B");
+        PRIMITIVE_MAP.put(Boolean.TYPE, "Z");
+        PRIMITIVE_MAP.put(Long.TYPE, "J");
+        PRIMITIVE_MAP.put(Integer.TYPE, "I");
+        PRIMITIVE_MAP.put(Short.TYPE, "S");
+        PRIMITIVE_MAP.put(Character.TYPE, "C");
+        PRIMITIVE_MAP.put(Float.TYPE, "F");
+        PRIMITIVE_MAP.put(Double.TYPE, "D");
+
+        NONPRIMITIVE_MAP.put(Byte.TYPE, Byte.class.getName().replaceAll("\\.", "/"));
+        NONPRIMITIVE_MAP.put(Boolean.TYPE, Boolean.class.getName().replaceAll("\\.", "/"));
+        NONPRIMITIVE_MAP.put(Long.TYPE, Long.class.getName().replaceAll("\\.", "/"));
+        NONPRIMITIVE_MAP.put(Integer.TYPE, Integer.class.getName().replaceAll("\\.", "/"));
+        NONPRIMITIVE_MAP.put(Short.TYPE, Short.class.getName().replaceAll("\\.", "/"));
+        NONPRIMITIVE_MAP.put(Character.TYPE, Character.class.getName().replaceAll("\\.", "/"));
+        NONPRIMITIVE_MAP.put(Float.TYPE, Float.class.getName().replaceAll("\\.", "/"));
+        NONPRIMITIVE_MAP.put(Double.TYPE, Double.class.getName().replaceAll("\\.", "/"));
+    }
+    
+    protected static String getMethodSignature(Method m) {
+        StringBuffer buf = new StringBuffer("(");
+        for (Class<?> cl : m.getParameterTypes()) {
+            buf.append(getClassCode(cl));
+        }
+        buf.append(")");
+        buf.append(getClassCode(m.getReturnType()));
+        
+        return buf.toString();
+    }
+    
+    protected static String periodToSlashes(String s) {
+        char ch[] = s.toCharArray();
+        for (int x = 0; x < ch.length; x++) {
+            if (ch[x] == '.') {
+                ch[x] = '/';
+            }
+        }
+        return new String(ch);
+    }
+    
+    
+    public static String getClassCode(Class<?> cl) {
+        if (cl == Void.TYPE) {
+            return "V";
+        }
+        if (cl.isPrimitive()) {
+            return PRIMITIVE_MAP.get(cl);
+        }
+        if (cl.isArray()) {
+            return "[" + getClassCode(cl.getComponentType());
+        }
+        return "L" + periodToSlashes(cl.getName()) + ";";
+    }
+    
+    
+    public ClassWriter createClassWriter() {
+        ClassWriter newCw = null;
+        if (!oldASM) {
+            Class<ClassWriter> cls = ClassWriter.class;
+            try {
+                // ASM 1.5.x/2.x
+                Constructor<ClassWriter> cons = cls.getConstructor(new Class<?>[] {Boolean.TYPE});
+                
+                try {
+                    // got constructor, now check if it's 1.x which is very
+                    // different from 2.x and 3.x
+                    cls.getMethod("newConstInt", new Class<?>[] {Integer.TYPE});               
+                    // newConstInt was removed in 2.x, if we get this far, we're
+                    // using 1.5.x,
+                    // set to null so we don't attempt to use it.
+                    newCw = null;    
+                    oldASM = true;
+                } catch (Throwable t) {
+                    newCw = cons.newInstance(new Object[] {Boolean.TRUE});
+                }
+                
+            } catch (Throwable e) {
+                // ASM 3.x
+                try {
+                    Constructor<ClassWriter> cons = cls.getConstructor(new Class<?>[] {Integer.TYPE});
+                    int i = cls.getField("COMPUTE_MAXS").getInt(null);
+                    i |= cls.getField("COMPUTE_FRAMES").getInt(null);
+                    newCw = cons.newInstance(new Object[] {Integer.valueOf(i)});
+                } catch (Throwable e1) {
+                    // ignore
+                }
+                
+            }
+        }
+        return newCw;
+    }
+    
+    
+    public Class<?> loadClass(String className, Class clz , byte[] bytes) { 
+        TypeHelperClassLoader loader = getTypeHelperClassLoader(clz);
+        return loader.defineClass(className, bytes);
+    }
+    public Class<?> findClass(String className, Class clz) { 
+        TypeHelperClassLoader loader = getTypeHelperClassLoader(clz);
+        return loader.lookupDefinedClass(className);
+    }
+    
+    private static synchronized TypeHelperClassLoader getTypeHelperClassLoader(Class<?> l) {
+        TypeHelperClassLoader ret = LOADER_MAP.get(l);
+        if (ret == null) {
+            ret = new TypeHelperClassLoader(l.getClassLoader());
+            LOADER_MAP.put(l, ret);
+        }
+        return ret;
+    }
+    
+    public static class TypeHelperClassLoader extends ClassLoader {
+        Map<String, Class<?>> defined = new ConcurrentHashMap<String, Class<?>>();
+        
+        TypeHelperClassLoader(ClassLoader parent) {
+            super(parent);
+        }
+        public Class<?> lookupDefinedClass(String name) {
+            return defined.get(name);
+        }
+        
+        public Class<?> defineClass(String name, byte bytes[]) {
+            if (name.endsWith("package-info")) {
+                Package p = super.getPackage(name.substring(0, name.length() - 13));
+                if (p == null) {
+                    definePackage(name.substring(0, name.length() - 13),
+                                    null,
+                                    null,
+                                    null, 
+                                    null,
+                                    null,
+                                    null,
+                                    null);
+                }
+            }
+            
+            Class<?> ret = super.defineClass(name, bytes, 0, bytes.length);
+            defined.put(name, ret);
+            return ret;
+        }
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/util/ASMHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/util/ASMHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HelloWsa.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HelloWsa.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HelloWsa.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HelloWsa.java Fri Feb 22 18:55:53 2008
@@ -1,31 +1,31 @@
-/**
- * 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.cxf.jaxws;
-
-import javax.jws.WebService;
-import javax.xml.ws.soap.Addressing;
-
-@Addressing
-@WebService
-public class HelloWsa {
-    public int add(int arg0, int arg1) {
-        return arg0 + arg1;
-    }
-}
+/**
+ * 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.cxf.jaxws;
+
+import javax.jws.WebService;
+import javax.xml.ws.soap.Addressing;
+
+@Addressing
+@WebService
+public class HelloWsa {
+    public int add(int arg0, int arg1) {
+        return arg0 + arg1;
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HelloWsa.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HelloWsa.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java Fri Feb 22 18:55:53 2008
@@ -1,71 +1,71 @@
-/**
- * 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.cxf.jaxws;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.ws.Endpoint;
-
-import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.interceptor.LoggingOutInterceptor;
-import org.apache.cxf.jaxws.service.AddNumbers;
-import org.apache.cxf.jaxws.service.AddNumbersImpl;
-import org.junit.Test;
-
-
-public class SEIWithJAXBAnnoTest extends AbstractJaxWsTest {
-    String address = "http://localhost:9000/Hello";
-
-    
-    @Test
-    public void testXMLList() throws Exception {
-        
-        AddNumbersImpl serviceImpl = new AddNumbersImpl();
-        Endpoint.publish("http://localhost:9000/Hello", serviceImpl);
-        
-        
-     
-        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
-        factory.setBus(SpringBusFactory.getDefaultBus());
-        factory.setServiceClass(AddNumbers.class);
-        
-
-        factory.setAddress(address);
-        AddNumbers proxy = (AddNumbers)factory.create();
-        StringWriter strWriter = new StringWriter();
-        LoggingOutInterceptor log = new LoggingOutInterceptor(new PrintWriter(strWriter));
-        factory.getClientFactoryBean().getClient().getOutInterceptors().add(log);
-        
-        List<String> args = new ArrayList<String>();
-        args.add("str1");
-        args.add("str2");
-        args.add("str3");
-        List<Integer> result = proxy.addNumbers(args);
-        String expected = "<ns2:addNumbers xmlns:ns2=\"http://service.jaxws.cxf.apache.org/\">" 
-            + "<arg0>str1 str2 str3</arg0></ns2:addNumbers>";
-        assertTrue("Client does not use the generated wrapper class to marshal request parameters",
-                     strWriter.toString().indexOf(expected) > -1);
-        assertEquals("Get the wrong result", 100, result.get(0));
-        
-    }    
-}
-
+/**
+ * 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.cxf.jaxws;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.service.AddNumbers;
+import org.apache.cxf.jaxws.service.AddNumbersImpl;
+import org.junit.Test;
+
+
+public class SEIWithJAXBAnnoTest extends AbstractJaxWsTest {
+    String address = "http://localhost:9000/Hello";
+
+    
+    @Test
+    public void testXMLList() throws Exception {
+        
+        AddNumbersImpl serviceImpl = new AddNumbersImpl();
+        Endpoint.publish("http://localhost:9000/Hello", serviceImpl);
+        
+        
+     
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setBus(SpringBusFactory.getDefaultBus());
+        factory.setServiceClass(AddNumbers.class);
+        
+
+        factory.setAddress(address);
+        AddNumbers proxy = (AddNumbers)factory.create();
+        StringWriter strWriter = new StringWriter();
+        LoggingOutInterceptor log = new LoggingOutInterceptor(new PrintWriter(strWriter));
+        factory.getClientFactoryBean().getClient().getOutInterceptors().add(log);
+        
+        List<String> args = new ArrayList<String>();
+        args.add("str1");
+        args.add("str2");
+        args.add("str3");
+        List<Integer> result = proxy.addNumbers(args);
+        String expected = "<ns2:addNumbers xmlns:ns2=\"http://service.jaxws.cxf.apache.org/\">" 
+            + "<arg0>str1 str2 str3</arg0></ns2:addNumbers>";
+        assertTrue("Client does not use the generated wrapper class to marshal request parameters",
+                     strWriter.toString().indexOf(expected) > -1);
+        assertEquals("Get the wrong result", 100, result.get(0));
+        
+    }    
+}
+

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/WrapperClassGeneratorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/WrapperClassGeneratorTest.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/WrapperClassGeneratorTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/WrapperClassGeneratorTest.java Fri Feb 22 18:55:53 2008
@@ -1,124 +1,124 @@
-/**
- * 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.cxf.jaxws;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.jaxws.interceptors.WrapperHelper;
-import org.apache.cxf.jaxws.service.AddNumbersImpl;
-import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
-import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
-import org.apache.cxf.service.Service;
-import org.apache.cxf.service.model.InterfaceInfo;
-import org.apache.cxf.service.model.OperationInfo;
-import org.apache.cxf.service.model.ServiceInfo;
-import org.junit.After;
-import org.junit.Assert;
-
-public class WrapperClassGeneratorTest extends Assert {
-    
-    @After
-    public void tearDown() {
-        BusFactory.setDefaultBus(null);
-    }
-    
-    @org.junit.Test
-    public void testForXmlList() throws Exception {
-        JaxWsImplementorInfo implInfo = 
-            new JaxWsImplementorInfo(AddNumbersImpl.class);
-        JaxWsServiceFactoryBean jaxwsFac = new JaxWsServiceFactoryBean(implInfo);
-        jaxwsFac.setBus(BusFactory.getDefaultBus());
-        Service service = jaxwsFac.create();
-        
-        
-        ServiceInfo serviceInfo =  service.getServiceInfos().get(0);
-        
-        InterfaceInfo interfaceInfo = serviceInfo.getInterface();
-        OperationInfo inf = interfaceInfo.getOperations().iterator().next();
-        Class requestClass = inf.getInput().getMessagePart(0).getTypeClass();
-        Class responseClass = inf.getOutput().getMessagePart(0).getTypeClass();
-                        
-        // Create request wrapper Object
-        List<String> partNames = Arrays.asList(new String[] {"arg0"});
-        List<String> elTypeNames = Arrays.asList(new String[] {"list"});
-        List<Class<?>> partClasses = Arrays.asList(new Class<?>[] {List.class});
-           
-        String className = requestClass.getName();
-        className = className.substring(0, className.lastIndexOf(".") + 1);
-        
-        WrapperHelper wh = WrapperHelper.createWrapperHelper(requestClass,
-                                                             partNames, elTypeNames, partClasses);        
-        
-        List<Object> paraList = new ArrayList<Object>();
-        List<String> valueList = new ArrayList<String>();
-        valueList.add("str1");
-        valueList.add("str2");
-        valueList.add("str3");
-        paraList.add(valueList);
-        Object requestObj = wh.createWrapperObject(paraList);
-        // Create response wrapper Object
-        
-        partNames = Arrays.asList(new String[] {"return"});
-        elTypeNames = Arrays.asList(new String[] {"list"});
-        partClasses = Arrays.asList(new Class<?>[] {List.class});
-           
-        className = responseClass.getName();
-        className = className.substring(0, className.lastIndexOf(".") + 1);
-        
-        wh = WrapperHelper.createWrapperHelper(responseClass,
-                                                             partNames, elTypeNames, partClasses);        
-        List<Object> resPara = new ArrayList<Object>();
-        List<Integer> intValueList = new ArrayList<Integer>();
-        intValueList.add(1);
-        intValueList.add(2);
-        intValueList.add(3);
-        resPara.add(intValueList);
-        Object responseObj = wh.createWrapperObject(resPara);
-              
-        JAXBContext jaxbContext = JAXBContext.newInstance(requestClass, responseClass);
-        java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
-        Marshaller marshaller = jaxbContext.createMarshaller();
-        
-        //check marshall wrapper
-        marshaller.marshal(requestObj, bout);      
-        String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" 
-            + "<ns2:addNumbers xmlns:ns2=\"http://service.jaxws.cxf.apache.org/\">" 
-            + "<arg0>str1 str2 str3</arg0></ns2:addNumbers>";
-
-        assertEquals("The generated request wrapper class does not contain the correct annotations", 
-                     expected, bout.toString());
-       
-        
-        bout.reset();
-        marshaller.marshal(responseObj, bout);       
-        expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" 
-            + "<ns2:addNumbersResponse xmlns:ns2=\"http://service.jaxws.cxf.apache.org/\">" 
-            + "<return>1</return><return>2</return><return>3</return></ns2:addNumbersResponse>";
-        assertEquals("The generated response wrapper class is not correct", expected,  bout.toString());
-     
-    }
-  
-}
+/**
+ * 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.cxf.jaxws;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.jaxws.interceptors.WrapperHelper;
+import org.apache.cxf.jaxws.service.AddNumbersImpl;
+import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.junit.After;
+import org.junit.Assert;
+
+public class WrapperClassGeneratorTest extends Assert {
+    
+    @After
+    public void tearDown() {
+        BusFactory.setDefaultBus(null);
+    }
+    
+    @org.junit.Test
+    public void testForXmlList() throws Exception {
+        JaxWsImplementorInfo implInfo = 
+            new JaxWsImplementorInfo(AddNumbersImpl.class);
+        JaxWsServiceFactoryBean jaxwsFac = new JaxWsServiceFactoryBean(implInfo);
+        jaxwsFac.setBus(BusFactory.getDefaultBus());
+        Service service = jaxwsFac.create();
+        
+        
+        ServiceInfo serviceInfo =  service.getServiceInfos().get(0);
+        
+        InterfaceInfo interfaceInfo = serviceInfo.getInterface();
+        OperationInfo inf = interfaceInfo.getOperations().iterator().next();
+        Class requestClass = inf.getInput().getMessagePart(0).getTypeClass();
+        Class responseClass = inf.getOutput().getMessagePart(0).getTypeClass();
+                        
+        // Create request wrapper Object
+        List<String> partNames = Arrays.asList(new String[] {"arg0"});
+        List<String> elTypeNames = Arrays.asList(new String[] {"list"});
+        List<Class<?>> partClasses = Arrays.asList(new Class<?>[] {List.class});
+           
+        String className = requestClass.getName();
+        className = className.substring(0, className.lastIndexOf(".") + 1);
+        
+        WrapperHelper wh = WrapperHelper.createWrapperHelper(requestClass,
+                                                             partNames, elTypeNames, partClasses);        
+        
+        List<Object> paraList = new ArrayList<Object>();
+        List<String> valueList = new ArrayList<String>();
+        valueList.add("str1");
+        valueList.add("str2");
+        valueList.add("str3");
+        paraList.add(valueList);
+        Object requestObj = wh.createWrapperObject(paraList);
+        // Create response wrapper Object
+        
+        partNames = Arrays.asList(new String[] {"return"});
+        elTypeNames = Arrays.asList(new String[] {"list"});
+        partClasses = Arrays.asList(new Class<?>[] {List.class});
+           
+        className = responseClass.getName();
+        className = className.substring(0, className.lastIndexOf(".") + 1);
+        
+        wh = WrapperHelper.createWrapperHelper(responseClass,
+                                                             partNames, elTypeNames, partClasses);        
+        List<Object> resPara = new ArrayList<Object>();
+        List<Integer> intValueList = new ArrayList<Integer>();
+        intValueList.add(1);
+        intValueList.add(2);
+        intValueList.add(3);
+        resPara.add(intValueList);
+        Object responseObj = wh.createWrapperObject(resPara);
+              
+        JAXBContext jaxbContext = JAXBContext.newInstance(requestClass, responseClass);
+        java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
+        Marshaller marshaller = jaxbContext.createMarshaller();
+        
+        //check marshall wrapper
+        marshaller.marshal(requestObj, bout);      
+        String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" 
+            + "<ns2:addNumbers xmlns:ns2=\"http://service.jaxws.cxf.apache.org/\">" 
+            + "<arg0>str1 str2 str3</arg0></ns2:addNumbers>";
+
+        assertEquals("The generated request wrapper class does not contain the correct annotations", 
+                     expected, bout.toString());
+       
+        
+        bout.reset();
+        marshaller.marshal(responseObj, bout);       
+        expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" 
+            + "<ns2:addNumbersResponse xmlns:ns2=\"http://service.jaxws.cxf.apache.org/\">" 
+            + "<return>1</return><return>2</return><return>3</return></ns2:addNumbersResponse>";
+        assertEquals("The generated response wrapper class is not correct", expected,  bout.toString());
+     
+    }
+  
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/WrapperClassGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/WrapperClassGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbers.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbers.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbers.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbers.java Fri Feb 22 18:55:53 2008
@@ -1,35 +1,35 @@
-/**
- * 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.cxf.jaxws.service;
-import java.util.List;
-
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebService;
-import javax.xml.bind.annotation.XmlList;
-
-@WebService
-public interface AddNumbers {
-    @WebMethod
-    List<Integer> addNumbers(
-                             @WebParam
-                             @XmlList
-                             List<String> arg);
-}
+/**
+ * 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.cxf.jaxws.service;
+import java.util.List;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlList;
+
+@WebService
+public interface AddNumbers {
+    @WebMethod
+    List<Integer> addNumbers(
+                             @WebParam
+                             @XmlList
+                             List<String> arg);
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbers.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java Fri Feb 22 18:55:53 2008
@@ -1,36 +1,36 @@
-/**
- * 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.cxf.jaxws.service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@javax.jws.WebService(endpointInterface = "org.apache.cxf.jaxws.service.AddNumbers")
-public class AddNumbersImpl implements AddNumbers {
-
-    public List<Integer> addNumbers(List<String> arg) {
-        List<Integer> res = new ArrayList<Integer>();
-        res.add(100);
-        res.add(200);
-        return res;
-
-    }
-
-}
+/**
+ * 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.cxf.jaxws.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@javax.jws.WebService(endpointInterface = "org.apache.cxf.jaxws.service.AddNumbers")
+public class AddNumbersImpl implements AddNumbers {
+
+    public List<Integer> addNumbers(List<String> arg) {
+        List<Integer> res = new ArrayList<Integer>();
+        res.add(100);
+        res.add(200);
+        return res;
+
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProverImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProverImplTest.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProverImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProverImplTest.java Fri Feb 22 18:55:53 2008
@@ -1,55 +1,55 @@
-/**
- * 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.cxf.jaxws.spi;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.ws.wsaddressing.W3CEndpointReference;
-
-import org.apache.cxf.BusFactory;
-import org.junit.After;
-
-
-public class ProverImplTest extends org.junit.Assert {
-    @org.junit.Test
-    public void testCreateW3CEpr() throws Exception {
-        QName serviceName = new QName("http://cxf.apache.org", "ServiceName");
-        QName portName = new QName("http://cxf.apache.org", "PortName");
-        ProviderImpl impl = new ProviderImpl();
-        W3CEndpointReference w3Epr = impl.createW3CEndpointReference("http://myaddress", serviceName,
-                                                                      portName, null, "wsdlLoc",
-                                                                      null);
-        
-        java.io.StringWriter sw = new java.io.StringWriter();
-        StreamResult result = new StreamResult(sw);
-        w3Epr.writeTo(result);
-        String expected = "<wsdl:definitions"; 
-        assertTrue("Embeded wsdl element is not generated", sw.toString().indexOf(expected) > -1);
-        
-
-    }
-    @After
-    public void tearDown() {
-        BusFactory.setDefaultBus(null);
-    }
-    
-    
-
-}
+/**
+ * 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.cxf.jaxws.spi;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.apache.cxf.BusFactory;
+import org.junit.After;
+
+
+public class ProverImplTest extends org.junit.Assert {
+    @org.junit.Test
+    public void testCreateW3CEpr() throws Exception {
+        QName serviceName = new QName("http://cxf.apache.org", "ServiceName");
+        QName portName = new QName("http://cxf.apache.org", "PortName");
+        ProviderImpl impl = new ProviderImpl();
+        W3CEndpointReference w3Epr = impl.createW3CEndpointReference("http://myaddress", serviceName,
+                                                                      portName, null, "wsdlLoc",
+                                                                      null);
+        
+        java.io.StringWriter sw = new java.io.StringWriter();
+        StreamResult result = new StreamResult(sw);
+        w3Epr.writeTo(result);
+        String expected = "<wsdl:definitions"; 
+        assertTrue("Embeded wsdl element is not generated", sw.toString().indexOf(expected) > -1);
+        
+
+    }
+    @After
+    public void tearDown() {
+        BusFactory.setDefaultBus(null);
+    }
+    
+    
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProverImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProverImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message