incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r498629 - in /incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba: CorbaStaxObject.java interceptors/CorbaFaultOutInterceptor.java interceptors/CorbaOutInterceptor.java
Date Mon, 22 Jan 2007 14:51:45 GMT
Author: bravi
Date: Mon Jan 22 06:51:44 2007
New Revision: 498629

URL: http://svn.apache.org/viewvc?view=rev&rev=498629
Log:
[YOKO-170] - Fixing marshalling of Wrapped & unwrapped style output.

Modified:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.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/CorbaStaxObject.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java?view=diff&rev=498629&r1=498628&r2=498629
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
Mon Jan 22 06:51:44 2007
@@ -120,6 +120,7 @@
 
     public CorbaObjectHandler readObjectFromStax(XMLEventReader reader, 
                                                  QName idlType,
+                                                 boolean isWrapped,
                                                  boolean isNested)
         throws CorbaBindingException {
         CorbaObjectHandler obj = null;
@@ -129,9 +130,12 @@
             if (!isNested) {
                 while (reader.peek().getEventType() != XMLStreamConstants.START_ELEMENT)
{
                     reader.nextEvent();
-                    reader.nextEvent();
                 }
             }
+            if (isWrapped) {
+                //read the wrapped type
+                reader.nextEvent();
+            }
         } catch (XMLStreamException ex) {
             throw new CorbaBindingException("Unable to locate start of object", ex);
         }
@@ -379,7 +383,7 @@
             StartElement arrayStartEl = reader.nextEvent().asStartElement();
             obj = new CorbaArrayHandler(arrayStartEl.getName(), idlType, tc, typeDefinition);
             for (int i = 0; i < arrayBound; ++i) {
-                CorbaObjectHandler element = readObjectFromStax(reader, arrayElemType, true);
+                CorbaObjectHandler element = readObjectFromStax(reader, arrayElemType, false,
true);
                 obj.addElement(element);
             }
             reader.nextEvent().asEndElement();
@@ -448,7 +452,10 @@
             obj = new CorbaExceptionHandler(exStartEl.getName(), idlType, tc, exType);
             List<MemberType> exMembers = exType.getMember();
             for (int i = 0; i < exMembers.size(); ++i) {
-                CorbaObjectHandler member = readObjectFromStax(reader, exMembers.get(i).getIdltype(),
true);
+                CorbaObjectHandler member = readObjectFromStax(reader,
+                                                               exMembers.get(i).getIdltype(),
+                                                               false,
+                                                               true);
                 obj.addMember(member);
             }
             reader.nextEvent().asEndElement();
@@ -498,13 +505,13 @@
             if (bound == 0) {
                 LOG.log(Level.INFO, "Unbounded sequence found");
                 while (reader.peek().getEventType() == XMLStreamConstants.START_ELEMENT)
{
-                    CorbaObjectHandler element = readObjectFromStax(reader, seqElementType,
true);
+                    CorbaObjectHandler element = readObjectFromStax(reader, seqElementType,
false, true);
                     obj.addElement(element);
                 }
             } else {
                 LOG.log(Level.INFO, "Bounded sequence found");
                 for (long i = 0; i < bound; ++i) {
-                    CorbaObjectHandler element = readObjectFromStax(reader, seqElementType,
true);
+                    CorbaObjectHandler element = readObjectFromStax(reader, seqElementType,
false, true);
                     obj.addElement(element);
                 }
             }
@@ -538,6 +545,7 @@
             for (int i = 0; i < structMembers.size(); ++i) {
                 CorbaObjectHandler member = readObjectFromStax(reader, 
                                                                structMembers.get(i).getIdltype(),

+                                                               false,
                                                                true);
                 obj.addMember(member);
             }
@@ -593,7 +601,7 @@
                 Unionbranch branch = branchesIter.next();
                 CorbaObjectHandler branchObj = null;
                 if (branch.getName().equals(branchName)) {
-                    branchObj = readObjectFromStax(reader, branch.getIdltype(), true);
+                    branchObj = readObjectFromStax(reader, branch.getIdltype(), false, true);
                     // We also need to set the discriminator since this is the branch with
the actual
                     // union value
                     CorbaObjectHandler discObj = 

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java?view=diff&rev=498629&r1=498628&r2=498629
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java
Mon Jan 22 06:51:44 2007
@@ -183,7 +183,7 @@
         LOG.log(Level.INFO, "Found exception in the raises list.  Marshalling.");
         ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
         XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
-        CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader, exIdlType,
false);
+        CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader, exIdlType,
false, false);
         CorbaStreamable streamable = new CorbaStreamable(obj, elName);
         message.setStreamableException(streamable);
     }

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=498629&r1=498628&r2=498629
==============================================================================
--- 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
Mon Jan 22 06:51:44 2007
@@ -105,13 +105,11 @@
             // TODO: where does encoding constant go?
             //String encoding = (String)message.get("Encoding");            
             BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
-            OperationType opType = boi.getExtensor(OperationType.class);
-            OperationInfo opInfo = boi.getOperationInfo();
         
             if (ContextUtils.isRequestor(message)) {
-                handleOutBoundMessage(message, opType, opInfo);
+                handleOutBoundMessage(message, boi);
             } else {
-                handleInBoundMessage(message, opType, opInfo);
+                handleInBoundMessage(message, boi);
             }
         } catch (Exception ex) {
             throw new Fault(ex);
@@ -119,14 +117,19 @@
     }
     
     
-    protected void handleOutBoundMessage(CorbaMessage message, OperationType opType, OperationInfo
opInfo)
+    protected void handleOutBoundMessage(CorbaMessage message, BindingOperationInfo boi)
         throws Exception {
+        OperationType opType = boi.getExtensor(OperationType.class);
         EventDataWriter writer = (EventDataWriter)getDataWriter(message);
         List<ParamType> paramTypes = opType.getParam();
         List<Object> args = message.getContent(List.class);
         MessageInfo msgInfo = message.get(MessageInfo.class);
-        addMarshalRequestParams(message, args, opInfo, paramTypes, 
-                                getXMLInputFactory(), getXMLOutputFactory(), 
+        addMarshalRequestParams(message,
+                                args,
+                                boi,
+                                paramTypes, 
+                                getXMLInputFactory(),
+                                getXMLOutputFactory(),
                                 writer);
 
         ArgType returnParam = opType.getReturn();
@@ -140,22 +143,30 @@
         }
     }
     
-    protected void handleInBoundMessage(CorbaMessage message, OperationType opType,
-                                        OperationInfo opInfo)
-        throws Exception {        
+    protected void handleInBoundMessage(CorbaMessage message, BindingOperationInfo boi)
+        throws Exception {
+        OperationType opType = boi.getExtensor(OperationType.class);
         EventDataWriter writer = (EventDataWriter)getDataWriter(message);
         ArgType returnParam = opType.getReturn();
         List<Object> args = message.getContent(List.class);
-        addMarshalResponseParams(message, args, opInfo, opType, getXMLInputFactory(), 
-                                 getXMLOutputFactory(), writer);
+        addMarshalResponseParams(message,
+                                 args,
+                                 boi,
+                                 opType,
+                                 getXMLInputFactory(), 
+                                 getXMLOutputFactory(),
+                                 writer);
     }
     
     protected void addMarshalRequestParams(CorbaMessage message, List<Object> arguments,
-                                           OperationInfo opInfo,
-                                           List<ParamType> params, XMLInputFactory
inputFactory,
-                                           XMLOutputFactory outputFactory, EventDataWriter
writer)
+                                           BindingOperationInfo boi,
+                                           List<ParamType> params,
+                                           XMLInputFactory inputFactory,
+                                           XMLOutputFactory outputFactory,
+                                           EventDataWriter writer)
         throws Exception {
         if (writer != null) {
+            OperationInfo opInfo = boi.getOperationInfo();
             List<Object> args = arguments;
 
             ByteArrayOutputStream outStream = new ByteArrayOutputStream();
@@ -167,7 +178,9 @@
             }
             ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
             XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
-            
+
+            boolean topLevelWrapper = boi.isUnwrappedCapable();
+
             for (Iterator<ParamType> iter = params.iterator(); iter.hasNext();) {
                 ParamType param = iter.next();
                 QName idlType = param.getIdltype();
@@ -176,7 +189,11 @@
                 if (param.getMode().equals(ModeType.OUT)) {
                     obj = CorbaHandlerUtils.initializeObjectHandler(orb, elName, idlType,
typeMaps, service);
                 } else {
-                    obj = corbaStaxObject.readObjectFromStax(evtReader, idlType, false);
+                    obj = corbaStaxObject.readObjectFromStax(evtReader,
+                                                             idlType,
+                                                             topLevelWrapper,
+                                                             false);
+                    topLevelWrapper = false;
                 }
                 CorbaStreamable streamable = new CorbaStreamable(obj, elName);
                 ModeType paramMode = param.getMode();
@@ -193,12 +210,15 @@
     }
     
     protected void addMarshalResponseParams(CorbaMessage message, List<Object> arguments,
-                                            OperationInfo opInfo,
-                                            OperationType opType, XMLInputFactory inputFactory,
-                                            XMLOutputFactory outputFactory, EventDataWriter
writer)
+                                            BindingOperationInfo boi,
+                                            OperationType opType,
+                                            XMLInputFactory inputFactory,
+                                            XMLOutputFactory outputFactory,
+                                            EventDataWriter writer)
         throws Exception {
         List<ParamType> params = opType.getParam();
         if (writer != null) {
+            OperationInfo opInfo = boi.getOperationInfo();
             List<Object> args = arguments;
 
             ByteArrayOutputStream outStream = new ByteArrayOutputStream();
@@ -208,6 +228,8 @@
                 Object partValue = args.get(i);
                 writer.write(partValue, part, evtWriter);
             }
+            boolean topLevelWrapper = boi.isUnwrappedCapable();
+
             ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
             XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
             
@@ -217,7 +239,9 @@
                 QName retName = new QName("", returnParam.getName());
                 CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader,
                                                                             retIdlType,
+                                                                            topLevelWrapper,
                                                                             false);
+                topLevelWrapper = false;
                 CorbaStreamable streamable = new CorbaStreamable(obj, retName);
                 message.setStreamableReturn(streamable);
             }
@@ -231,7 +255,11 @@
                 if (param.getMode().equals(ModeType.IN)) {
                     obj = CorbaHandlerUtils.initializeObjectHandler(orb, elName, idlType,
typeMaps, service);
                 } else {
-                    obj = corbaStaxObject.readObjectFromStax(evtReader, idlType, false);
+                    obj = corbaStaxObject.readObjectFromStax(evtReader,
+                                                             idlType,
+                                                             topLevelWrapper,
+                                                             false);
+                    topLevelWrapper = false;
                 }
 
                 CorbaStreamable streamable = new CorbaStreamable(obj, elName);



Mime
View raw message