incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eno...@apache.org
Subject svn commit: r482611 - in /incubator/yoko/branches/cxf_port/bindings: ./ src/main/java/org/apache/yoko/bindings/corba2/ src/main/java/org/apache/yoko/bindings/corba2/interceptors/
Date Tue, 05 Dec 2006 11:58:04 GMT
Author: enolan
Date: Tue Dec  5 03:58:03 2006
New Revision: 482611

URL: http://svn.apache.org/viewvc?view=rev&rev=482611
Log:
yoko-225 - adding fault marshalling and unmarshalling support.

Added:
    incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultInInterceptor.java   (with props)
    incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultOutInterceptor.java   (with props)
Modified:
    incubator/yoko/branches/cxf_port/bindings/pom.xml
    incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/ContextUtils.java
    incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBinding.java
    incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBindingFactory.java
    incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaStaxObject.java
    incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaUtils.java
    incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaInInterceptor.java
    incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaOutInterceptor.java

Modified: incubator/yoko/branches/cxf_port/bindings/pom.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/pom.xml?view=diff&rev=482611&r1=482610&r2=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/pom.xml (original)
+++ incubator/yoko/branches/cxf_port/bindings/pom.xml Tue Dec  5 03:58:03 2006
@@ -58,21 +58,6 @@
         </dependency>
         
         <dependency>
-            <groupId>org.objectweb.celtix</groupId>
-            <artifactId>celtix-common</artifactId>
-        </dependency>
-            
-        <dependency>
-            <groupId>org.objectweb.celtix</groupId>
-            <artifactId>celtix-rt</artifactId>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.objectweb.celtix</groupId>
-            <artifactId>celtix-api</artifactId>
-        </dependency>
-    
-        <dependency>
             <groupId>org.apache.yoko</groupId>
             <artifactId>yoko-api</artifactId>
         </dependency>

Modified: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/ContextUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/ContextUtils.java?view=diff&rev=482611&r1=482610&r2=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/ContextUtils.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/ContextUtils.java Tue Dec  5 03:58:03 2006
@@ -56,7 +56,7 @@
                && message == exchange.getOutMessage();
     }
         
-    protected DataWriter<XMLEventWriter> getDataWriter(Message message) {
+    public static DataWriter<XMLEventWriter> getDataWriter(CorbaMessage message) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataWriterFactory factory = service.getDataBinding().getDataWriterFactory();
 

Modified: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBinding.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBinding.java?view=diff&rev=482611&r1=482610&r2=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBinding.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBinding.java Tue Dec  5 03:58:03 2006
@@ -32,14 +32,14 @@
 
     private List<Interceptor> in;
     private List<Interceptor> out;
-    private List<Interceptor> fault;
-    private Interceptor outFaultInterceptor;
-    private Interceptor inFaultInterceptor;
+    private List<Interceptor> infault;
+    private List<Interceptor> outfault;   
     
     public CorbaBinding() {
         in = new ArrayList<Interceptor>();
         out = new ArrayList<Interceptor>();
-        fault = new ArrayList<Interceptor>();        
+        infault = new ArrayList<Interceptor>();
+        outfault = new ArrayList<Interceptor>();
     }
     
     public Message createMessage() {
@@ -50,8 +50,12 @@
         return new CorbaMessage(m);
     }
 
-    public List<Interceptor> getFaultInterceptors() {
-        return fault;
+    public List<Interceptor> getFaultInInterceptors() {
+        return infault;
+    }
+    
+    public List<Interceptor> getFaultOutInterceptors() {
+        return outfault;
     }
 
     public List<Interceptor> getInInterceptors() {
@@ -62,11 +66,4 @@
         return out;
     }
 
-    public Interceptor getInFaultInterceptor() {
-        return inFaultInterceptor;
-    }
-
-    public Interceptor getOutFaultInterceptor() {
-        return outFaultInterceptor;
-    }
 }

Modified: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBindingFactory.java?view=diff&rev=482611&r1=482610&r2=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBindingFactory.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaBindingFactory.java Tue Dec  5 03:58:03 2006
@@ -48,6 +48,8 @@
 
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 
+import org.apache.yoko.bindings.corba2.interceptors.CorbaFaultInInterceptor;
+import org.apache.yoko.bindings.corba2.interceptors.CorbaFaultOutInterceptor;
 import org.apache.yoko.bindings.corba2.interceptors.CorbaInInterceptor;
 import org.apache.yoko.bindings.corba2.interceptors.CorbaOutInterceptor;
 
@@ -101,7 +103,8 @@
         CorbaBinding binding = new CorbaBinding();
         binding.getInInterceptors().add(new CorbaInInterceptor());
         binding.getOutInterceptors().add(new CorbaOutInterceptor());
-        //binding.getOutFaultInterceptors().add(new CorbaFaultInterceptor());
+        binding.getFaultInInterceptors().add(new CorbaFaultInInterceptor());
+        binding.getFaultOutInterceptors().add(new CorbaFaultOutInterceptor());
         return binding;
     }
 

Modified: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaStaxObject.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaStaxObject.java?view=diff&rev=482611&r1=482610&r2=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaStaxObject.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaStaxObject.java Tue Dec  5 03:58:03 2006
@@ -83,6 +83,14 @@
     private ORB orb;
     private List<CorbaTypeMap> typeMaps;       
     
+    
+    public CorbaStaxObject() {         
+    }
+    
+    public CorbaStaxObject(ORB orb) {
+        this.orb = orb;    
+    }
+    
     public ORB getOrb() {
         return this.orb;
     }
@@ -165,85 +173,89 @@
     public void writeObjectToStax(CorbaObjectHandler obj, XMLEventWriter writer, XMLEventFactory factory,
                                   boolean isNested) {
         try {
-            QName objName = null;
-            if (isNested) {
-                objName = new QName(obj.getName().getLocalPart());
-            } else {
-                objName = obj.getName();
-            }
-
-            StartElement startEl = null;
-            TypeCode tc = obj.getTypeCode();            
-            if (CorbaUtils.isPrimitiveIdlType(obj.getIdlType())) {
-                LOG.log(Level.INFO, "Writing primitive type to XML writer");
-                
-                if (obj.getTypeCodeKind().value() == TCKind._tk_any) {
-                    // Any is a special case.  Create an attribute called xsi:type which identifies the type
-                    // of object stored in the Any.  Also create a 'dummy' attribute to get the XML schema 
-                    // namespace included in the Stax event.  createNamespace() doesn't work for some reason.
-                    // TODO: Revisit this.
-                    String schemaType = ((CorbaAnyHandler)obj).getSchemaType();
-                    QName attrName = new QName(XSI_NAMESPACE_URI, "type", XSI_PREFIX);
-                    Attribute attr = factory.createAttribute(attrName, schemaType); 
-                    QName nsName = new QName(XMLSCHEMA_NAMESPACE_URI, "namespace", XMLSCHEMA_PREFIX);
-                    Attribute ns = factory.createAttribute(nsName, "");
-                    List<Attribute> attributes = new ArrayList<Attribute>();
-                    attributes.add(attr);
-                    attributes.add(ns);
-                    
-                    startEl = 
-                        factory.createStartElement(objName, attributes.iterator(), null);
+            if (obj != null) {
+                QName objName = null;
+                if (isNested) {
+                    objName = new QName(obj.getName().getLocalPart());
                 } else {
-                    startEl = factory.createStartElement(objName, null, null);
+                    objName = obj.getName();
                 }
 
-                writer.add(startEl);
-                writePrimitiveToStax(obj, writer, factory);
-            } else {
-                startEl = factory.createStartElement(objName, null, null);
-                writer.add(startEl);
-
-                switch(tc.kind().value()) {
-                case TCKind._tk_array:
-                    LOG.log(Level.INFO, "Writing array type to XML writer");
-                    writeArrayToStax(obj, writer, factory);
-                    break;
-                case TCKind._tk_enum:
-                    LOG.log(Level.INFO, "Writing enum type to XML writer");
-                    writeEnumToStax(obj, writer, factory);
-                    break;
-                case TCKind._tk_except:
-                    LOG.log(Level.INFO, "Writing exception type to XML writer");
-                    writeExceptionToStax(obj, writer, factory);
-                    break;
-                case TCKind._tk_fixed:
-                    LOG.log(Level.INFO, "Writing fixed type to XML writer");
-                    writeFixedToStax(obj, writer, factory);
-                    break;
-                case TCKind._tk_sequence:
-                    LOG.log(Level.INFO, "Writing sequence type to XML writer");
-                    writeSequenceToStax(obj, writer, factory);
-                    break;
-                case TCKind._tk_struct:
-                    LOG.log(Level.INFO, "Writing struct type to XML writer");
-                    writeStructToStax(obj, writer, factory);
-                    break;
-                case TCKind._tk_union:
-                    LOG.log(Level.INFO, "Writing union type to XML writer");
-                    writeUnionToStax(obj, writer, factory);
-                    break;
-                case TCKind._tk_string:
-                case TCKind._tk_wstring:
-                    LOG.log(Level.INFO, "Wrting anonymous string to XML writer");
+                StartElement startEl = null;
+                TypeCode tc = obj.getTypeCode();
+                if (CorbaUtils.isPrimitiveIdlType(obj.getIdlType())) {
+                    LOG.log(Level.INFO, "Writing primitive type to XML writer");
+
+                    if (obj.getTypeCodeKind().value() == TCKind._tk_any) {
+                        // Any is a special case. Create an attribute called
+                        // xsi:type which identifies the type
+                        // of object stored in the Any. Also create a 'dummy'
+                        // attribute to get the XML schema
+                        // namespace included in the Stax event.
+                        // createNamespace() doesn't work for some reason.
+                        // TODO: Revisit this.
+                        String schemaType = ((CorbaAnyHandler)obj).getSchemaType();
+                        QName attrName = new QName(XSI_NAMESPACE_URI, "type", XSI_PREFIX);
+                        Attribute attr = factory.createAttribute(attrName, schemaType);
+                        QName nsName = new QName(XMLSCHEMA_NAMESPACE_URI, "namespace", XMLSCHEMA_PREFIX);
+                        Attribute ns = factory.createAttribute(nsName, "");
+                        List<Attribute> attributes = new ArrayList<Attribute>();
+                        attributes.add(attr);
+                        attributes.add(ns);
+
+                        startEl = factory.createStartElement(objName, attributes.iterator(), null);
+                    } else {
+                        startEl = factory.createStartElement(objName, null, null);
+                    }
+
+                    writer.add(startEl);
                     writePrimitiveToStax(obj, writer, factory);
-                    break;
-                default:
-                    throw new CorbaBindingException("Unsupported complex type");
+                } else {
+                    startEl = factory.createStartElement(objName, null, null);
+                    writer.add(startEl);
+
+                    switch (tc.kind().value()) {
+                    case TCKind._tk_array:
+                        LOG.log(Level.INFO, "Writing array type to XML writer");
+                        writeArrayToStax(obj, writer, factory);
+                        break;
+                    case TCKind._tk_enum:
+                        LOG.log(Level.INFO, "Writing enum type to XML writer");
+                        writeEnumToStax(obj, writer, factory);
+                        break;
+                    case TCKind._tk_except:
+                        LOG.log(Level.INFO, "Writing exception type to XML writer");
+                        writeExceptionToStax(obj, writer, factory);
+                        break;
+                    case TCKind._tk_fixed:
+                        LOG.log(Level.INFO, "Writing fixed type to XML writer");
+                        writeFixedToStax(obj, writer, factory);
+                        break;
+                    case TCKind._tk_sequence:
+                        LOG.log(Level.INFO, "Writing sequence type to XML writer");
+                        writeSequenceToStax(obj, writer, factory);
+                        break;
+                    case TCKind._tk_struct:
+                        LOG.log(Level.INFO, "Writing struct type to XML writer");
+                        writeStructToStax(obj, writer, factory);
+                        break;
+                    case TCKind._tk_union:
+                        LOG.log(Level.INFO, "Writing union type to XML writer");
+                        writeUnionToStax(obj, writer, factory);
+                        break;
+                    case TCKind._tk_string:
+                    case TCKind._tk_wstring:
+                        LOG.log(Level.INFO, "Wrting anonymous string to XML writer");
+                        writePrimitiveToStax(obj, writer, factory);
+                        break;
+                    default:
+                        throw new CorbaBindingException("Unsupported complex type");
+                    }
                 }
-            }            
-            
-            EndElement endEl = factory.createEndElement(objName, null);
-            writer.add(endEl);
+
+                EndElement endEl = factory.createEndElement(objName, null);
+                writer.add(endEl);                
+            }
         } catch (XMLStreamException ex) {
             LOG.log(Level.SEVERE, "STAX exception while writing to STAX event writer: " + ex.toString());
             LOG.log(Level.SEVERE, "Object being written: " + obj);

Modified: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaUtils.java?view=diff&rev=482611&r1=482610&r2=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaUtils.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/CorbaUtils.java Tue Dec  5 03:58:03 2006
@@ -296,32 +296,34 @@
     }
 
     public static void createCorbaTypeMap(List<CorbaTypeMap> typeMaps, List<TypeMappingType> tmTypes) {
-        for (int i = 0; i < tmTypes.size(); i++) {
-            TypeMappingType tmType = tmTypes.get(i);
+        if (tmTypes != null) {
+            for (int i = 0; i < tmTypes.size(); i++) {
+                TypeMappingType tmType = tmTypes.get(i);
 
-            CorbaTypeMap map = null;
-            for (Iterator<CorbaTypeMap> it = typeMaps.iterator(); it.hasNext();) {
-                CorbaTypeMap tm = it.next();
-                if (tm.getTargetNamespace().equals(tmType.getTargetNamespace())) {
-                    LOG.info("Found an existing typemap with the same namespace");
-                    map = tm;
-                    break;
+                CorbaTypeMap map = null;
+                for (Iterator<CorbaTypeMap> it = typeMaps.iterator(); it.hasNext();) {
+                    CorbaTypeMap tm = it.next();
+                    if (tm.getTargetNamespace().equals(tmType.getTargetNamespace())) {
+                        LOG.info("Found an existing typemap with the same namespace");
+                        map = tm;
+                        break;
+                    }
                 }
-            }
-                
-            if (map == null) {
-                map = new CorbaTypeMap(tmType.getTargetNamespace());
-                typeMaps.add(map);
-            }
-                
-            LOG.info("Found typemap in WSDL (Namespace: " + tmType.getTargetNamespace() + ")");
 
-            List<CorbaTypeImpl> types = tmType.getStructOrExceptionOrUnion();
-            LOG.info("Found " + types.size() + " types defined in the typemap");
-            for (Iterator<CorbaTypeImpl> it = types.iterator(); it.hasNext();) {
-                CorbaTypeImpl corbaType = it.next();
-                map.addType(corbaType.getName(), corbaType);
-                LOG.info("Adding type " + corbaType.getName());
+                if (map == null) {
+                    map = new CorbaTypeMap(tmType.getTargetNamespace());
+                    typeMaps.add(map);
+                }
+
+                LOG.info("Found typemap in WSDL (Namespace: " + tmType.getTargetNamespace() + ")");
+
+                List<CorbaTypeImpl> types = tmType.getStructOrExceptionOrUnion();
+                LOG.info("Found " + types.size() + " types defined in the typemap");
+                for (Iterator<CorbaTypeImpl> it = types.iterator(); it.hasNext();) {
+                    CorbaTypeImpl corbaType = it.next();
+                    map.addType(corbaType.getName(), corbaType);
+                    LOG.info("Adding type " + corbaType.getName());
+                }
             }
         }
     }

Added: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultInInterceptor.java?view=auto&rev=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultInInterceptor.java (added)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultInInterceptor.java Tue Dec  5 03:58:03 2006
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.yoko.bindings.corba2.interceptors;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.RaisesType;
+import org.apache.yoko.bindings.corba2.CorbaBindingException;
+import org.apache.yoko.bindings.corba2.CorbaMessage;
+import org.apache.yoko.bindings.corba2.CorbaStreamable;
+import org.apache.yoko.bindings.corba2.types.CorbaObjectHandler;
+
+import org.omg.CORBA.ORB;
+
+
+public class CorbaFaultInInterceptor extends AbstractPhaseInterceptor<Message> {
+        
+    private static final Logger LOG = LogUtils.getL7dLogger(CorbaFaultInInterceptor.class);  
+    
+    public CorbaFaultInInterceptor() {
+        super();
+        setPhase(Phase.UNMARSHAL);        
+    }
+    
+    public void setOrb(ORB orb) {       
+    }
+
+    public void handleMessage(Message msg) {
+        CorbaMessage message = (CorbaMessage)msg;
+    
+        try {
+            Exchange exchange = msg.getExchange();
+            BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
+            OperationType opType = boi.getExtensor(OperationType.class);
+            if (opType == null) {
+                throw new CorbaBindingException("Unable to find operation definition");
+            }
+            List<RaisesType> raises = opType.getRaises();
+            //Method currentMethod = (Method)objContext.get(ObjectMessageContext.METHOD_OBJ);
+            //Class<?>[] methodExs = currentMethod.getExceptionTypes();
+
+            CorbaStreamable streamableEx = message.getStreamableException();
+            CorbaObjectHandler exObject = streamableEx.getObject();
+            String name = exObject.getName().getLocalPart();
+            
+            Class exWrapperCls = null;            
+            for (int i = 0; i < raises.size(); ++i) {
+                // Right now, this assumes that all exceptions will have unique simple names.  REVISIT.
+                RaisesType type = raises.get(i);
+                if (name.equals(raises.get(i).getException().getLocalPart())) {
+                    //exWrapperCls = methodExs[i];
+                    break;
+                }
+            }
+
+            if (exWrapperCls == null) {
+                throw new CorbaBindingException("Unable to locate exception type in " 
+                                                + "declared exception list");
+            }
+
+            try {
+                Method faultInfoMethod = exWrapperCls.getMethod("getFaultInfo");
+                Class<?> exCls = faultInfoMethod.getReturnType();
+                Object yokoEx = exCls.newInstance();
+
+               // CorbaExceptionHandler.unmarshalCorbaException((CorbaExceptionHandler)exObject, yokoEx);
+                
+                Constructor exWrapperCtr = exWrapperCls.getConstructor(String.class, exCls);
+                Object exWrapper = exWrapperCtr.newInstance("", yokoEx);
+                Exception exception = new Exception();                
+
+                // the wrapper should always be an instance of throwable
+                //message.setException((Exception)exWrapper);    
+
+                
+            } catch (java.lang.Exception ex) {
+                // rethrow to be caught below
+                throw ex;
+            }
+
+        } catch (java.lang.Exception ex) {
+            LOG.log(Level.SEVERE, "CORBA unmarshalFault exception", ex);
+            throw new CorbaBindingException("CORBA unmarshalFault exception", ex);
+        }
+
+    }
+}
\ No newline at end of file

Propchange: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultInInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultInInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultOutInterceptor.java?view=auto&rev=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultOutInterceptor.java (added)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultOutInterceptor.java Tue Dec  5 03:58:03 2006
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.yoko.bindings.corba2.interceptors;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.ws.WebFault;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxb.io.EventDataWriter;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.RaisesType;
+import org.apache.yoko.bindings.corba2.CorbaBindingException;
+import org.apache.yoko.bindings.corba2.CorbaMessage;
+import org.apache.yoko.bindings.corba2.CorbaStreamable;
+import org.apache.yoko.bindings.corba2.types.CorbaObjectHandler;
+import org.apache.yoko.bindings.corba2.ContextUtils;
+import org.apache.yoko.bindings.corba2.CorbaStaxObject;
+
+public class CorbaFaultOutInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    private static final Logger LOG = LogUtils.getL7dLogger(CorbaFaultOutInterceptor.class);
+    protected CorbaStaxObject corbaStaxObject;    
+    
+    public CorbaFaultOutInterceptor() {
+        super();
+        setPhase(Phase.MARSHAL);
+        corbaStaxObject = new CorbaStaxObject();
+    }
+
+    public void handleMessage(Message msg) {
+        try {
+            CorbaMessage message = (CorbaMessage)msg;
+            EventDataWriter writer = (EventDataWriter)ContextUtils.getDataWriter(message);
+
+            // Get information about the operation being invoked from the WSDL
+            // definition.
+            // We need this to marshal data correctly
+            Exchange exchange = msg.getExchange();
+            BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
+            OperationType opType = boi.getExtensor(OperationType.class);
+            if (opType == null) {
+                throw new CorbaBindingException("Unable to find operation definition");
+            }
+
+            XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+            XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+            outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+            Throwable except = new Throwable();
+            Method faultInfoMethod = except.getClass().getMethod("getFaultInfo");
+            Object faultInfo = faultInfoMethod.invoke(except);
+            WebFault wfAnnotation = except.getClass().getAnnotation(WebFault.class);
+            QName elName = new QName(wfAnnotation.targetNamespace(), except.getClass().getSimpleName());
+
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+            writer.write(faultInfo, evtWriter);
+
+            QName exIdlType = null;
+            List<RaisesType> exList = opType.getRaises();
+            for (Iterator<RaisesType> i = exList.iterator(); i.hasNext();) {
+                // REVISIT: Note that this assumes that exception names need to
+                // be unique. We should make
+                // sure that this is really the case.
+                RaisesType raises = i.next();
+                if (raises.getException().getLocalPart().equals(elName.getLocalPart())) {
+                    exIdlType = raises.getException();
+                }
+            }
+            if (exIdlType == null) {
+                LOG.log(Level.INFO,
+                        "Could not find the exception in the raises list.  Must be a system exception.");
+                // This could be a system exception?
+            } else {
+                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);
+                CorbaStreamable streamable = new CorbaStreamable(obj, elName);
+                message.setStreamableException(streamable);
+            }
+
+        } catch (java.lang.Exception ex) {
+            LOG.log(Level.SEVERE, "CORBA marshalFault exception", ex);
+            // TODO: Throw a exception proper exception once implemented
+            throw new CorbaBindingException("Method unmarshalFault not implemented");
+        }
+
+    }                                
+    
+}
\ No newline at end of file

Propchange: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultOutInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaFaultOutInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaInInterceptor.java?view=diff&rev=482611&r1=482610&r2=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaInInterceptor.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaInInterceptor.java Tue Dec  5 03:58:03 2006
@@ -82,12 +82,7 @@
 
 public class CorbaInInterceptor extends AbstractPhaseInterceptor<Message> {
     
-    private static final String XSI_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance";
-    private static final String XSI_PREFIX = "xsi";
-    private static final String XMLSCHEMA_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema";
-    private static final String XMLSCHEMA_PREFIX = "xs";
-
-    protected CorbaStaxObject corbaStaxObject = new CorbaStaxObject();
+    protected static CorbaStaxObject corbaStaxObject;
     private List<CorbaTypeMap> typeMaps;    
     private XMLOutputFactory xof;
     private XMLInputFactory xif;
@@ -96,22 +91,24 @@
     public CorbaInInterceptor() {
         super();
         setPhase(Phase.UNMARSHAL);
+        corbaStaxObject = new CorbaStaxObject();
+    }
+    
+    public void setOrb(ORB orb) {
+        this.orb = orb;
     }
 
-    public void handleMessage(Message msg) {
-        System.out.println("handleMessage() in CorbaInInterceptor...");  
-        
+    public void handleMessage(Message msg) {                  
         CorbaMessage message = (CorbaMessage) msg;                
-        Exchange exchange = message.getExchange();
+        //corbaStaxObject = new CorbaStaxObject();
         CorbaDestination destination = null;
         if (message.getDestination() != null) {
             destination = (CorbaDestination)message.getDestination();
         } else {
-            destination = (CorbaDestination)exchange.getDestination();
+            destination = (CorbaDestination)message.getExchange().getDestination();
         }
         
-        typeMaps = new ArrayList<CorbaTypeMap>();        
-        
+        typeMaps = new ArrayList<CorbaTypeMap>();                
         ServiceInfo service = destination.getBindingInfo().getService();        
         List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
         if (corbaTypes != null) {
@@ -119,113 +116,139 @@
             corbaStaxObject.setTypeMaps(typeMaps);
         }
         
-        BindingInfo bInfo = destination.getBindingInfo();              
-        InterfaceInfo info = bInfo.getInterface();
-        
         // TODO: where does encoding constant go?
-        String encoding = (String)message.get("Encoding");        
-        EventDataReader reader;
-        reader = (EventDataReader)getDataReader(message);
-        
-        // Handle the parameters that are given for the operation
-        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
-        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
-        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);        
-        
-        OperationType opType = null;
-        
+        //String encoding = (String)message.get("Encoding");        
+                               
         // check to see if we have an input or output message
         if (!ContextUtils.isRequestor(msg)) {
-            System.out.println("Is not a requester.....");
-            orb = (ORB)exchange.get(ORB.class);
-            corbaStaxObject.setOrb(orb);
-            String opName = message.getExchange().get(String.class);
+            handleNotRequestMessage(message, destination, service);                
+        } else {             
+            handleRequestMessage(message, destination, service);
+        } 
+    }
             
-            QName opQName = null;
-            Iterator i = bInfo.getOperations().iterator();
-            while (i.hasNext()) {
-                BindingOperationInfo bOpType = (BindingOperationInfo)i.next();
-                if (bOpType.getName().getLocalPart().equals(opName)) {
-                    opType = bOpType.getExtensor(OperationType.class);
-                    opQName = bOpType.getName();
-                    break;
-                }
+    protected void handleNotRequestMessage(CorbaMessage message, CorbaDestination destination,
+                                        ServiceInfo service) {
+        QName opQName = null;
+        OperationType opType = null;
+        BindingInfo bInfo = destination.getBindingInfo();              
+        InterfaceInfo info = bInfo.getInterface();        
+        EventDataReader reader = (EventDataReader)getDataReader(message);
+        
+        Exchange exchange = message.getExchange();
+        orb = (ORB)exchange.get(ORB.class);        
+        if (corbaStaxObject != null)
+            corbaStaxObject.setOrb(orb);
+        else {
+            corbaStaxObject = new CorbaStaxObject(orb);
+        }
+        String opName = message.getExchange().get(String.class);
+                
+        Iterator i = bInfo.getOperations().iterator();
+        while (i.hasNext()) {
+            BindingOperationInfo bOpType = (BindingOperationInfo)i.next();
+            if (bOpType.getName().getLocalPart().equals(opName)) {
+                opType = bOpType.getExtensor(OperationType.class);
+                opQName = bOpType.getName();
+                break;
             }
+        }
 
-            ServerRequest request = (ServerRequest)exchange.get(org.omg.CORBA.ServerRequest.class);
-            NVList list = prepareArguments(message, destination, info, service, opType, opQName);
-            request.arguments(list);
-            message.setList(list);            
-        
-            // Handle the parameters that are given for the operation
-            List<ParamType> paramTypes = opType.getParam();     
-            ArgType argType = opType.getReturn();            
-            MessageInfo msgInfo = message.get(MessageInfo.class);
-            
-            addUnmarshalParams(message,
-                               message,
-                             paramTypes,
-                             info,
-                             opType,
-                             getXMLInputFactory(),
-                             getXMLOutputFactory(),
-                             reader);
-                   
-
-        } else {            
-            System.out.println("Its a requester.....");
-            orb = (ORB) message.get(CorbaConstants.ORB);
-            ORB orb2 = corbaStaxObject.getOrb();
+        ServerRequest request = (ServerRequest)exchange.get(org.omg.CORBA.ServerRequest.class);
+        NVList list = prepareArguments(message, destination, info, service, opType, opQName);
+        request.arguments(list);
+        message.setList(list);            
+    
+        // Handle the parameters that are given for the operation
+        List<ParamType> paramTypes = null;
+        if (opType != null) {
+            paramTypes = opType.getParam();             
+        }
+        addUnmarshalParams(message, message, 
+                           paramTypes, info,
+                           opType, reader);
+        
+    }
+    
+    protected void handleRequestMessage(CorbaMessage message, CorbaDestination destination,
+                                           ServiceInfo service) {
+        OperationType opType = null;
+                
+        orb = (ORB) message.get(CorbaConstants.ORB);  
+        if (corbaStaxObject != null) {
             corbaStaxObject.setOrb(orb);
-            BindingOperationInfo bopInfo = exchange.get(BindingOperationInfo.class);
-            opType = bopInfo.getExtensor(OperationType.class);
+        } else {
+            corbaStaxObject = new CorbaStaxObject(orb);
+        }        
+        EventDataReader reader;
+        reader = (EventDataReader)getDataReader(message);
+        BindingInfo bInfo = destination.getBindingInfo();              
+        InterfaceInfo info = bInfo.getInterface();
+        
+        Exchange exchange = message.getExchange();
+        BindingOperationInfo bopInfo = exchange.get(BindingOperationInfo.class);
+        opType = bopInfo.getExtensor(OperationType.class);
 
-            // Handle the parameters that are given for the operation
-            List<ParamType> paramTypes = opType.getParam();     
-            ArgType argType = opType.getReturn();            
-            CorbaMessage outMessage = (CorbaMessage)exchange.getOutMessage();                               
-            MessageInfo msgInfo = outMessage.get(MessageInfo.class);
-            
-            addUnmarshalParams(outMessage,
-                               message,
-                             paramTypes,
-                             info,
-                             opType,
-                             getXMLInputFactory(),
-                             getXMLOutputFactory(),
-                             reader);
-            
-            try {
-                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
-                CorbaStreamable retVal = outMessage.getStreamableReturn();
-                corbaStaxObject.writeObjectToStax(retVal.getObject(), evtWriter, XMLEventFactory
-                    .newInstance(), false);
-                evtWriter.flush();
+        // Handle the parameters that are given for the operation
+        List<ParamType> paramTypes = null;     
+        ArgType argType = null;
+        
+        if (opType != null) {
+            paramTypes = opType.getParam();     
+            argType = opType.getReturn();
+        }
+        CorbaMessage outMessage = (CorbaMessage)exchange.getOutMessage();                                       
+        
+        addUnmarshalParams(outMessage,
+                           message,
+                           paramTypes,
+                           info,
+                           opType,                         
+                           reader);
+        
+        writeReturnValue(message, outMessage, argType, reader);        
+    }
+    
+    protected void writeReturnValue(CorbaMessage message, CorbaMessage outMessage, 
+                                    ArgType argType, EventDataReader reader ) {
+        Object retValue = null;
+        // Handle the parameters that are given for the operation
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, 
+                                  Boolean.TRUE);        
 
-                ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
-                XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);                
+        try {
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+            CorbaStreamable retVal = outMessage.getStreamableReturn();
+            corbaStaxObject.writeObjectToStax(retVal.getObject(), evtWriter, 
+                                              XMLEventFactory.newInstance(),
+                                              false);
+            evtWriter.flush();
+
+            ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+            XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);            
+            if (argType.getName() != null) {
                 QName retName = new QName("", argType.getName(), "");
-                Object retValue = reader.read(retName, evtReader, String.class);                
-                List<Object> args = new ArrayList<Object>();
-                args.add(retValue);
-                message.setContent(List.class, args);
-            } catch (XMLStreamException ex) {
-                //NEED TO DO  
+                retValue = reader.read(retName, evtReader, String.class);
             }
-        } 
+            List<Object> args = new ArrayList<Object>();
+            args.add(retValue);
+            message.setContent(List.class, args);           
+        } catch (XMLStreamException ex) {
+            // NEED TO DO
+        }        
     }
-        
-    private void addUnmarshalParams(CorbaMessage msg,
+    
+    protected void addUnmarshalParams(CorbaMessage msg,
                                     CorbaMessage message,
-                                  List<ParamType> params,
-                                  InterfaceInfo info,
-                                  OperationType opType,
-                                  XMLInputFactory inputFactory,
-                                  XMLOutputFactory outputFactory,
-                                  EventDataReader reader) {
-              
-        System.out.println("In unmarshal params....");
+                                    List<ParamType> params,
+                                    InterfaceInfo info,
+                                    OperationType opType,                                  
+                                    EventDataReader reader) {
+                      
+        
         CorbaStreamable[] streamables = msg.getStreamableArguments();       
         List<Object> args = msg.getContent(List.class);         
                 
@@ -241,47 +264,34 @@
             } else if (param.getMode().equals(ModeType.IN)) {
                 skipRead = true;
             }
-           
+                       
             if (!skipRead) {
-                try {
-                    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                    XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);                                        
-                    corbaStaxObject.writeObjectToStax(streamables[i].getObject(), evtWriter,
-                                                      XMLEventFactory.newInstance(), false);
-                    evtWriter.flush();
-
-                    ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
-                    //String str = new String(outStream.toByteArray());
-                    //System.out.println(str);
-                    XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
-                    if (param.getMode().equals(ModeType.OUT)) {                        
-                        QName retName = new QName("", param.getName(), "");
-                        obj =  reader.read(evtReader);                                                                       
-                        msg.setStreamableReturn(streamables[i]);
-                    } else {                       
-                        QName elName2 = new QName("", param.getName(), "");                                              
-                        obj = reader.read(elName2, evtReader, String.class);
-                                   
-                        try {
-                            if (param.getMode().equals(ModeType.INOUT) || param.getMode().equals(ModeType.OUT)) {
-                                args.get(i).getClass().getField("value").set(i, obj);            
-                            } else {
-                                args.add(obj);
-                            }
-                        } catch (IllegalAccessException ex) {
-                            ex.printStackTrace();
-                        } catch (NoSuchFieldException ex) {
-                            ex.printStackTrace();
+
+                XMLEventReader evtReader = getEventReader(streamables[i]);
+                if (param.getMode().equals(ModeType.OUT)) {                    
+                    obj = reader.read(evtReader);
+                    msg.setStreamableReturn(streamables[i]);
+                } else {
+                    QName elName2 = new QName("", param.getName(), "");
+                    obj = reader.read(elName2, evtReader, String.class);
+
+                    try {
+                        if (param.getMode().equals(ModeType.INOUT) || param.getMode().equals(ModeType.OUT)) {
+                            args.get(i).getClass().getField("value").set(i, obj);
+                        } else {
+                            args.add(obj);
                         }
+                    } catch (IllegalAccessException ex) {
+                        ex.printStackTrace();
+                    } catch (NoSuchFieldException ex) {
+                        ex.printStackTrace();
                     }
-                } catch (XMLStreamException ex) {
-                    // NEED TO DO
                 }
+
             } else {
-                if (param.getMode().equals(ModeType.OUT)) {                                   
-                    List<Object> retArgs = new ArrayList<Object>();
+                if (param.getMode().equals(ModeType.OUT)) {                                                       
                     args.add(obj);
-                    message.setContent(List.class, retArgs);
+                    message.setContent(List.class, args);
                 } else if (param.getMode().equals(ModeType.INOUT) || param.getMode().equals(ModeType.OUT)) {
                     try {
                         args.get(i).getClass().getField("value").set(i, obj);
@@ -290,14 +300,34 @@
                     } catch (NoSuchFieldException ex) {
                         ex.printStackTrace();
                     } 
-                }               
+                }                             
             }
             msg.setContent(List.class, args);
         }
     }   
     
     
-    private NVList prepareArguments(CorbaMessage corbaMsg, CorbaDestination destination,
+    protected XMLEventReader getEventReader(CorbaStreamable streamable) {
+        
+        XMLEventReader evtReader  = null;
+        XMLInputFactory inputFactory = getXMLInputFactory();
+        XMLOutputFactory outputFactory = getXMLOutputFactory();
+        try {
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+            corbaStaxObject.writeObjectToStax(streamable.getObject(), evtWriter, XMLEventFactory
+                .newInstance(), false);
+            evtWriter.flush();
+
+            ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+            evtReader = inputFactory.createXMLEventReader(inStream);
+        } catch (XMLStreamException ex) {
+            // NEED TO DO
+        }        
+        return evtReader;
+    }
+    
+    protected NVList prepareArguments(CorbaMessage corbaMsg, CorbaDestination destination,
                                     InterfaceInfo info, ServiceInfo service, 
                                     OperationType opType, QName opQName) {
         
@@ -319,35 +349,19 @@
                        
         List<ParamType> paramTypes = opType.getParam();       
         CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];                               
-        NVList list = prepareDIIArgsList(corbaMsg, arguments, paramTypes, typeMaps, opType, info);        
+        NVList list = prepareDIIArgsList(corbaMsg, arguments, paramTypes, typeMaps);         
         
         return list;
         
     }
     
-    private NVList prepareDIIArgsList(CorbaMessage corbaMsg, CorbaStreamable[] streamables, List<ParamType> paramTypes, 
-                                      List<CorbaTypeMap> typeMaps, OperationType opType,
-                                      InterfaceInfo info) {
+    protected NVList prepareDIIArgsList(CorbaMessage corbaMsg, CorbaStreamable[] streamables, List<ParamType> paramTypes, 
+                                      List<CorbaTypeMap> typeMaps) { 
         
         // Build the list of DII arguments, returns, and exceptions        
         NVList list = orb.create_list(streamables.length);        
-        List<Object> args = new ArrayList<Object>();
-        int idx = 0;
         
-        try {
-            for (ParamType param : paramTypes) {
-                Class cls = param.getClass();
-                if (cls.isAssignableFrom(Holder.class)) {
-                    args.add(cls.newInstance());
-                } 
-                idx++;
-            }
-            corbaMsg.setContent(List.class, args);
-        } catch (InstantiationException ex) {
-            ex.printStackTrace();         
-        } catch (IllegalAccessException ex2) {
-            ex2.printStackTrace();
-        }
+        prepareArgs(corbaMsg, paramTypes);
         
         for (int i = 0; i < paramTypes.size(); i++) {           
             ParamType param = paramTypes.get(i);                                       
@@ -376,17 +390,25 @@
         return list;
     } 
     
-    private MessagePartInfo getMessagePartInfo(MessageInfo msgInfo, String name) {
-        List<MessagePartInfo> parts = msgInfo.getMessageParts();
-        for (int i = 0; i < parts.size(); i++) {
-            MessagePartInfo part = parts.get(i);
-            if (part.getName().getLocalPart().equals(name)) {
-                return part;
+    protected void prepareArgs(CorbaMessage corbaMsg, List<ParamType> paramTypes) {
+        List<Object> args = new ArrayList<Object>();
+        int idx = 0;
+        
+        try {
+            for (ParamType param : paramTypes) {
+                Class cls = param.getClass();
+                if (cls.isAssignableFrom(Holder.class)) {
+                    args.add(cls.newInstance());
+                } 
+                idx++;
             }
+            corbaMsg.setContent(List.class, args);
+        } catch (InstantiationException ex) {
+            ex.printStackTrace();         
+        } catch (IllegalAccessException ex2) {
+            ex2.printStackTrace();
         }
-        return null;
     }
-
     
     protected XMLOutputFactory getXMLOutputFactory() {
         if (xof == null) {
@@ -403,15 +425,17 @@
         return xif;
     }        
     
-    protected DataReader<XMLEventReader> getDataReader(Message message) {
+    protected DataReader<XMLEventReader> getDataReader(CorbaMessage message) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataReaderFactory factory = service.getDataBinding().getDataReaderFactory();
 
         DataReader<XMLEventReader> dataReader = null;
-        for (Class<?> cls : factory.getSupportedFormats()) {
-            if (cls == XMLEventReader.class) {
-                dataReader = factory.createReader(XMLEventReader.class);
-                break;
+        if (factory != null) {
+            for (Class<?> cls : factory.getSupportedFormats()) {
+                if (cls == XMLEventReader.class) {
+                    dataReader = factory.createReader(XMLEventReader.class);
+                    break;
+                }
             }
         }
 

Modified: incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaOutInterceptor.java?view=diff&rev=482611&r1=482610&r2=482611
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaOutInterceptor.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/main/java/org/apache/yoko/bindings/corba2/interceptors/CorbaOutInterceptor.java Tue Dec  5 03:58:03 2006
@@ -46,6 +46,7 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.databinding.DataWriterFactory;
+import org.apache.cxf.jaxb.io.EventDataReader;
 import org.apache.cxf.jaxb.io.EventDataWriter;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -117,7 +118,7 @@
     private static final String XMLSCHEMA_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema";
     private static final String XMLSCHEMA_PREFIX = "xs";
 
-    protected CorbaStaxObject corbaStaxObject = new CorbaStaxObject();
+    protected CorbaStaxObject corbaStaxObject;
     private List<CorbaTypeMap> typeMaps;
     private ORB orb;
     private XMLOutputFactory xof;
@@ -129,11 +130,9 @@
     }
 
     public void handleMessage(Message msg) {
-        System.out.println("handleMessage() in CorbaOutInterceptor...");
         CorbaMessage message = (CorbaMessage) msg;
-
         orb = (ORB) message.get(CorbaConstants.ORB);
-        corbaStaxObject.setOrb(orb);
+        corbaStaxObject = new CorbaStaxObject(orb);
         Exchange exchange = message.getExchange();
         typeMaps = new ArrayList<CorbaTypeMap>();
 
@@ -143,119 +142,119 @@
         getXMLOutputFactory().setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
 
         // TODO: where does encoding constant go?
-        String encoding = (String)message.get("Encoding");
-        EventDataWriter writer;
-        writer = (EventDataWriter)getDataWriter(message);        
-
+        //String encoding = (String)message.get("Encoding");                
         BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
-        OperationType opType = boi.getExtensor(OperationType.class);
-        System.out.println("Operation: " + opType.getName());
-
-        List<ParamType> paramTypes = opType.getParam();
+        OperationType opType = boi.getExtensor(OperationType.class);        
         
         if (ContextUtils.isRequestor(message)) {
-            System.out.println("Its an outbound message");
-            List<Object> args = message.getContent(List.class);
-            MessageInfo msgInfo = message.get(MessageInfo.class);
-            addMarshalParams(message,
-                             args,
-                             msgInfo,
-                             paramTypes,
-                             getXMLInputFactory(),
-                             getXMLOutputFactory(),
-                             writer);
-             
-            ArgType returnParam = opType.getReturn();                                           
+            handleOutBoundMessage(message, opType);           
+        } else {
+            handleInBoundMessage(message, opType);            
+        }
+    }
+    
+    
+    protected void handleOutBoundMessage(CorbaMessage message, OperationType opType) {
+        EventDataWriter writer = (EventDataWriter)getDataWriter(message);
+        List<ParamType> paramTypes = opType.getParam();
+        List<Object> args = message.getContent(List.class);
+        MessageInfo msgInfo = message.get(MessageInfo.class);
+        addMarshalParams(message, args, msgInfo, paramTypes, 
+                         getXMLInputFactory(), getXMLOutputFactory(), 
+                         writer);
+
+        ArgType returnParam = opType.getReturn();
+        QName retName = new QName("", returnParam.getName());
+        QName retIdlType = returnParam.getIdltype();
+        CorbaObjectHandler obj = CorbaHandlerUtils
+            .initializeObjectHandler(orb, retName, retIdlType, typeMaps);
+        CorbaStreamable streamable = new CorbaStreamable(obj, retName);
+        System.out.println("done outbound message");
+        message.setStreamableReturn(streamable);
+    }
+    
+    protected void handleInBoundMessage(CorbaMessage message, OperationType opType) {        
+        EventDataWriter writer = (EventDataWriter)getDataWriter(message);
+        List<ParamType> paramTypes = opType.getParam();
+        OperationInfo opInfo = message.getExchange().get(OperationInfo.class);
+        MessageInfo msgInInfo = opInfo.getInput();
+        List<Object> args = message.getExchange().getInMessage().getContent(List.class);
+        addMarshalParams(message, args, msgInInfo, paramTypes, getXMLInputFactory(), getXMLOutputFactory(),
+                         writer);
+
+        ArgType returnParam = opType.getReturn();
+        try {
+            List<Object> argsRet = message.getContent(List.class);
+            MessageInfo msgInfo = opInfo.getOutput();
+            MessagePartInfo part = getMessagePartInfo(msgInfo, returnParam.getName());
+
+            // for the server, write the result out.
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            XMLEventWriter evtWriter = xof.createXMLEventWriter(outStream);
             QName retName = new QName("", returnParam.getName());
+            writer.write(argsRet.get(0), part, evtWriter);
+            ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+            XMLEventReader evtReader = xif.createXMLEventReader(inStream);
             QName retIdlType = returnParam.getIdltype();
-            CorbaObjectHandler obj = 
-                CorbaHandlerUtils.initializeObjectHandler(orb, retName, retIdlType, typeMaps);
+            CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader, retIdlType, false);
             CorbaStreamable streamable = new CorbaStreamable(obj, retName);
-            message.setStreamableReturn(streamable);                        
-        } else {
-            System.out.println("Its an inbound message");
-            OperationInfo opInfo = message.getExchange().get(OperationInfo.class);
-            MessageInfo msgInInfo = opInfo.getInput();
-            List<Object> args = message.getExchange().getInMessage().getContent(List.class);            
-            addMarshalParams(message,
-                             args,
-                             msgInInfo, paramTypes,
-                             getXMLInputFactory(), 
-                             getXMLOutputFactory(), 
-                             writer);
-
-            ArgType returnParam = opType.getReturn();
-            try {
-                List<Object> argsRet = message.getContent(List.class);
-                MessageInfo msgInfo = opInfo.getOutput();
-                MessagePartInfo part = getMessagePartInfo(msgInfo, returnParam.getName());
-                
-                // for the server, write the result out.
-                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                XMLEventWriter evtWriter = xof.createXMLEventWriter(outStream);
-                QName retName = new QName("", returnParam.getName());
-                writer.write(argsRet.get(0), part, evtWriter);
-                ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
-                XMLEventReader evtReader = xif.createXMLEventReader(inStream);
-                QName retIdlType = returnParam.getIdltype();
-                CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader, retIdlType, false);
-                CorbaStreamable streamable = new CorbaStreamable(obj, retName);
-                message.setStreamableReturn(streamable);
-            } catch (XMLStreamException ex) {
-                // NEED TO DO
-                // throw
-            }            
+            message.setStreamableReturn(streamable);
+        } catch (XMLStreamException ex) {
+            // NEED TO DO
+            // throw
         }
+
     }
     
-    private void addMarshalParams(CorbaMessage message, List<Object> arguments, MessageInfo msgInfo,
-                                  List<ParamType> params, XMLInputFactory inputFactory,
-                                  XMLOutputFactory outputFactory, EventDataWriter writer) {
+    protected void addMarshalParams(CorbaMessage message, List<Object> arguments, MessageInfo msgInfo,
+                                    List<ParamType> params, XMLInputFactory inputFactory,
+                                    XMLOutputFactory outputFactory, EventDataWriter writer) {
         try {
+            if (writer != null) {
+                List<Object> args = arguments;
+                for (int i = 0; i < params.size(); i++) {
+                    Object partValue;
+                    ParamType param = params.get(i);
+                    if (param.getMode() != ModeType.IN) {
+                        partValue = ((Holder)args.get(i)).value;
+                    } else {
+                        partValue = args.get(i);
+                    }
 
-            List<Object> args = arguments;
-            for (int i = 0; i < params.size(); i++) {
-                Object partValue;
-                ParamType param = params.get(i);
-                if (param.getMode() != ModeType.IN) {
-                    partValue = ((Holder)args.get(i)).value;
-                } else {
-                    partValue = args.get(i);
-                }
-
-                MessagePartInfo part = getMessagePartInfo(msgInfo, param.getName());
-                QName elName = new QName("", param.getName());
-                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
-                writer.write(partValue, part, evtWriter);
-
-                ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
-                XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
-                QName idlType = param.getIdltype();
-                CorbaObjectHandler obj = null;
-                boolean skipRead = false;
-                if (!ContextUtils.isRequestor(message)) {
-                    if (param.getMode().equals(ModeType.IN)) {
+                    MessagePartInfo part = getMessagePartInfo(msgInfo, param.getName());
+                    QName elName = new QName("", param.getName());
+                    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+                    XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+                    writer.write(partValue, part, evtWriter);
+
+                    ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+                    XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+                    QName idlType = param.getIdltype();
+                    CorbaObjectHandler obj = null;
+                    boolean skipRead = false;
+                    if (!ContextUtils.isRequestor(message)) {
+                        if (param.getMode().equals(ModeType.IN)) {
+                            skipRead = true;
+                        }
+                    } else if (param.getMode().equals(ModeType.OUT)) {
                         skipRead = true;
                     }
-                } else if (param.getMode().equals(ModeType.OUT)) {
-                    skipRead = true;
-                }
-                if (skipRead) {
-                    obj = CorbaHandlerUtils.initializeObjectHandler(orb, elName, idlType, typeMaps);
-                } else {
-                    obj = corbaStaxObject.readObjectFromStax(evtReader, idlType, false);
-                }
-                CorbaStreamable streamable = new CorbaStreamable(obj, elName);
-                ModeType paramMode = param.getMode();
-                if (paramMode.value().equals("in")) {
-                    streamable.setMode(org.omg.CORBA.ARG_IN.value);
-                } else if (paramMode.value().equals("inout")) {
-                    streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
-                } else if (paramMode.value().equals("out")) {
-                    streamable.setMode(org.omg.CORBA.ARG_OUT.value);
+                    if (skipRead) {
+                        obj = CorbaHandlerUtils.initializeObjectHandler(orb, elName, idlType, typeMaps);
+                    } else {
+                        obj = corbaStaxObject.readObjectFromStax(evtReader, idlType, false);
+                    }
+                    CorbaStreamable streamable = new CorbaStreamable(obj, elName);
+                    ModeType paramMode = param.getMode();
+                    if (paramMode.value().equals("in")) {
+                        streamable.setMode(org.omg.CORBA.ARG_IN.value);
+                    } else if (paramMode.value().equals("inout")) {
+                        streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
+                    } else if (paramMode.value().equals("out")) {
+                        streamable.setMode(org.omg.CORBA.ARG_OUT.value);
+                    }
+                    message.addStreamableArgument(streamable);
                 }
-                message.addStreamableArgument(streamable);
             }
         } catch (java.lang.Exception ex) {
             ex.printStackTrace();
@@ -278,15 +277,28 @@
     }
 
 
-    protected DataWriter<XMLEventWriter> getDataWriter(Message message) {
+    protected MessagePartInfo getMessagePartInfo(MessageInfo msgInfo, String name) {
+        List<MessagePartInfo> parts = msgInfo.getMessageParts();
+        for (int i = 0; i < parts.size(); i++) {
+            MessagePartInfo part = parts.get(i);
+            if (part.getName().getLocalPart().equals(name)) {
+                return part;
+            }
+        }
+        return null;
+    }
+    
+    protected DataWriter<XMLEventWriter> getDataWriter(CorbaMessage message) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataWriterFactory factory = service.getDataBinding().getDataWriterFactory();
 
         DataWriter<XMLEventWriter> dataWriter = null;
-        for (Class<?> cls : factory.getSupportedFormats()) {
-            if (cls == XMLEventWriter.class) {
-                dataWriter = factory.createWriter(XMLEventWriter.class);
-                break;
+        if (factory != null) {
+            for (Class<?> cls : factory.getSupportedFormats()) {
+                if (cls == XMLEventWriter.class) {
+                    dataWriter = factory.createWriter(XMLEventWriter.class);
+                    break;
+                }
             }
         }
 
@@ -299,28 +311,4 @@
         return dataWriter;
     }
 
-    private MessagePartInfo getMessagePartInfo(MessageInfo msgInfo, String name) {
-        List<MessagePartInfo> parts = msgInfo.getMessageParts();
-        for (int i = 0; i < parts.size(); i++) {
-            MessagePartInfo part = parts.get(i);
-            if (part.getName().getLocalPart().equals(name)) {
-                return part;
-            }
-        }
-        return null;
-    }
-
-    private Map<TypeCode, RaisesType> getOperationExceptions(OperationType operation) {
-        Map<TypeCode, RaisesType> exceptions = new HashMap<TypeCode, RaisesType>();
-        List<RaisesType> exList = operation.getRaises();
-
-        for (int i = 0; i < exList.size(); ++i) {
-            RaisesType ex = exList.get(i);
-            TypeCode tc = CorbaUtils.getTypeCode(orb, ex.getException(), typeMaps);
-            exceptions.put(tc, ex);
-        }
-
-        return exceptions;
-    }
-       
 }



Mime
View raw message