cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r446534 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/phase/ api/src/main/java/org/apache/cxf/wsdl/ common/src/main/java/org/apache/cxf/common/util/ common/src/main/java/org/apache/cxf/staxutils/ rt/bindings/soap/src/main/java...
Date Fri, 15 Sep 2006 07:20:57 GMT
Author: ffang
Date: Fri Sep 15 00:20:56 2006
New Revision: 446534

URL: http://svn.apache.org/viewvc?view=rev&rev=446534
Log:
[JIRA CXF-67] get callback working

Added:
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback_test.wsdl
      - copied, changed from r443185, incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback.wsdl
Removed:
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback.wsdl
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
    incubator/cxf/trunk/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java
    incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataReaderFactory.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
    incubator/cxf/trunk/testutils/pom.xml
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
Fri Sep 15 00:20:56 2006
@@ -129,6 +129,7 @@
                 if (LOG.isLoggable(Level.FINE)) {
                     LOG.fine("Invoking handleMessage on interceptor " + currentInterceptor);
                 }
+                //System.out.println("current interceptor is " + currentInterceptor.getClass().getName());
                 currentInterceptor.handleMessage(message);
             } catch (Exception ex) {
                 if (LOG.isLoggable(Level.INFO)) {

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Fri Sep 15 00:20:56 2006
@@ -22,17 +22,14 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.WeakHashMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.jws.WebService;
 import javax.wsdl.Definition;
-import javax.wsdl.Import;
 import javax.wsdl.Port;
 import javax.wsdl.Service;
-import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
 import javax.xml.XMLConstants;
 import javax.xml.bind.JAXBElement;
@@ -55,9 +52,13 @@
 
 import org.xml.sax.SAXException;
 
+
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
+//import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.ws.addressing.AttributedURIType;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.apache.cxf.ws.addressing.MetadataType;
@@ -70,7 +71,7 @@
  */
 public final class EndpointReferenceUtils {
 
-    static WeakHashMap<Definition, Schema> schemaMap = new WeakHashMap<Definition,
Schema>();
+    static WeakHashMap<ServiceInfo, Schema> schemaMap = new WeakHashMap<ServiceInfo,
Schema>();
 
     private static final Logger LOG = LogUtils.getL7dLogger(EndpointReferenceUtils.class);
 
@@ -386,56 +387,24 @@
         return null;
     }
 
-    private static List<javax.wsdl.extensions.schema.Schema> getSchemas(Definition
definition) {
-        Types types = definition.getTypes();
-        List<javax.wsdl.extensions.schema.Schema> schemaList = 
-            new ArrayList<javax.wsdl.extensions.schema.Schema>();
-        if (types != null) {
-            for (Object o : types.getExtensibilityElements()) {
-                if (o instanceof javax.wsdl.extensions.schema.Schema) {
-                    javax.wsdl.extensions.schema.Schema s =
-                        (javax.wsdl.extensions.schema.Schema)o;
-                    schemaList.add(s);
-                }
-            }
-        }
-
-        Map wsdlImports = definition.getImports();
-        for (Object o : wsdlImports.values()) {
-            if (o instanceof List) {
-                for (Object p : (List)o) {
-                    if (p instanceof Import) {
-                        schemaList.addAll(getSchemas(((Import)p).getDefinition()));
-                    }
-                }
-            }
-        }
-        return schemaList;
-    }
-
-    public static Schema getSchema(WSDLManager manager, EndpointReferenceType ref) {
-        Definition definition;
-        try {
-            definition = getWSDLDefinition(manager, ref);
-        } catch (javax.wsdl.WSDLException wsdlEx) {
-            return null;
-        }
-        if (definition == null) {
+    
+    
+    public static Schema getSchema(ServiceInfo serviceInfo) {
+        if (serviceInfo == null) {
             return null;
         }
         synchronized (schemaMap) {
-            if (schemaMap.containsKey(definition)) {
-                return schemaMap.get(definition);
+            if (schemaMap.containsKey(serviceInfo)) {
+                return schemaMap.get(serviceInfo);
             }
         }
-        Schema schema = schemaMap.get(definition);
+        Schema schema = schemaMap.get(serviceInfo);
         if (schema == null) {
-            List<javax.wsdl.extensions.schema.Schema> schemas = getSchemas(definition);
             SchemaFactory factory = SchemaFactory.newInstance(
                 XMLConstants.W3C_XML_SCHEMA_NS_URI);
             List<Source> schemaSources = new ArrayList<Source>();
-            for (javax.wsdl.extensions.schema.Schema s : schemas) {
-                Source source = new DOMSource(s.getElement());
+            for (SchemaInfo schemaInfo : serviceInfo.getTypeInfo().getSchemas()) {
+                Source source = new DOMSource(schemaInfo.getElement());
                 if (source != null) {
                     schemaSources.add(source);
                 }
@@ -445,9 +414,9 @@
                     new Source[schemaSources.size()]));
                 if (schema != null) {
                     synchronized (schemaMap) {
-                        schemaMap.put(definition, schema);
+                        schemaMap.put(serviceInfo, schema);
                     }
-                    LOG.log(Level.FINE, "Obtained schema from wsdl definition");
+                    LOG.log(Level.FINE, "Obtained schema from ServiceInfo");
                 }
             } catch (SAXException ex) {
                 // Something not right with the schema from the wsdl.
@@ -455,8 +424,10 @@
             }
         }
         return schema;
+
     }
     
+
     /**
      * Gets the WSDL port for the provided endpoint reference.
      * @param manager - the WSDL manager 

Modified: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java
(original)
+++ incubator/cxf/trunk/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java
Fri Sep 15 00:20:56 2006
@@ -19,8 +19,26 @@
 
 package org.apache.cxf.common.util;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+
 public final class PackageUtils {
     
+    private static final Set<String> KEYWORDS = new HashSet<String>(Arrays
+        .asList(new String[] {"abstract", "boolean", "break", "byte", "case", "catch", "char",
"class",
+                              "const", "continue", "default", "do", "double", "else", "extends",
"final",
+                              "finally", "float", "for", "goto", "if", "implements", "import",
"instanceof",
+                              "int", "interface", "long", "native", "new", "package", "private",
"protected",
+                              "public", "return", "short", "static", "strictfp", "super",
"switch",
+                              "synchronized", "this", "throw", "throws", "transient", "try",
"void",
+                              "volatile", "while", "true", "false", "null", "assert", "enum"}));
+
+    
     private PackageUtils() {
         
     }
@@ -39,5 +57,125 @@
         return getPackageName(className);
     }
     
+    public static String parsePackageName(String namespace, String defaultPackageName) {
+        String packageName = (defaultPackageName != null && defaultPackageName.trim().length()
> 0)
+            ? defaultPackageName : null;
+
+        if (packageName == null) {
+            packageName = getPackageNameByNameSpaceURI(namespace);
+        }
+        return packageName;
+    }
+    
+    public static String getPackageNameByNameSpaceURI(String nameSpaceURI) {
+        int idx = nameSpaceURI.indexOf(':');
+        String scheme = "";
+        if (idx >= 0) {
+            scheme = nameSpaceURI.substring(0, idx);
+            if ("http".equalsIgnoreCase(scheme) || "urn".equalsIgnoreCase(scheme)) {
+                nameSpaceURI = nameSpaceURI.substring(idx + 1);
+            }
+        }
+
+        List<String> tokens = tokenize(nameSpaceURI, "/: ");
+        if (tokens.size() == 0) {
+            return null;
+        }
+
+        if (tokens.size() > 1) {
+            String lastToken = tokens.get(tokens.size() - 1);
+            idx = lastToken.lastIndexOf('.');
+            if (idx > 0) {
+                lastToken = lastToken.substring(0, idx);
+                tokens.set(tokens.size() - 1, lastToken);
+            }
+        }
+
+        String domain = tokens.get(0);
+        idx = domain.indexOf(':');
+        if (idx >= 0) {
+            domain = domain.substring(0, idx);
+        }
+        List<String> r = reverse(tokenize(domain, "urn".equals(scheme) ? ".-" : "."));
+        if ("www".equalsIgnoreCase(r.get(r.size() - 1))) {
+            // remove leading www
+            r.remove(r.size() - 1);
+        }
+
+        // replace the domain name with tokenized items
+        tokens.addAll(1, r);
+        tokens.remove(0);
+
+        // iterate through the tokens and apply xml->java name algorithm
+        for (int i = 0; i < tokens.size(); i++) {
+
+            // get the token and remove illegal chars
+            String token = tokens.get(i);
+            token = removeIllegalIdentifierChars(token);
+
+            // this will check for reserved keywords
+            if (contiansReservedKeywords(token)) {
+                token = '_' + token;
+            }
+
+            tokens.set(i, token.toLowerCase());
+        }
+
+        // concat all the pieces and return it
+        return combine(tokens, '.');
+    }
+
+    private static List<String> tokenize(String str, String sep) {
+        StringTokenizer tokens = new StringTokenizer(str, sep);
+        List<String> r = new ArrayList<String>();
+
+        while (tokens.hasMoreTokens()) {
+            r.add(tokens.nextToken());
+        }
+        return r;
+    }
+
+    private static <T> List<T> reverse(List<T> a) {
+        List<T> r = new ArrayList<T>();
+
+        for (int i = a.size() - 1; i >= 0; i--) {
+            r.add(a.get(i));
+        }
+        return r;
+    }
+
+    private static String removeIllegalIdentifierChars(String token) {
+        StringBuffer newToken = new StringBuffer();
+        for (int i = 0; i < token.length(); i++) {
+            char c = token.charAt(i);
+
+            if (i == 0 && !Character.isJavaIdentifierStart(c)) {
+                // prefix an '_' if the first char is illegal
+                newToken.append("_" + c);
+            } else if (!Character.isJavaIdentifierPart(c)) {
+                // replace the char with an '_' if it is illegal
+                newToken.append('_');
+            } else {
+                // add the legal char
+                newToken.append(c);
+            }
+        }
+        return newToken.toString();
+    }
+
+    private static String combine(List r, char sep) {
+        StringBuilder buf = new StringBuilder(r.get(0).toString());
+
+        for (int i = 1; i < r.size(); i++) {
+            buf.append(sep);
+            buf.append(r.get(i));
+        }
+
+        return buf.toString();
+    }
+
+    private static boolean contiansReservedKeywords(String token) {
+        return KEYWORDS.contains(token);
+    }
     
 }

Modified: incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ incubator/cxf/trunk/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Fri Sep
15 00:20:56 2006
@@ -20,7 +20,6 @@
 package org.apache.cxf.staxutils;
 
 import java.io.*;
-import java.util.*;
 import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Fri Sep 15 00:20:56 2006
@@ -35,6 +35,7 @@
 import org.apache.cxf.binding.soap.SoapVersionFactory;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
+//import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.staxutils.PartialXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -50,7 +51,7 @@
     public void handleMessage(SoapMessage message) {
         XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
      
-  
+        
         
         if (xmlReader == null) {
             InputStream in = (InputStream)message.getContent(InputStream.class);
@@ -61,6 +62,8 @@
         }
 
         try {
+            /*System.out.println("the xml fragment is ");
+            System.out.println(XMLUtils.toString(StaxUtils.read(xmlReader)));*/
             if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
                 String ns = xmlReader.getNamespaceURI();
                 SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
Fri Sep 15 00:20:56 2006
@@ -85,7 +85,6 @@
             
             // Calling for Wrapped/RPC/Doc/ Interceptor for writing SOAP body
             message.getInterceptorChain().doIntercept(message);
-
             xtw.writeEndElement();
             
             // Write Envelop end element
@@ -133,12 +132,7 @@
             Object[] args = objs.toArray();
             Object[] els = parts.toArray();
  
-            //should not have this assertion since jaxws-Holder may exist
-            /*if (args.length != els.length) {
-                message.setContent(Exception.class,
-                                   new RuntimeException("The number of arguments is not equal!"));
-            }*/
- 
+             
             SoapVersion soapVersion = message.getVersion();
             for (int idx = 0; idx < countParts; idx++) {
                 Object arg = args[idx];

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java
Fri Sep 15 00:20:56 2006
@@ -62,11 +62,7 @@
             Object[] args = objs.toArray();
             Object[] els = parts.toArray();
 
-            //should not have this assertion since jaxws-Holder may exist
-            /*if (args.length != els.length) {
-                message.setContent(Exception.class,
-                    new RuntimeException("The number of arguments is not equal!"));
-            }*/
+
                         
             for (int idx = 0; idx < countParts; idx++) {
                 Object arg = args[idx];

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
Fri Sep 15 00:20:56 2006
@@ -370,16 +370,21 @@
         MessageInfo unwrappedInput = new MessageInfo(opInfo, inputMessage.getName());
         MessageInfo unwrappedOutput = null;
 
-        XmlSchemaComplexType xsct = (XmlSchemaComplexType)inputEl.getSchemaType();
-        if (inputEl.getSchemaType() instanceof XmlSchemaComplexType
-            && (hasAttributes(xsct) || !isWrappableSequence(xsct, unwrappedInput)))
{
-            return;
+        XmlSchemaComplexType xsct = null;
+        if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
+            xsct = (XmlSchemaComplexType)inputEl.getSchemaType();
+            if (hasAttributes(xsct) || !isWrappableSequence(xsct, unwrappedInput)) {
+                return;
+            }
         }
         if (outputMessage != null) {
             unwrappedOutput = new MessageInfo(opInfo, outputMessage.getName());
-            xsct = (XmlSchemaComplexType)outputEl.getSchemaType();
-            if (outputEl != null && (hasAttributes(xsct) || !isWrappableSequence(xsct,
unwrappedOutput))) {
-                return;
+            
+            if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType)
{
+                xsct = (XmlSchemaComplexType)outputEl.getSchemaType();
+                if (hasAttributes(xsct) || !isWrappableSequence(xsct, unwrappedOutput)) {
+                    return;
+                }
             }
         }
 

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataReaderFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataReaderFactory.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataReaderFactory.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataReaderFactory.java
Fri Sep 15 00:20:56 2006
@@ -50,7 +50,7 @@
                                                                         XMLMessage.class};
     
     public JAXBDataReaderFactory() {
-        
+    
     }
 
     

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Fri Sep 15 00:20:56 2006
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxb;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Array;
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
@@ -31,6 +32,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.jws.WebMethod;
+import javax.jws.WebParam;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
@@ -58,39 +60,40 @@
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.interceptor.Fault;
 
-
 /**
  * JAXBEncoderDecoder
+ * 
  * @author apaibir
  */
 public final class JAXBEncoderDecoder {
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXBEncoderDecoder.class);
-    
+
     private static Map<Class<?>, JAXBContext> contextMap = new ConcurrentHashMap<Class<?>,
JAXBContext>();
-    
-    private JAXBEncoderDecoder() {        
+
+    private JAXBEncoderDecoder() {
     }
-    
+
     public static JAXBContext createJAXBContextForClass(Class<?> cls) throws JAXBException
{
         JAXBContext context = contextMap.get(cls);
         if (context == null) {
             Set<Class<?>> classes = new HashSet<Class<?>>();
             getClassesForContext(cls, classes, cls.getClassLoader());
-            
+
             try {
                 classes.add(Class.forName("org.apache.cxf.ws.addressing.wsdl.AttributedQNameType"));
                 classes.add(Class.forName("org.apache.cxf.ws.addressing.wsdl.ObjectFactory"));
                 classes.add(Class.forName("org.apache.cxf.ws.addressing.wsdl.ServiceNameType"));
             } catch (ClassNotFoundException e) {
-                //REVISIT - ignorable if WS-ADDRESSING not available?
-                //maybe add a way to allow interceptors to add stuff to the context?
+                // REVISIT - ignorable if WS-ADDRESSING not available?
+                // maybe add a way to allow interceptors to add stuff to the
+                // context?
             }
             context = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]));
             contextMap.put(cls, context);
         }
         return context;
     }
-    
+
     private static Class<?> getValidClass(Class<?> cls) {
         if (cls.isEnum()) {
             return cls;
@@ -115,7 +118,7 @@
         }
         return cls;
     }
-    
+
     private static void addClass(Class<?> cls, Set<Class<?>> classes) {
         if (cls.isArray()) {
             classes.add(cls);
@@ -134,12 +137,12 @@
                     classes.add(cls);
                 }
             } catch (ClassNotFoundException ex) {
-                //cannot add factory, just add the class
+                // cannot add factory, just add the class
                 classes.add(cls);
             }
         }
     }
-    
+
     private static void addType(Type cls, Set<Class<?>> classes) {
         if (cls instanceof Class) {
             addClass((Class)cls, classes);
@@ -152,11 +155,9 @@
             addType(gt.getGenericComponentType(), classes);
         }
     }
-    
-    //collect ALL the classes that are accessed by the class
-    private static void getClassesForContext(Class<?> theClass, 
-                                             Set<Class<?>> classes, 
-                                             ClassLoader loader) {
+
+    // collect ALL the classes that are accessed by the class
+    private static void getClassesForContext(Class<?> theClass, Set<Class<?>>
classes, ClassLoader loader) {
         Method methods[] = theClass.getMethods();
         for (Method meth : methods) {
             WebEndpoint webEndpoint = meth.getAnnotation(WebEndpoint.class);
@@ -164,51 +165,74 @@
                 getClassesForContext(meth.getReturnType(), classes, loader);
             }
 
-            //only methods marked as WebMethods are interesting to us
+            // only methods marked as WebMethods are interesting to us
             WebMethod webMethod = meth.getAnnotation(WebMethod.class);
             if (webMethod == null) {
                 continue;
             }
-            
+
             for (Type t : meth.getGenericParameterTypes()) {
                 addType(t, classes);
             }
             addType(meth.getGenericReturnType(), classes);
-            
+
             if (meth.getReturnType().isArray()) {
                 addClass(meth.getReturnType(), classes);
             }
             for (Class<?> cls : meth.getParameterTypes()) {
                 addClass(cls, classes);
             }
-            
+
             for (Class<?> cls : meth.getExceptionTypes()) {
-                //addClass(cls, classes);
+                // addClass(cls, classes);
                 try {
                     Method fim = cls.getMethod("getFaultInfo", new Class[0]);
                     addClass(fim.getReturnType(), classes);
                 } catch (NoSuchMethodException ex) {
-                    //ignore - not a valid JAXB fault thing
+                    // ignore - not a valid JAXB fault thing
                 }
             }
             try {
-                //Get the RequestWrapper
+                // Get the RequestWrapper
                 RequestWrapper reqWrapper = meth.getAnnotation(RequestWrapper.class);
                 if (reqWrapper != null) {
-                    Class<?> cls = Class.forName(reqWrapper.className(), false,
-                                        loader);
+                    Class<?> cls = Class.forName(reqWrapper.className(), false, loader);
                     addClass(cls, classes);
+
                 }
-                //Get the RequestWrapper
+                // Get the RequestWrapper
+
                 ResponseWrapper respWrapper = meth.getAnnotation(ResponseWrapper.class);
                 if (respWrapper != null) {
-                    Class<?> cls = Class.forName(respWrapper.className(),
-                                              false,
-                                              loader);
+                    Class<?> cls = Class.forName(respWrapper.className(), false, loader);
                     addClass(cls, classes);
                 }
             } catch (ClassNotFoundException ex) {
-                //ignore
+                // ignore
+            }
+            // get ObjectFactory in case of bare
+
+            Annotation[][] parasAnnotation = meth.getParameterAnnotations();
+            String packageName = null;
+            for (int i = 0; i < parasAnnotation.length; i++) {
+                Annotation[] paraAnno = parasAnnotation[i];
+                for (int j = 0; j < paraAnno.length; j++) {
+                    if (paraAnno[j].annotationType() == WebParam.class) {
+                     
+                        packageName = ((WebParam)paraAnno[j]).targetNamespace();
+                        packageName = PackageUtils.parsePackageName(packageName, null);
+
+                        try {
+                            Class<?> cls = Class.forName(packageName + ".ObjectFactory",
false, theClass
+                                .getClassLoader());
+                            if (cls != null) {
+                                classes.add(cls);
+                            }
+                        } catch (ClassNotFoundException ex) {
+                            // ignore
+                        }
+                    }
+                }
             }
         }
 
@@ -219,38 +243,36 @@
             getClassesForContext(theClass.getSuperclass(), classes, loader);
         }
     }
-    
-    private static Marshaller createMarshaller(JAXBContext context,
-                                               Class<?> cls) throws JAXBException {
+
+    private static Marshaller createMarshaller(JAXBContext context, Class<?> cls) throws
JAXBException {
         Marshaller jm = null;
         if (context == null) {
             context = JAXBContext.newInstance(cls);
         }
-        
+
         jm = context.createMarshaller();
-        jm.setProperty(Marshaller.JAXB_ENCODING , "UTF-8");
+        jm.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
         jm.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-        
+
         return jm;
     }
-    
-    public static void marshall(JAXBContext context, Schema schema,
-                                Object elValue, QName elNname,  
+
+    public static void marshall(JAXBContext context, Schema schema, Object elValue, QName
elNname,
                                 Object source, AttachmentMarshaller am) {
-        
+
         Class<?> cls = null != elValue ? elValue.getClass() : null;
         try {
             Marshaller u = createMarshaller(context, cls);
             try {
-                // The Marshaller.JAXB_FRAGMENT will tell the Marshaller not to generate
the xml declaration.
+                // The Marshaller.JAXB_FRAGMENT will tell the Marshaller not to
+                // generate the xml declaration.
                 u.setProperty(Marshaller.JAXB_FRAGMENT, true);
             } catch (javax.xml.bind.PropertyException e) {
                 // intentionally empty.
             }
-            Object mObj = elValue;      
+            Object mObj = elValue;
 
-            if (null != elNname && null != cls 
-                && !cls.isAnnotationPresent(XmlRootElement.class)) {
+            if (null != elNname && null != cls && !cls.isAnnotationPresent(XmlRootElement.class))
{
                 mObj = JAXBElement.class.getConstructor(new Class[] {QName.class, Class.class,
Object.class})
                     .newInstance(elNname, cls, mObj);
             }
@@ -272,25 +294,23 @@
         }
     }
 
-    public static void marshall(JAXBContext context, Schema schema,
-                                Object elValue, Object source) {
+    public static void marshall(JAXBContext context, Schema schema, Object elValue, Object
source) {
         marshall(context, schema, elValue, null, source, null);
     }
-    
-    public static void marshall(JAXBContext context, Schema schema,
-                                Object elValue, QName elNname, Object source) {
+
+    public static void marshall(JAXBContext context, Schema schema, Object elValue, QName
elNname,
+                                Object source) {
         marshall(context, schema, elValue, elNname, source, null);
     }
 
-    private static Unmarshaller createUnmarshaller(JAXBContext context,
-                                                   Class<?> cls) throws JAXBException
{
+    private static Unmarshaller createUnmarshaller(JAXBContext context, Class<?> cls)
throws JAXBException {
         Unmarshaller um = null;
         if (context == null) {
             context = JAXBContext.newInstance(cls);
         }
-        
-        um = context.createUnmarshaller();            
-        
+
+        um = context.createUnmarshaller();
+
         return um;
     }
 
@@ -298,36 +318,32 @@
         return unmarshall(context, schema, source, null, null, null);
     }
 
-    public static Object unmarshall(JAXBContext context, Schema schema,
-                                    Object source, QName elName) {
+    public static Object unmarshall(JAXBContext context, Schema schema, Object source, QName
elName) {
         return unmarshall(context, schema, source, elName, null, null);
     }
 
-    public static Object unmarshall(JAXBContext context, Schema schema,
-                                    Object source, QName elName, 
+    public static Object unmarshall(JAXBContext context, Schema schema, Object source, QName
elName,
                                     Class<?> clazz) {
         return unmarshall(context, schema, source, elName, clazz, null);
     }
-    
-    public static Object unmarshall(JAXBContext context, Schema schema,
-                                    Object source, QName elName, 
+
+    public static Object unmarshall(JAXBContext context, Schema schema, Object source, QName
elName,
                                     Class<?> clazz, AttachmentUnmarshaller au) {
         Object obj = null;
         try {
             Unmarshaller u = createUnmarshaller(context, clazz);
-            u.setSchema(schema);            
+            u.setSchema(schema);
             if (au != null) {
                 u.setAttachmentUnmarshaller(au);
             }
             if (source instanceof Node) {
-                obj = (clazz != null) ? u.unmarshal((Node)source, clazz) 
-                                  : u.unmarshal((Node)source);
+                obj = (clazz != null) ? u.unmarshal((Node)source, clazz) : u.unmarshal((Node)source);
             } else if (source instanceof XMLStreamReader) {
-                obj = (clazz != null) ? u.unmarshal((XMLStreamReader)source, clazz) 
-                    : u.unmarshal((XMLStreamReader)source);                
+                obj = (clazz != null) ? u.unmarshal((XMLStreamReader)source, clazz) : u
+                    .unmarshal((XMLStreamReader)source);
             } else if (source instanceof XMLEventReader) {
-                obj = (clazz != null) ? u.unmarshal((XMLEventReader)source, clazz) 
-                    : u.unmarshal((XMLEventReader)source);                              
 
+                obj = (clazz != null) ? u.unmarshal((XMLEventReader)source, clazz) : u
+                    .unmarshal((XMLEventReader)source);
             } else {
                 throw new Fault(new Message("UNKNOWN_SOURCE", BUNDLE, source.getClass().getName()));
             }
@@ -341,7 +357,7 @@
         if (null == obj) {
             return null;
         }
-        
+
         if (obj instanceof JAXBElement<?>) {
             JAXBElement<?> el = (JAXBElement<?>)obj;
             if (isSame(el.getName(), elName)) {
@@ -350,7 +366,7 @@
         }
         return obj;
     }
-    
+
     private static boolean isSame(QName messageQName, QName methodQName) {
         boolean same = false;
         if (StringUtils.isEmpty(messageQName.getNamespaceURI())) {
@@ -360,7 +376,7 @@
         }
         return same;
     }
-    
+
     public static Class<?> getClassFromType(Type t) {
         if (t instanceof Class) {
             return (Class)t;
@@ -371,7 +387,8 @@
             ParameterizedType p = (ParameterizedType)t;
             return getClassFromType(p.getRawType());
         }
-        //TypeVariable and WildCardType are not handled as it is unlikely such Types will

+        // TypeVariable and WildCardType are not handled as it is unlikely such
+        // Types will
         // JAXB Code Generated.
         assert false;
         throw new IllegalArgumentException("Cannot get Class object from unknown Type");

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
Fri Sep 15 00:20:56 2006
@@ -29,17 +29,28 @@
 
 import org.apache.callback.SOAPService;
 import org.apache.callback.ServerPortType;
+
 import org.apache.cxf.systest.common.ClientServerSetupBase;
 import org.apache.cxf.systest.common.ClientServerTestBase;
+
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
-import org.apache.cxf.wsdl11.WSDLManagerImpl;
 
 public class CallbackClientServerTest extends ClientServerTestBase {
     private static final QName SERVICE_NAME 
         = new QName("http://apache.org/callback", "SOAPService");
+    private static final QName SERVICE_NAME_CALLBACK 
+        = new QName("http://apache.org/callback", "CallbackService");
 
+    private static final QName PORT_NAME 
+        = new QName("http://apache.org/callback", "SOAPPort");
 
+    private static final QName PORT_NAME_CALLBACK 
+        = new QName("http://apache.org/callback", "CallbackPort");
+    
+    private static final QName PORT_TYPE_CALLBACK
+        = new QName("http://apache.org/callback", "CallbackPortType");
+    
     public static Test suite() throws Exception {
         TestSuite suite = new TestSuite(CallbackClientServerTest.class);
         return new ClientServerSetupBase(suite) {
@@ -48,25 +59,28 @@
             }
         };
         
+                
     }
 
-    public void xtestCallback() {
+    public void testCallback() throws Exception {
 
                     
         Object implementor = new CallbackImpl();
         String address = "http://localhost:9005/CallbackContext/CallbackPort";
         Endpoint.publish(address, implementor);
     
-        URL wsdlURL = getClass().getResource("/wsdl/basic_callback.wsdl");
+        URL wsdlURL = getClass().getResource("/wsdl/basic_callback_test.wsdl");
     
         SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
-        ServerPortType port = ss.getSOAPPort();
+        ServerPortType port = ss.getPort(PORT_NAME, ServerPortType.class);
    
         EndpointReferenceType ref = null;
         try {
-            ref = EndpointReferenceUtils.getEndpointReference(new WSDLManagerImpl(), implementor);
+            ref = EndpointReferenceUtils.getEndpointReference(wsdlURL, 
+                                                              SERVICE_NAME_CALLBACK, 
+                                                              PORT_NAME_CALLBACK.getLocalPart());
+            EndpointReferenceUtils.setInterfaceName(ref, PORT_TYPE_CALLBACK);
         } catch (Exception e) {
-            // TODO Auto-generated catch block
             e.printStackTrace();
         }
     
@@ -76,8 +90,5 @@
             
     }
     
-    public void testDummyCallback() throws Exception {
-        assertTrue(true);
-    }
-
+    
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
Fri Sep 15 00:20:56 2006
@@ -30,13 +30,13 @@
         Object implementor = new ServerImpl();
         String address = "http://localhost:9007/SoapContext/SoapPort";
         Endpoint.publish(address, implementor);
+        
     }
 
     public static void main(String[] args) {
         try { 
             Server s = new Server(); 
             s.start();
-            //s.run();
         } catch (Exception ex) {
             ex.printStackTrace();
             System.exit(-1);

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
Fri Sep 15 00:20:56 2006
@@ -37,7 +37,7 @@
                       portName = "SOAPPort",
                       targetNamespace = "http://apache.org/callback",
                       endpointInterface = "org.apache.callback.ServerPortType") 
-                      //wsdlLocation = "file:./wsdl/basic_callback.wsdl")
+                      
                   
 public class ServerImpl implements ServerPortType  {
 
@@ -89,5 +89,7 @@
         
         return "registerCallback called";     
     }
+
     
+        
 }    

Modified: incubator/cxf/trunk/testutils/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/pom.xml?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/testutils/pom.xml (original)
+++ incubator/cxf/trunk/testutils/pom.xml Fri Sep 15 00:20:56 2006
@@ -203,7 +203,7 @@
                                 </wsdlOption>
 
                                 <wsdlOption>
-                                    <wsdl>${basedir}/src/main/resources/wsdl/basic_callback.wsdl</wsdl>
+                                    <wsdl>${basedir}/src/main/resources/wsdl/basic_callback_test.wsdl</wsdl>
                                 </wsdlOption>
                                 
                                 <wsdlOption>

Copied: incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback_test.wsdl (from
r443185, incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback.wsdl)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback_test.wsdl?view=diff&rev=446534&p1=incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback.wsdl&r1=443185&p2=incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback_test.wsdl&r2=446534
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/basic_callback_test.wsdl Fri Sep
15 00:20:56 2006
@@ -95,7 +95,7 @@
     </wsdl:service>
     <wsdl:service name="SOAPService">
 	<wsdl:port binding="tns:ServerPortType_SOAPBinding" name="SOAPPort">
-	    <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+	    <soap:address location="http://localhost:9007/SoapContext/SoapPort"/>
 	</wsdl:port>
     </wsdl:service>
 </wsdl:definitions>

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java?view=diff&rev=446534&r1=446533&r2=446534
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jms/JMSAddressSerializer.java
Fri Sep 15 00:20:56 2006
@@ -20,7 +20,6 @@
 package org.apache.cxf.tools.common.extensions.jms;
 
 import java.io.*;
-import java.lang.reflect.*;
 
 import javax.wsdl.Definition;
 import javax.wsdl.WSDLException;



Mime
View raw message