cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r442162 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/databinding/ api/src/main/java/org/apache/cxf/endpoint/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/core/src/main/java/org/apache/cxf/endpoin...
Date Mon, 11 Sep 2006 10:11:16 GMT
Author: tli
Date: Mon Sep 11 03:11:15 2006
New Revision: 442162

URL: http://svn.apache.org/viewvc?view=rev&rev=442162
Log:
rollback modification on databinding api and jaxb, add RPCIn/Out Interceptors of soap binding

Removed:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBindingContext.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBindingContext.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBinding.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataFactoryBase.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/XMLStreamDataReader.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBinding.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBinding.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBinding.java Mon
Sep 11 03:11:15 2006
@@ -31,6 +31,5 @@
     DataWriterFactory getDataWriterFactory();
     
     Map<String, SchemaInfo> getSchemas(ServiceInfo serviceInfo);
-    
-    DataBindingContext getDataBindingContext();
+        
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java Mon Sep 11
03:11:15 2006
@@ -44,4 +44,6 @@
     Executor getExecutor();
     
     Interceptor getFaultInterceptor();
+    
+    Object getImplementor();
 }

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
Mon Sep 11 03:11:15 2006
@@ -17,80 +17,122 @@
  * under the License.
  */
 
-package org.apache.cxf.binding.soap.interceptor;
-
-import org.apache.cxf.interceptor.WrappedInInterceptor;
-
-public class RPCInInterceptor extends WrappedInInterceptor {
-//        
-//    private BindingOperationInfo getOperation(SoapMessage message, DepthXMLStreamReader
xmlReader) {
-//        if (!StaxUtils.toNextElement(xmlReader)) {
-//            message.setContent(Exception.class,
-//                               new RuntimeException("There must be a method name element."));
-//        }
-//
-//        String opName = xmlReader.getLocalName();
-//        if (!isInboundMessage(message) && opName.endsWith("Response")) {
-//            opName = opName.substring(0, opName.length() - 8);
-//        }
-//
-//        BindingOperationInfo operation = ServiceModelUtil.getOperation(message,
-//                                                                     new QName(xmlReader.getNamespaceURI(),
-//                                                                                 opName));
-//        if (operation == null) {
-//            message.setContent(Exception.class,
-//                               new RuntimeException("Could not find operation:" + opName));
-//        }
-//        return operation;
-//    }
-//
-//    public void handleMessage(Message message) {
-//        DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
-//        
-//        BindingOperationInfo operation = null;
-//        if (!isOperationResolved(message)) {
-//            operation = getOperation(message, xmlReader);
-//            // Store operation into the message.
-//            message.put(Message.INVOCATION_OPERATION, operation.getName().getLocalPart());
-//        }
-//
-//        MessageInfo msg;
-//        DataReader<XMLStreamReader> dr = getDataReader(message,
-//                                                       operation.getOperationInfo());
-//         
-//        if (isInboundMessage(message)) {
-//            msg = operation.getInput().getMessageInfo();
-//        } else {
-//            msg = operation.getOutput().getMessageInfo();
-//        }
-//
-//        List<Object> parameters = new ArrayList<Object>();
-//
-//        StaxUtils.nextEvent(xmlReader);
-//        while (StaxUtils.toNextElement(xmlReader)) {
-//            int idx = parameters.size();
-//            MessagePartInfo p = msg.getMessageParts().get(idx);
-//            if (p == null) {
-//                message.setContent(Exception.class,
-//                                   new RuntimeException("Parameter "
-//                                                        + xmlReader.getName()
-//                                                        + " does not exist!"));
-//            }
-//            QName name = xmlReader.getName();
-//            QName elName = ServiceModelUtil.getRPCPartName(p);
-//
-//            if (!elName.getLocalPart().equals(name.getLocalPart())) {
-//                String expMessage = "Parameter "
-//                    + name
-//                    + " does not equal to the name in the servicemodel!";
-//                message.setContent(Exception.class, new RuntimeException(expMessage));
-//            }
-//            parameters.add(dr.read(elName,
-//                                   xmlReader,
-//                                   getParameterTypeClass(message, idx)));
-//        }
-//        
-//        message.put(Message.INVOCATION_OBJECTS, parameters);
-//    }
-}
-
+package org.apache.cxf.binding.soap.interceptor;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.ServiceModelUtil;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.tools.util.ProcessorUtil;
+
+public class RPCInInterceptor extends AbstractInDatabindingInterceptor {
+
+    public RPCInInterceptor() {
+        super();
+        setPhase(Phase.UNMARSHAL);
+    }
+
+    private BindingOperationInfo getOperation(Message message, DepthXMLStreamReader xmlReader)
{
+        if (!StaxUtils.toNextElement(xmlReader)) {
+            message.setContent(Exception.class, new RuntimeException("There must be a method
name element."));
+        }
+
+        String opName = xmlReader.getLocalName();
+        if (isRequestor(message) && opName.endsWith("Response")) {
+            opName = opName.substring(0, opName.length() - 8);
+        }
+
+        BindingOperationInfo operation = ServiceModelUtil.getOperation(message.getExchange(),
new QName(
+                        xmlReader.getNamespaceURI(), opName));
+        if (operation == null) {
+            message.setContent(Exception.class, new RuntimeException("Could not find operation:"
+ opName));
+        }
+        return operation;
+    }
+
+    public void handleMessage(Message message) {
+        DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
+
+        BindingOperationInfo operation = null;
+        if (message.getExchange().get(BindingOperationInfo.class) == null) {
+            operation = getOperation(message, xmlReader);            
+            // Store operation into the message.
+            message.getExchange().put(BindingOperationInfo.class, operation);
+        }
+        findMethod(message);
+        MessageInfo msg;
+        DataReader<XMLStreamReader> dr = getDataReader(message);
+
+        if (!isRequestor(message)) {
+            msg = operation.getInput().getMessageInfo();
+        } else {
+            msg = operation.getOutput().getMessageInfo();
+        }
+
+        List<Object> parameters = new ArrayList<Object>();
+
+        StaxUtils.nextEvent(xmlReader);
+        while (StaxUtils.toNextElement(xmlReader)) {
+            int idx = parameters.size();
+            MessagePartInfo p = msg.getMessageParts().get(idx);
+            if (p == null) {
+                message.setContent(Exception.class, new RuntimeException("Parameter " + xmlReader.getName()
+                                + " does not exist!"));
+            }
+            QName name = xmlReader.getName();
+            QName elName = ServiceModelUtil.getRPCPartName(p);
+
+            if (!elName.getLocalPart().equals(name.getLocalPart())) {
+                String expMessage = "Parameter " + name + " does not equal to the name in
the servicemodel!";
+                message.setContent(Exception.class, new RuntimeException(expMessage));
+            }
+            Object param = dr.read(elName, xmlReader, getParameterTypeClass(message, idx));
+            parameters.add(param);
+        }
+        message.setContent(List.class, parameters);
+    }
+
+    private void findMethod(Message message) {
+        Endpoint ep = message.getExchange().get(Endpoint.class);
+        BindingOperationInfo boi = message.getExchange().get(BindingOperationInfo.class);
+        Class implementorClass = ep.getImplementor().getClass();
+        for (Method meth : implementorClass.getDeclaredMethods()) {
+            String opName = boi.getOperationInfo().getName().getLocalPart();
+            if (ProcessorUtil.mangleNameToVariableName(meth.getName()).equals(opName)) {
+                message.put(Method.class, meth);
+                break;
+            }
+        }
+    }
+
+    private Class getParameterTypeClass(Message message, int idx) {
+        Method method = message.get(Method.class);
+        BindingOperationInfo boi = message.getExchange().get(BindingOperationInfo.class);
+        MessageInfo mi;
+        if (!isRequestor(message)) {
+            mi = boi.getOperationInfo().getInput();
+        } else {
+            mi = boi.getOperationInfo().getOutput();
+        }
+        MessagePartInfo mpi = mi.getMessagePartByIndex(idx);
+        if (!mpi.isElement()) {
+            return method.getParameterTypes()[idx];
+        } else {
+            return null;
+        }
+    }
+}

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
Mon Sep 11 03:11:15 2006
@@ -17,128 +17,115 @@
  * under the License.
  */
 
-package org.apache.cxf.binding.soap.interceptor;
-
-import org.apache.cxf.interceptor.WrappedOutInterceptor;
-
-public class RPCOutInterceptor extends WrappedOutInterceptor {
-    
-//    public void handleMessage(SoapMessage message) {
-//        BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class);
-//        OperationInfo opInfo = bop.getOperationInfo();
-//        OperationInfo unwrapped = new UnwrappedOperationInfo(opInfo);
-//        opInfo.setUnwrappedOperation(unwrapped);
-//        unwrapped.setInput(opInfo.getInputName(), unwrappedInput);
-//    }
-//    
-//    private NSStack nsStack;
-//    
-//    private void init() {
-//        nsStack = new NSStack();
-//        nsStack.push();
-//    }
-//
-//    public void handleMessage(SoapMessage message) {
-//        try {
-//            init();
-//            
-//            BindingOperationInfo operation = ServiceModelUtil.getOperation(message,
-//                                                                           getOperationName(message));
-//
-//            assert operation.getName() != null;
-//            
-//            XMLStreamWriter xmlWriter = getXMLStreamWriter(message);
-//            DataWriter<XMLStreamWriter> dataWriter = getDataWriter(message, operation.getOperationInfo());
-//
-//            addOperationNode(message, xmlWriter);
-//
-//            int countParts = 0;
-//            List<MessagePartInfo> parts = null;
-//            
-//            if (isOutboundMessage(message)) {
-//                parts = operation.getOutput().getMessageInfo().getMessageParts();
-//            } else {
-//                parts = operation.getInput().getMessageInfo().getMessageParts();
-//            }
-//            countParts = parts.size();
-//
-//            if (countParts > 0) {
-//                List<?> objs = (List<?>) message.get(Message.INVOCATION_OBJECTS);
-//                Object[] args = objs.toArray();
-//                Object[] els  = parts.toArray();
-//
-//                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];
-//                    MessagePartInfo  part = (MessagePartInfo) els[idx];
-//                    QName elName = getPartName(part);
-//                    dataWriter.write(arg, elName, xmlWriter);
-//                }
-//            }
-//
-//            // Finishing the writing.
-//            xmlWriter.writeEndElement();
-//            xmlWriter.flush();
-//            xmlWriter.close();
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//            message.setContent(Exception.class, e);
-//        }
-//    }
-//
-//    private QName getPartName(MessagePartInfo part) {
-//        QName name = part.getElementQName();
-//        if (name == null) {
-//            name = part.getTypeQName();
-//        }
-//        return new QName(name.getNamespaceURI(), part.getName().getLocalPart());
-//    }
-//
-//    protected boolean isOutboundMessage(SoapMessage message) {
-//        return message.containsKey(Message.INBOUND_MESSAGE);
-//    }
-//
-//    protected DataWriter<XMLStreamWriter> getDataWriter(SoapMessage message, OperationInfo
oi) {
-//        String key = (String) message.getExchange().get(SoapMessage.DATAWRITER_FACTORY_KEY);
-//        DataWriterFactory factory = (DataWriterFactory) oi.getProperty(key);
-//
-//        DataWriter<XMLStreamWriter> dataWriter = null;
-//        for (Class<?> cls : factory.getSupportedFormats()) {
-//            if (cls == XMLStreamWriter.class) {
-//                dataWriter = factory.createWriter(XMLStreamWriter.class);
-//                break;
-//            }
-//        }
-//        if (dataWriter == null) {
-//            message.setContent(Exception.class,
-//                               new RuntimeException("Could not figure out how to marshal
data"));
-//        }        
-//        return dataWriter;
-//    }
-//    
-//    private String getOperationName(SoapMessage message) {
-//        return (String) message.get(Message.INVOCATION_OPERATION);
-//    }
-//
-//    protected void addOperationNode(SoapMessage message, XMLStreamWriter xmlWriter)
-//        throws XMLStreamException {
-//        String responseSuffix = isOutboundMessage(message) ? "Response" : "";
-//        String namespaceURI = ServiceModelUtil.getTargetNamespace(message);
-//        nsStack.add(namespaceURI);
-//        String prefix = nsStack.getPrefix(namespaceURI);
-//            
-//        String operationName = getOperationName(message) + responseSuffix;
-//            
-//        StaxUtils.writeStartElement(xmlWriter, prefix, operationName, namespaceURI);
-//        xmlWriter.flush();
-//    }
-//
-//    private XMLStreamWriter getXMLStreamWriter(Message message) {
-//        return message.getContent(XMLStreamWriter.class);
-//    }
-}
-
+package org.apache.cxf.binding.soap.interceptor;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.helpers.NSStack;
+import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.ServiceModelUtil;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class RPCOutInterceptor extends AbstractOutDatabindingInterceptor {
+
+    private NSStack nsStack;
+
+    public RPCOutInterceptor() {
+        super();
+        setPhase(Phase.MARSHAL);
+    }
+
+    private void init() {
+        nsStack = new NSStack();
+        nsStack.push();
+    }
+
+    public void handleMessage(Message message) {
+        try {
+            init();
+
+            BindingOperationInfo operation = (BindingOperationInfo) message.getExchange().get(
+                            BindingOperationInfo.class.getName());
+
+            assert operation.getName() != null;
+
+            XMLStreamWriter xmlWriter = getXMLStreamWriter(message);
+            DataWriter<XMLStreamWriter> dataWriter = getDataWriter(message);
+
+            addOperationNode(message, xmlWriter);
+
+            int countParts = 0;
+            List<MessagePartInfo> parts = null;
+
+            if (!isRequestor(message)) {
+                parts = operation.getOutput().getMessageInfo().getMessageParts();
+            } else {
+                parts = operation.getInput().getMessageInfo().getMessageParts();
+            }
+            countParts = parts.size();
+
+            if (countParts > 0) {
+                List<?> objs = (List<?>) message.getContent(List.class);
+                Object[] args = objs.toArray();
+                Object[] els = parts.toArray();
+
+                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];
+                    MessagePartInfo part = (MessagePartInfo) els[idx];
+                    QName elName = getPartName(part);
+                    dataWriter.write(arg, elName, xmlWriter);
+                }
+            }
+            // Finishing the writing.
+            xmlWriter.writeEndElement();            
+        } catch (Exception e) {
+            e.printStackTrace();
+            message.setContent(Exception.class, e);
+        }
+    }
+
+    protected void addOperationNode(Message message, XMLStreamWriter xmlWriter) throws XMLStreamException
{
+        String responseSuffix = !isRequestor(message) ? "Response" : "";
+        String namespaceURI = ServiceModelUtil.getTargetNamespace(message.getExchange());
+        nsStack.add(namespaceURI);
+        String prefix = nsStack.getPrefix(namespaceURI);
+
+        String operationName = getOperationName(message) + responseSuffix;
+
+        StaxUtils.writeStartElement(xmlWriter, prefix, operationName, namespaceURI);
+        xmlWriter.flush();
+    }
+
+    protected XMLStreamWriter getXMLStreamWriter(Message message) {
+        return message.getContent(XMLStreamWriter.class);
+    }
+
+    private String getOperationName(Message message) {
+        BindingOperationInfo boi = (BindingOperationInfo) message.getExchange().get(
+                        BindingOperationInfo.class);       
+        return boi.getOperationInfo().getName().getLocalPart();
+    }
+
+    private QName getPartName(MessagePartInfo part) {
+        QName name = part.getElementQName();
+        if (name == null) {
+            name = part.getTypeQName();
+        }
+        return new QName(name.getNamespaceURI(), part.getName().getLocalPart());
+    }
+
+}

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java Mon
Sep 11 03:11:15 2006
@@ -47,6 +47,7 @@
     private Executor executor;
     private Bus bus;
     private Interceptor faultInterceptor;
+    private Object implementor;
     
     public EndpointImpl(Bus bus, Service s, EndpointInfo ei) throws EndpointException {
         this.bus = bus;
@@ -104,6 +105,14 @@
             Message msg = new Message("NO_BINDING_FACTORY", BUNDLE, namespace);
             throw new EndpointException(msg);
         }
+    }
+
+    public Object getImplementor() {
+        return implementor;
+    }
+
+    public void setImplementor(Object implementor) {
+        this.implementor = implementor;
     }
 
 }

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Mon Sep 11 03:11:15 2006
@@ -20,8 +20,6 @@
 package org.apache.cxf.jaxb;
 
 import java.io.IOException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -32,7 +30,6 @@
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
-import javax.xml.namespace.QName;
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.w3c.dom.Document;
@@ -42,17 +39,11 @@
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.i18n.UncheckedException;
 import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.databinding.DataBindingContext;
 import org.apache.cxf.databinding.DataReaderFactory;
 import org.apache.cxf.databinding.DataWriterFactory;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.resource.URIResolver;
-import org.apache.cxf.service.Service;
-import org.apache.cxf.service.model.BindingInfo;
-import org.apache.cxf.service.model.BindingOperationInfo;
-import org.apache.cxf.service.model.MessageInfo;
-import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.ws.commons.schema.XmlSchema;
@@ -72,35 +63,20 @@
 
     JAXBContext context;
 
-    Service service;
-
-    Class clazz;
-
-    // this will be used to call unmarshall to provide the QName and Class
-    JAXBDataBindingContext jaxbDataBindingContext;
+    Class cls;
 
     public JAXBDataBinding() throws JAXBException {
         reader = new JAXBDataReaderFactory();
         writer = new JAXBDataWriterFactory();
     }
 
-    public JAXBDataBinding(Class<?> cls, Service pService) throws JAXBException {
-        this();
-        clazz = cls;
-        service = pService;
+    public JAXBDataBinding(Class<?> cls) throws JAXBException {
+        this();                
         context = JAXBEncoderDecoder.createJAXBContextForClass(cls);
         reader.setJAXBContext(context);
         writer.setJAXBContext(context);
-
-        Map<BindingInfo, Map<BindingOperationInfo, Map<QName, Class>>>
typeClassMap;
-        typeClassMap = new HashMap<BindingInfo, Map<BindingOperationInfo, Map<QName,
Class>>>();        
-        buildTypeClassMapping(typeClassMap);
-        jaxbDataBindingContext = new JAXBDataBindingContext(typeClassMap);
     }
 
-    public DataBindingContext getDataBindingContext() {
-        return jaxbDataBindingContext;
-    }
 
     public void setContext(JAXBContext ctx) {
         context = ctx;
@@ -175,49 +151,5 @@
         }
     }
 
-    private void buildTypeClassMapping(
-                    Map<BindingInfo, Map<BindingOperationInfo, Map<QName, Class>>>
typeClassMap) {
-        for (BindingInfo bi : service.getServiceInfo().getBindings()) {
-            Map<BindingOperationInfo, Map<QName, Class>> biMap = 
-                new HashMap<BindingOperationInfo, Map<QName, Class>>();
-            typeClassMap.put(bi, biMap);
-            for (BindingOperationInfo boi : bi.getOperations()) {
-                Map<QName, Class> boiMap = new HashMap<QName, Class>();
-                biMap.put(boi, boiMap);
-                addTypeClassMapping(clazz, boiMap, boi.getOperationInfo().getInput());
-                addTypeClassMapping(clazz, boiMap, boi.getOperationInfo().getOutput());
-            }
-        }
-    }
-
-    private static void addTypeClassMapping(Class cls, Map<QName, Class> boiMap, MessageInfo
msg) {
-        if (msg == null) {
-            return;
-        }
-        for (MessagePartInfo mpi : msg.getMessageParts()) {
-            if (!mpi.isElement()) {
-                String methodName = msg.getOperation().getName().getLocalPart();
-                String paramName = mpi.getTypeQName().getLocalPart();
-                Class paramCls = getParamClass(cls, methodName, paramName);
-                if (paramCls != null) {
-                    boiMap.put(mpi.getTypeQName(), paramCls);
-                }
-            }
-        }
-    }
-
-    private static Class getParamClass(Class cls, String methodName, String paramName) {
-        Method methods[] = cls.getMethods();
-        for (Method meth : methods) {
-            if (meth.getName().equals(methodName)) {
-                for (Type t : meth.getGenericParameterTypes()) {
-                    if (t.getClass().getSimpleName().equals(paramName)) {
-                        return t.getClass();
-                    }
-                }
-            }
-        }
-        return null;
-    }
 
 }

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataFactoryBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataFactoryBase.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataFactoryBase.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataFactoryBase.java
Mon Sep 11 03:11:15 2006
@@ -23,6 +23,7 @@
 import javax.xml.validation.Schema;
 
 public abstract class JAXBDataFactoryBase {
+    
     protected JAXBContext context; 
     protected Schema schema;
 
@@ -40,4 +41,5 @@
     public JAXBContext getJAXBContext() {
         return context;
     }
+
 }

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/XMLStreamDataReader.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/XMLStreamDataReader.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/XMLStreamDataReader.java
Mon Sep 11 03:11:15 2006
@@ -38,15 +38,13 @@
     }
 
     public Object read(QName name, XMLStreamReader reader) {
+
         return read(name, reader, null);
+
     }
 
     public Object read(QName name, XMLStreamReader reader, Class cls) {
-        return JAXBEncoderDecoder.unmarshall(factory.getJAXBContext(),
-                                             factory.getSchema(),
-                                             reader,
-                                             name,
-                                             cls,
-                                             null);
+        return JAXBEncoderDecoder.unmarshall(factory.getJAXBContext(), factory.getSchema(),
reader, name,
+                        cls, null);
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Mon Sep 11 03:11:15 2006
@@ -75,6 +75,7 @@
         // create the endpoint        
         QName endpointName = implInfo.getEndpointName();
         EndpointInfo ei = service.getServiceInfo().getEndpoint(endpointName);
+        endpoint.setImplementor(implementor);
 
         if (implInfo.isWebServiceProvider()) {
             service.setInvoker(new ProviderInvoker((Provider<?>)i));

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Mon Sep 11 03:11:15 2006
@@ -82,7 +82,7 @@
         handlerResolver = new HandlerResolverImpl(bus, name);
 
         try {
-            JAXBDataBinding dataBinding = new JAXBDataBinding(cls, service);
+            JAXBDataBinding dataBinding = new JAXBDataBinding(cls);
             service.setDataReaderFactory(dataBinding.getDataReaderFactory());
             service.setDataWriterFactory(dataBinding.getDataWriterFactory());
         } catch (JAXBException e) {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?view=diff&rev=442162&r1=442161&r2=442162
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Mon Sep 11 03:11:15 2006
@@ -53,9 +53,11 @@
 public class JaxWsServiceFactoryBean extends ReflectionServiceFactoryBean {
 
     private static final Logger LOG = LogUtils.getL7dLogger(JaxWsServiceFactoryBean.class);
+
     private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
 
     Class<?> seiClass;
+
     JAXBDataBinding dataBinding;
 
     JaxwsImplementorInfo implInfo;
@@ -79,7 +81,7 @@
     }
 
     public void activateEndpoint(Service service, EndpointInfo ei) throws BusException, WSDLException,
-        IOException, EndpointException {
+                    IOException, EndpointException {
         JaxwsEndpointImpl ep = new JaxwsEndpointImpl(getBus(), service, ei);
         ChainInitiationObserver observer = new ChainInitiationObserver(ep, getBus());
 
@@ -105,6 +107,18 @@
 
     @Override
     public void setServiceClass(Class<?> serviceClass) {
+
+        super.setServiceClass(serviceClass);
+
+        try {
+            dataBinding = new JAXBDataBinding(serviceClass);
+        } catch (JAXBException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        setDataReaderFactory(dataBinding.getDataReaderFactory());    
+        setDataWriterFactory(dataBinding.getDataWriterFactory());
+
         // update wsdl location
         // TODO: replace version in EndpointreferenceUtils?
         String wsdlLocation = null;
@@ -113,8 +127,10 @@
             WebServiceProvider wsProvider = implInfo.getWsProvider();
             wsdlLocation = wsProvider.wsdlLocation();
         } else {
+            if (ws == null) {
+                throw new WebServiceException(BUNDLE.getString("SEI_WITHOUT_WEBSERVICE_ANNOTATION_EXC"));
+            }
             wsdlLocation = ws.wsdlLocation();
-
             String sei = ws.endpointInterface();
             if (null != sei && !"".equals(sei)) {
                 try {
@@ -139,7 +155,8 @@
                 url = new URL(wsdlLocation);
             } catch (MalformedURLException ex) {
                 // LOG a warning instead of throw exception.
-                //url = implInfo.getImplementorClass().getResource(wsdlLocation);
+                // url =
+                // implInfo.getImplementorClass().getResource(wsdlLocation);
                 if (url == null) {
                     System.err.println("Can't resolve the wsdl location " + wsdlLocation);
                 }
@@ -147,20 +164,6 @@
             setWsdlURL(url);
         }
 
-        super.setServiceClass(serviceClass);
-
-        initializeServiceConfigurations();
-        
-        initializeServiceModel();
-        
-        try {
-            dataBinding = new JAXBDataBinding(serviceClass, getService());
-        } catch (JAXBException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        setDataReaderFactory(dataBinding.getDataReaderFactory());
-        setDataWriterFactory(dataBinding.getDataWriterFactory());
     }
 
     protected QName getServiceQName() {



Mime
View raw message