incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r490356 - in /incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors: CorbaInInterceptor.java CorbaOutInterceptor.java
Date Tue, 26 Dec 2006 19:05:22 GMT
Author: bravi
Date: Tue Dec 26 11:05:19 2006
New Revision: 490356

URL: http://svn.apache.org/viewvc?view=rev&rev=490356
Log:
[YOKO-170] - Updates to the Corba binding to properly marshal & unmarshal wsdl paramaters.

Modified:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java?view=diff&rev=490356&r1=490355&r2=490356
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java
Tue Dec 26 11:05:19 2006
@@ -38,6 +38,7 @@
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.databinding.DataReaderFactory;
 import org.apache.cxf.jaxb.JAXBUtils;
+import org.apache.cxf.jaxb.WrapperHelper;
 import org.apache.cxf.jaxb.io.EventDataReader;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -155,19 +156,24 @@
         request.arguments(list);
         message.setList(list);            
     
+        OperationInfo opInfo = processWrappedOperation(bopInfo, false);
+
         addUnmarshalParams(message,
                            message, 
                            info,
-                           bopInfo,
+                           opType,
+                           opInfo,
                            reader,
                            false);
+
+        addWrapperParams(message, bopInfo, false);
         
     }
     
     protected void handleRequestMessage(CorbaMessage message, CorbaDestination destination,
                                         ServiceInfo service) {
         OperationType opType = null;
-                
+        
         orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);  
         if (corbaStaxObject != null) {
             corbaStaxObject.setOrb(orb);
@@ -192,28 +198,106 @@
         }
         CorbaMessage outMessage = (CorbaMessage)exchange.getOutMessage();
         
+        opType = bopInfo.getExtensor(OperationType.class);
+
+        OperationInfo opInfo = processWrappedOperation(bopInfo, true);
+
+        writeReturnValue(message, outMessage, opInfo, argType, reader);
+
         addUnmarshalParams(outMessage,
                            message,
                            info,
-                           bopInfo,                         
+                           opType,
+                           opInfo,
                            reader,
                            true);
-        writeReturnValue(message, outMessage, bopInfo, argType, reader);
+        addWrapperParams(message, bopInfo, true);
+    }
+
+    protected void addWrapperParams(Message message, BindingOperationInfo bopInfo, boolean
isOutput) {
+        if (bopInfo.isUnwrappedCapable()) {
+            OperationInfo opInfo = bopInfo.getOperationInfo();
+
+            MessageInfo msgInfo = null;
+            if (isOutput) {
+                msgInfo = opInfo.getOutput();
+            } else {
+                msgInfo = opInfo.getInput();
+            }
+            Class wrapperTypeClass = msgInfo.getMessageParts().get(0).getTypeClass();
+            opInfo = opInfo.getUnwrappedOperation();
+            if (isOutput) {
+                msgInfo = opInfo.getOutput();
+            } else {
+                msgInfo = opInfo.getInput();
+            }
+            List<Object> objs = message.getContent(List.class);
+            if ((objs != null) && (objs.size() == 1)) {
+                try {
+                    Object wrapperType = wrapperTypeClass.newInstance();
+                    int i = 0;
+                    for (MessagePartInfo p : msgInfo.getMessageParts()) {
+                        Object part = objs.get(i);
+                        WrapperHelper.setWrappedPart(p.getName().getLocalPart(), wrapperType,
part);
+                        i++;
+                    }
+                    objs = new ArrayList<Object>();
+                    objs.add(wrapperType);
+                    message.setContent(List.class, objs);
+                } catch (Exception ex) {
+                    ex.printStackTrace();
+                }
+            }
+        }
+    }
+
+    protected OperationInfo processWrappedOperation(BindingOperationInfo bopInfo, boolean
isOutput) {
+        OperationInfo opInfo = bopInfo.getOperationInfo();
+        MessageInfo msgInfo = null;
+        if (bopInfo.isUnwrappedCapable()) {
+            if (isOutput) {
+                msgInfo = opInfo.getOutput();
+            } else {
+                msgInfo = opInfo.getInput();
+            }
+            Class wrapperTypeClass = msgInfo.getMessageParts().get(0).getTypeClass();
+            opInfo = opInfo.getUnwrappedOperation();
+            if (isOutput) {
+                msgInfo = opInfo.getOutput();
+            } else {
+                msgInfo = opInfo.getInput();
+            }
+            
+            for (MessagePartInfo part : msgInfo.getMessageParts()) {
+                try {
+                    String elementType = null;
+                    if (part.isElement()) {
+                        elementType = part.getElementQName().getLocalPart();
+                    } else if (part.getTypeQName() == null) {
+                        // handling anonymous complex type
+                        elementType = null;
+                    } else {
+                        elementType = part.getTypeQName().getLocalPart();
+                    }
+                    part.setTypeClass(getWrappedPartClass(part.getName().getLocalPart(),

+                                                          wrapperTypeClass,
+                                                          elementType));
+                } catch (Exception ex) {
+                    ex.printStackTrace();
+                }
+            }
+        }
+        return opInfo;
     }
     
     protected void writeReturnValue(CorbaMessage message, 
                                     CorbaMessage outMessage,
-                                    BindingOperationInfo bopInfo,
+                                    OperationInfo opInfo,
                                     ArgType argType, 
                                     EventDataReader reader) {
         Object retValue = null;
 
-        OperationInfo opInfo = bopInfo.getOperationInfo();          
         MessageInfo msgInfo = opInfo.getOutput();
-        if (bopInfo.isUnwrappedCapable()) {
-            opInfo = opInfo.getUnwrappedOperation();
-            msgInfo = opInfo.getOutput();
-        }
 
         // Handle the parameters that are given for the operation
         XMLInputFactory inputFactory = XMLInputFactory.newInstance();
@@ -245,49 +329,13 @@
     protected void addUnmarshalParams(CorbaMessage msg,
                                       CorbaMessage message,
                                       InterfaceInfo info,
-                                      BindingOperationInfo bopInfo,                     
            
+                                      OperationType opType,
+                                      OperationInfo opInfo,                             
    
                                       EventDataReader reader,
                                       boolean isOutput) {
 
-        OperationType opType = bopInfo.getExtensor(OperationType.class);
-
         MessageInfo msgInfo;
-        OperationInfo opInfo = bopInfo.getOperationInfo();
-
-        if (bopInfo.isUnwrappedCapable()) {
-            if (isOutput) {
-                msgInfo = opInfo.getOutput();
-            } else {
-                msgInfo = opInfo.getInput();
-            }
-            Class wrapperTypeClass = msgInfo.getMessageParts().get(0).getTypeClass();
-            opInfo = opInfo.getUnwrappedOperation();
-            if (isOutput) {
-                msgInfo = opInfo.getOutput();
-            } else {
-                msgInfo = opInfo.getInput();
-            }
-            
-            for (MessagePartInfo part : msgInfo.getMessageParts()) {
-                try {
-                    String elementType = null;
-                    if (part.isElement()) {
-                        elementType = part.getElementQName().getLocalPart();
-                    } else if (part.getTypeQName() == null) {
-                        // handling anonymous complex type
-                        elementType = null;
-                    } else {
-                        elementType = part.getTypeQName().getLocalPart();
-                    }
-                    part.setTypeClass(getWrappedPartClass(part.getName().getLocalPart(),

-                                                          wrapperTypeClass,
-                                                          elementType));
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                }
-            }
-
-        } else if (isOutput) {
+        if (isOutput) {
             msgInfo = opInfo.getOutput();
         } else {
             msgInfo = opInfo.getInput();
@@ -297,7 +345,7 @@
 
         try {       
             CorbaStreamable[] streamables = msg.getStreamableArguments();       
-            List<Object> args = new ArrayList<Object>();
+            List<Object> args = message.getContent(List.class);
             int index = 0;
             for (int i = 0; i < params.size(); i++) {
                 Object obj = null;
@@ -329,7 +377,7 @@
                                                               isOutput);
                     args.add(reader.read(part, evtReader));
                     index++;
-                } else {
+                } else if (!isOutput) {
                     args.add(obj);
                 }
 
@@ -355,10 +403,12 @@
         exg.put(EndpointReferenceType.class, destination.getAddress());
         exg.put(ServiceInfo.class, service);
         exg.put(BindingOperationInfo.class, bOpInfo);        
-        exg.put(OperationInfo.class, opInfo);                
+        exg.put(OperationInfo.class, opInfo);
         exg.put(MessageInfo.class, opInfo.getInput());
         exg.put(String.class, opQName.getLocalPart());        
         exg.setInMessage(corbaMsg);
+
+        corbaMsg.put(MessageInfo.class, opInfo.getInput());
                        
         List<ParamType> paramTypes = opType.getParam();       
         CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];           
                   

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java?view=diff&rev=490356&r1=490355&r2=490356
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java
Tue Dec 26 11:05:19 2006
@@ -128,7 +128,6 @@
         CorbaObjectHandler obj = CorbaHandlerUtils
             .initializeObjectHandler(orb, retName, retIdlType, typeMaps);
         CorbaStreamable streamable = new CorbaStreamable(obj, retName);
-        System.out.println("done outbound message");
         message.setStreamableReturn(streamable);
     }
     



Mime
View raw message