incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eno...@apache.org
Subject svn commit: r483585 [1/2] - in /incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba: ./ extensions/
Date Thu, 07 Dec 2006 18:10:26 GMT
Author: enolan
Date: Thu Dec  7 10:10:25 2006
New Revision: 483585

URL: http://svn.apache.org/viewvc?view=rev&rev=483585
Log:
yoko-225 - porting yoko from celtix to use cxf.

Added:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java   (with props)
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBinding.java   (with props)
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java   (with props)
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java   (with props)
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java   (with props)
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java   (with props)
Removed:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaExceptionHelper.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContext.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContextImpl.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerBinding.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/extensions/
Modified:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectWriter.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStreamable.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaTypeMap.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/Messages.properties

Added: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java?view=auto&rev=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java (added)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java Thu Dec  7 10:10:25 2006
@@ -0,0 +1,76 @@
+/**
+ * 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.corba;
+
+import javax.xml.stream.XMLEventWriter;
+
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.databinding.DataWriterFactory;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.ServiceModelUtil;
+
+
+/**
+ * Holder for utility methods relating to contexts.
+ */
+public final class ContextUtils {
+    
+    public static boolean isRequestor(Message message) {
+        return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE));
+    }
+
+    /**
+     * Determine if message is outbound.
+     *
+     * @param message the current Message
+     * @return true iff the message direction is outbound
+     */
+    public static boolean isOutbound(Message message) {
+        Exchange exchange = message.getExchange();
+        return message != null
+               && exchange != null
+               && message == exchange.getOutMessage();
+    }
+        
+    public static 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 (dataWriter == null) {
+            //throw a fault
+            //throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAWRITER", BUNDLE, service
+            //    .getName()));
+        }
+
+        return dataWriter;
+    }
+
+}

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBinding.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBinding.java?view=auto&rev=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBinding.java (added)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBinding.java Thu Dec  7 10:10:25 2006
@@ -0,0 +1,69 @@
+/**
+ * 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.corba;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.binding.Binding;
+import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+
+public class CorbaBinding extends AbstractBasicInterceptorProvider implements Binding {
+
+    private List<Interceptor> in;
+    private List<Interceptor> out;
+    private List<Interceptor> infault;
+    private List<Interceptor> outfault;   
+    
+    public CorbaBinding() {
+        in = new ArrayList<Interceptor>();
+        out = new ArrayList<Interceptor>();
+        infault = new ArrayList<Interceptor>();
+        outfault = new ArrayList<Interceptor>();
+    }
+    
+    public Message createMessage() {
+        return createMessage(new MessageImpl());
+    }
+
+    public Message createMessage(Message m) {
+        return new CorbaMessage(m);
+    }
+
+    public List<Interceptor> getFaultInInterceptors() {
+        return infault;
+    }
+    
+    public List<Interceptor> getFaultOutInterceptors() {
+        return outfault;
+    }
+
+    public List<Interceptor> getInInterceptors() {
+        return in;
+    }
+
+    public List<Interceptor> getOutInterceptors() {
+        return out;
+    }
+
+}

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java?view=diff&rev=483585&r1=483584&r2=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java Thu Dec  7 10:10:25 2006
@@ -43,4 +43,4 @@
     public CorbaBindingException(Throwable t) {
         super(t);
     }
-}
\ No newline at end of file
+}

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java?view=diff&rev=483585&r1=483584&r2=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java Thu Dec  7 10:10:25 2006
@@ -1,70 +1,138 @@
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.yoko.bindings.corba;
 
 import java.io.IOException;
-import javax.wsdl.Binding;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.WSDLException;
-
-import org.apache.yoko.bindings.corba.extensions.CorbaAddressExtensionHelper;
-import org.apache.yoko.bindings.corba.extensions.CorbaBindingExtensionHelper;
-import org.apache.yoko.bindings.corba.extensions.CorbaOperationExtensionHelper;
-import org.apache.yoko.bindings.corba.extensions.CorbaTypesExtensionHelper;
-
-import org.objectweb.celtix.Bus;
-import org.objectweb.celtix.bindings.BindingFactory;
-import org.objectweb.celtix.bindings.ClientBinding;
-import org.objectweb.celtix.bindings.ServerBinding;
-import org.objectweb.celtix.bindings.ServerBindingEndpointCallback;
-import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.AbstractBindingFactory;
+import org.apache.cxf.binding.Binding;
+import org.apache.cxf.binding.BindingFactoryManager;
+
+import org.apache.cxf.helpers.CastUtils;
+
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+
+
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.ConduitInitiator;
+import org.apache.cxf.transport.ConduitInitiatorManager;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
 
-public class CorbaBindingFactory implements BindingFactory {
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+
+import org.apache.yoko.bindings.corba.interceptors.CorbaFaultInInterceptor;
+import org.apache.yoko.bindings.corba.interceptors.CorbaFaultOutInterceptor;
+import org.apache.yoko.bindings.corba.interceptors.CorbaInInterceptor;
+import org.apache.yoko.bindings.corba.interceptors.CorbaOutInterceptor;
+
+public class CorbaBindingFactory extends AbstractBindingFactory
+    implements ConduitInitiator, DestinationFactory {
 
     private Bus bus;
+    private Collection<String> activationNamespaces;
+    private List<String> transportIds;
 
-    public CorbaBindingFactory() {
+    @Resource
+    public void setBus(Bus b) {
+        bus = b;
+    }
+    
+    @Resource
+    public void setActivationNamespaces(Collection<String> ans) {
+        activationNamespaces = ans;
     }
 
-    public void init(Bus b) {
-        bus = b;
+    @PostConstruct
+    void registerSelf() {
+        if (null == bus) {
+            return;
+        }
+        BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
+        if (null != bfm) {
+            for (String ns : activationNamespaces) {
+                bfm.registerBindingFactory(ns, this);
+            }
+        }
+    }
+
+    @PostConstruct
+    void registerWithBindingManager() {
+        ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
+        if (null != cim) {
+            for (String ns : activationNamespaces) {
+                cim.registerConduitInitiator(ns, this);
+            }
+        }
+        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+        if (null != dfm) {
+            for (String ns : activationNamespaces) {
+                dfm.registerDestinationFactory(ns, this);
+            }
+        }
+    }
+
+    public Binding createBinding(BindingInfo bindingInfo) {
+        CorbaBinding binding = new CorbaBinding();
+        binding.getInInterceptors().add(new CorbaInInterceptor());
+        binding.getOutInterceptors().add(new CorbaOutInterceptor());
+        binding.getFaultInInterceptors().add(new CorbaFaultInInterceptor());
+        binding.getFaultOutInterceptors().add(new CorbaFaultOutInterceptor());
+        return binding;
+    }
+
+    public Conduit getConduit(EndpointInfo endpointInfo)
+        throws IOException {
+        return getConduit(endpointInfo, null);
+    }
+
+    public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target)
+        throws IOException {
+        return new CorbaConduit(endpointInfo, target);
+    }
+
+    public Destination getDestination(EndpointInfo endpointInfo)
+        throws IOException {
+        return new CorbaDestination(endpointInfo);
+    }
+
+    public List<String> getTransportIds() {
+        return transportIds;
+    }
+
+    @Resource
+    public void setTransportIds(List<String> ids) {
+        transportIds = ids;
+    }
 
-        CorbaAddressExtensionHelper.addExtension(
-                bus.getWSDLManager().getExtenstionRegistry(), Port.class, "address");
-        CorbaBindingExtensionHelper.addExtension(
-                bus.getWSDLManager().getExtenstionRegistry(), Binding.class, "binding");
-        CorbaOperationExtensionHelper.addExtension(
-                bus.getWSDLManager().getExtenstionRegistry(), BindingOperation.class, "operation");
-        CorbaTypesExtensionHelper.addExtension(
-                bus.getWSDLManager().getExtenstionRegistry(), Definition.class, "typeMapping");
-    }
-
-    public ClientBinding createClientBinding(EndpointReferenceType reference)
-        throws WSDLException, IOException {
-        return new CorbaClientBinding(bus, reference);
-    }
-
-    public ServerBinding createServerBinding(EndpointReferenceType reference,
-                                             ServerBindingEndpointCallback cbFactory) 
-        throws WSDLException, IOException {
-        return new CorbaServerBinding(bus, reference, cbFactory);
+    public Set<String> getUriPrefixes() {
+        return CastUtils.cast(Collections.EMPTY_SET);
     }
 }

Added: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java?view=auto&rev=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java (added)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java Thu Dec  7 10:10:25 2006
@@ -0,0 +1,325 @@
+/**
+ * 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.corba;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.io.AbstractCachedOutputStream;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.AttributedURIType;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.schemas.yoko.bindings.corba.AddressType;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.RaisesType;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+import org.apache.yoko.wsdl.CorbaConstants;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.TypeCode;
+
+
+public class CorbaConduit implements Conduit {
+    private static final Logger LOG = LogUtils.getL7dLogger(CorbaConduit.class);
+
+    private EndpointInfo endpointInfo;
+    private EndpointReferenceType target;
+    private MessageObserver incomingObserver;
+    private ORB orb;
+
+    public CorbaConduit(EndpointInfo ei, EndpointReferenceType ref) {
+        endpointInfo = ei;
+        target = getTargetReference(ref);
+        // TODO: Set any additional properties needed to initialize the ORB  before
+        // we initialize it. We will get this information from the Celtix configuration 
+        // that is used with the current application.
+        java.util.Properties props = System.getProperties();
+        props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+        props.put("org.omg.CORBA.ORBSingletonClass",
+                "org.apache.yoko.orb.CORBA.ORBSingleton");
+        props.put("yoko.orb.id", "Yoko-Client-Binding");
+
+        orb = ORB.init(new String[0], props);
+        if (orb == null) {
+            LOG.severe("Could not create instance of the ORB");
+            throw new CorbaBindingException("Could not create instance of the ORB");
+        }
+    }
+
+    public void send(Message message) throws IOException {    
+        try {
+            AddressType address = endpointInfo.getExtensor(AddressType.class);
+
+            if (address == null) {
+                LOG.log(Level.SEVERE, "Unable to locate a valid CORBA address");
+                throw new CorbaBindingException("Unable to locate a valid CORBA address");
+            }            
+            org.omg.CORBA.Object targetObject = CorbaUtils.importObjectReference(orb, address.getLocation());
+            message.put(CorbaConstants.ORB, orb);
+            message.put(CorbaConstants.CORBA_ENDPOINT_OBJECT, targetObject);
+            message.setContent(OutputStream.class,
+                               new CorbaOutputStream(message));
+        } catch (java.lang.Exception ex) {
+            LOG.log(Level.SEVERE, "Could not resolve target object");
+            throw new CorbaBindingException(ex);
+        }
+    }
+
+    public void close(Message message) throws IOException {            
+        BindingOperationInfo boi = message.getExchange().get(BindingOperationInfo.class);
+        OperationType opType = boi.getExtensor(OperationType.class);
+        
+        try {
+            buildRequest((CorbaMessage)message, opType);
+            message.getContent(OutputStream.class).close();
+        } catch (Exception ex) {
+            // NEED TO DO
+        }
+    }
+
+    public EndpointReferenceType getTarget() {
+        return target;
+    }
+
+    public Destination getBackChannel() {
+        System.out.println("In CorbaConduit back channel.");
+        return null;
+    }
+
+    public void close() {
+        System.out.println("in Close() in corbaConduit");
+        
+    }
+
+    public void setMessageObserver(MessageObserver observer) {
+        incomingObserver = observer;
+    }
+
+    public EndpointReferenceType getTargetReference(EndpointReferenceType t) {
+        EndpointReferenceType ref = null;
+        if (null == t) {
+            ref = new EndpointReferenceType();
+            AttributedURIType address = new AttributedURIType();
+            address.setValue(getAddress());
+            ref.setAddress(address);
+        } else {
+            ref = t;
+        }
+        return ref;
+    }
+
+    protected String getAddress() {
+        return endpointInfo.getAddress();
+    }
+        
+    protected void buildRequest(CorbaMessage message, OperationType opType) throws Exception {        
+        try {
+            List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();
+
+            ServiceInfo service = message.getExchange().get(ServiceInfo.class);
+            List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
+            if (corbaTypes != null) {
+                CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
+            }
+        
+            NVList nvlist = getArguments(message);
+            NamedValue ret = getReturn(message);
+            ExceptionList exList = getExceptionList(message, opType, typeMaps);     
+            invokeRequest(message, opType.getName(), nvlist, ret, exList);
+
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        }                
+    }
+       
+    protected NVList getArguments(CorbaMessage message) {
+        // Build the list of DII arguments, returns, and exceptions
+        NVList list = null;
+        if (message.getStreamableArguments() != null) {
+            CorbaStreamable[] arguments = message.getStreamableArguments();
+            list = orb.create_list(arguments.length);
+
+            for (int i = 0; i < arguments.length; ++i) {
+                Any value = orb.create_any();
+                value.insert_Streamable(arguments[i]);
+                list.add_value(arguments[i].getName(), value, arguments[i].getMode());
+            }
+        } else {
+            list = orb.create_list(0);
+        }
+
+        return list;        
+    }
+    
+    protected NamedValue getReturn(CorbaMessage message) {
+        CorbaStreamable retVal = message.getStreamableReturn();
+        NamedValue ret = null;
+        if (retVal != null) {
+            Any returnAny = orb.create_any();
+            returnAny.insert_Streamable(retVal);
+            ret = orb.create_named_value(retVal.getName(), returnAny, org.omg.CORBA.ARG_OUT.value);
+        } else {
+            // TODO: REVISIT: for some reason, the yoko ORB does not like to
+            // have a null NamedValue return value. Create this 'empty' 
+            // one if a void return type is used.
+            ret = orb.create_named_value("return", orb.create_any(), org.omg.CORBA.ARG_OUT.value);
+        }
+        return ret;        
+    }
+    
+    protected ExceptionList getExceptionList(CorbaMessage message, 
+                                               OperationType opType,
+                                               List<CorbaTypeMap> typeMaps) {
+        // Get the typecodes for the exceptions this operation can throw.
+        // These are defined in the operation definition from WSDL.
+        ExceptionList exList = orb.create_exception_list();
+
+        Map<TypeCode, RaisesType> exceptions = getOperationExceptions(opType, typeMaps);        
+        if (exceptions != null) {
+            Object[] tcs = null;
+            tcs = exceptions.keySet().toArray();
+        
+            for (int i = 0; i < exceptions.size(); ++i) {
+                exList.add((TypeCode)tcs[i]);
+            }
+        }
+        return exList;
+    }
+            
+    protected void invokeRequest(CorbaMessage message, String opName,
+                                 org.omg.CORBA.NVList nvlist, 
+                                 org.omg.CORBA.NamedValue ret, 
+                                 org.omg.CORBA.ExceptionList exList) 
+        throws Exception {
+        try {            
+            ContextList ctxList = orb.create_context_list();
+            Context ctx = orb.get_default_context();            
+            org.omg.CORBA.Object targetObj = 
+                (org.omg.CORBA.Object)message.get(CorbaConstants.CORBA_ENDPOINT_OBJECT);
+            if (targetObj != null) {                
+                Request request = targetObj._create_request(ctx, opName, 
+                                             nvlist, ret, exList, ctxList);                
+                request.invoke();
+            }
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+        
+    protected Map<TypeCode, RaisesType> getOperationExceptions(
+                                         OperationType operation, 
+                                         List<CorbaTypeMap> typeMaps) {
+        Map<TypeCode, RaisesType> exceptions = new HashMap<TypeCode, RaisesType>();
+        List<RaisesType> exList = operation.getRaises(); 
+        if (exList != null) {
+            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;
+    }
+    
+    private class CorbaOutputStream extends AbstractCachedOutputStream {
+       
+        private Message message;
+        private boolean isOneWay;
+
+        CorbaOutputStream(Message m) {
+            message = m;        
+        }
+
+        /**
+         * Perform any actions required on stream flush (freeze headers, reset
+         * output stream ... etc.)
+         */
+        public void doFlush() throws IOException {
+            // do nothing here
+        }
+
+        /**
+         * Perform any actions required on stream closure (handle response etc.)
+         */
+        public void doClose() throws IOException {
+            if (ContextUtils.isRequestor(message) && ContextUtils.isOutbound(message)) {
+                System.out.println("is requester and outbound message");
+                try {
+                    isOneWay = message.getExchange().isOneWay();
+                    
+                    if (!isOneWay) {                
+                        handleResponse();
+                        System.out.println("handled response");
+                    }
+                } catch (Exception ex) {
+                    LOG.log(Level.WARNING, "Connection failed with Exception : ", ex);
+                    throw new IOException(ex.toString());
+                }            
+            } else  if (!ContextUtils.isRequestor(message) && !ContextUtils.isOutbound(message)) {
+                System.out.println("is not requester and is inbound message");
+            } else if (!ContextUtils.isRequestor(message) && ContextUtils.isOutbound(message)) {
+                System.out.println("is not requester and is outbound message");
+            } else if (ContextUtils.isRequestor(message) && !ContextUtils.isOutbound(message)) {
+                System.out.println("is requester and is inbound message");
+            }
+        }
+
+        public void onWrite() throws IOException {
+
+        }
+
+        public void handleResponse() throws IOException {
+            LOG.log(Level.FINE, "incoming observer is " + incomingObserver);
+            Exchange exchange = message.getExchange();            
+            MessageImpl inMessage = new MessageImpl();
+            CorbaDestination destination = new CorbaDestination(endpointInfo);
+            inMessage.setDestination(destination);
+            exchange.put(ORB.class, orb);
+            inMessage.setExchange(exchange);
+                        
+            LOG.log(Level.FINE, "incoming observer is " + incomingObserver);
+            incomingObserver.onMessage((Message)inMessage);          
+        }
+
+    }
+}

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java?view=diff&rev=483585&r1=483584&r2=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java Thu Dec  7 10:10:25 2006
@@ -18,31 +18,16 @@
  */
 package org.apache.yoko.bindings.corba;
 
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import javax.xml.namespace.QName;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.handler.MessageContext;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.transport.MessageObserver;
 
 import org.apache.schemas.yoko.bindings.corba.BindingType;
-import org.apache.schemas.yoko.bindings.corba.ModeType;
-import org.apache.schemas.yoko.bindings.corba.OperationType;
-import org.apache.schemas.yoko.bindings.corba.ParamType;
-import org.apache.yoko.bindings.corba.types.CorbaHandlerUtils;
-import org.apache.yoko.bindings.corba.types.CorbaObjectHandler;
-
-import org.objectweb.celtix.bindings.DataBindingCallback;
-import org.objectweb.celtix.bindings.ServerBindingEndpointCallback;
-import org.objectweb.celtix.bindings.ServerDataBindingCallback;
-import org.objectweb.celtix.context.GenericMessageContext;
-import org.objectweb.celtix.context.ObjectMessageContext;
-import org.objectweb.celtix.context.WebServiceContextImpl;
-
-import org.omg.CORBA.Any;
-import org.omg.CORBA.NVList;
 import org.omg.CORBA.ORB;
 import org.omg.CORBA.ServerRequest;
 import org.omg.PortableServer.DynamicImplementation;
@@ -50,25 +35,30 @@
 
 public class CorbaDSIServant extends DynamicImplementation {
 
-    private final ORB orb;
-    private final POA servantPOA;
-    private final CorbaServerBinding serverBinding;
-    private ServerBindingEndpointCallback sbeCallback;
+    private ORB orb;
+    private POA servantPOA;    
     private List<String> interfaces;
-
-    public CorbaDSIServant(ORB theOrb, POA poa, CorbaServerBinding binding,
-                           ServerBindingEndpointCallback epCallback) {
+    private MessageObserver incomingObserver;
+    private CorbaDestination destination;
+    
+    public CorbaDSIServant() {
+        //Complete
+    }
+    
+    public void init(ORB theOrb,
+                           POA poa,
+                           CorbaDestination dest,
+                           MessageObserver observer) {
         orb = theOrb;
         servantPOA = poa;
-        serverBinding = binding;
-        sbeCallback = epCallback;
-
+        destination = dest;
+        incomingObserver = observer;
+       
         // Get the list of interfaces that this servant will support
-        try {
-            BindingType bindType = CorbaUtils.getCorbaBindingType(binding.getBus(), 
-                                                                  binding.getEndpointReference());
+        try {                
+            BindingType bindType = destination.getBindingInfo().getExtensor(BindingType.class);            
             if (bindType == null) {
-                throw new CorbaBindingException("Unable to determine binding information");
+                throw new CorbaBindingException("Unable to determine corba binding information");
             }
 
             List<String> bases = bindType.getBases();
@@ -83,156 +73,35 @@
         }
     }
 
-    public void invoke(ServerRequest request) throws CorbaBindingException {
-        try {
-            CorbaMessageContext corbaCtx = 
-                (CorbaMessageContext)serverBinding.getBindingImpl().
-                    createBindingMessageContext(new GenericMessageContext());
-            corbaCtx.setMessage(new CorbaMessage());
-            corbaCtx.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.TRUE);
-
-            QName operationName = new QName(request.operation());
-            corbaCtx.put(MessageContext.WSDL_OPERATION, operationName);
-
-            ObjectMessageContext objectCtx = serverBinding.createObjectContext();
-            DataBindingCallback.Mode mode = sbeCallback.getServiceMode();
-            DataBindingCallback callback = 
-                sbeCallback.getDataBindingCallback((QName)corbaCtx.get(MessageContext.WSDL_OPERATION),
-                                                   objectCtx, 
-                                                   mode);
-            callback.initObjectContext(objectCtx);
-            objectCtx.putAll(corbaCtx);
-
-            // Get the WSDL definition for the operation being invoked 
-            // TODO: Verify that two operations can't be overloaded.
-            OperationType opElement = CorbaUtils.getCorbaOperationType(operationName.getLocalPart(), 
-                                                                       serverBinding.getBus(),
-                                                                       serverBinding.getEndpointReference());
-            if (opElement == null) {
-                throw new CorbaBindingException("Unable to locate operation type definition");
-            }
-
-            List<ParamType> paramTypes = opElement.getParam();
-            List<CorbaTypeMap> typeMaps = 
-                ((CorbaBindingImpl)serverBinding.getBindingImpl()).getCorbaTypeMaps();
-
-            // Build a list of streamables that correspond to the values that should be contained in the
-            // argument list of the ServerRequest, build the correct NVList and retreive the arguments
-            CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];
-            NVList list = prepareDIIArgsList(corbaCtx, objectCtx, arguments, paramTypes, typeMaps, callback);
-            request.arguments(list);
-
-            serverBinding.getBindingImpl().unmarshal(corbaCtx, objectCtx, callback);
-
-            boolean isOneWay = callback.isOneWay();
-            doCeltixInvocation(callback, objectCtx);
-
-            corbaCtx.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.FALSE);
-            if (!isOneWay) {
-                if (objectCtx.getException() != null) {
-                    serverBinding.getBindingImpl().marshalFault(objectCtx, corbaCtx, callback);
-                    Any exAny = orb.create_any();
-                    exAny.insert_Streamable(corbaCtx.getMessage().getStreamableException());
-                    request.set_exception(exAny);
-                } else {
-                    serverBinding.getBindingImpl().marshal(objectCtx, corbaCtx, callback);
-
-                    arguments = corbaCtx.getMessage().getStreamableArguments();
-                    for (int i = 0; i < arguments.length; ++i) {
-                        if (list.item(i).flags() != org.omg.CORBA.ARG_IN.value) {
-                            list.item(i).value().insert_Streamable(arguments[i]);
-                        }
-                    }
-
-                    CorbaStreamable resultValue = corbaCtx.getMessage().getStreamableReturn();
-                    if (resultValue != null) {
-                        Any resultAny = orb.create_any();
-                        resultAny.insert_Streamable(resultValue);
-                        request.set_result(resultAny);
-                    }
-                }
-            }
-
-        } catch (java.lang.Exception ex) {
-            throw new CorbaBindingException("Exception during invoke", ex);
-        }
+    protected MessageObserver getObserver() {
+        return incomingObserver;
     }
     
-    public NVList prepareDIIArgsList(CorbaMessageContext corbaCtx, ObjectMessageContext objContext, 
-                                     CorbaStreamable[] streamables, List<ParamType> params,  
-                                     List<CorbaTypeMap> typeMaps, DataBindingCallback callback) {
-        NVList list = orb.create_list(streamables.length);
-
-        // We need to check to see if Celtix is using the return type of the operation as the method for
-        // passing back the value of a CORBA out parameter.
-        Object[] args = objContext.getMessageObjects();
-        boolean hasOutParamReturn = false;
-        if (args != null) {
-            hasOutParamReturn = params.size() != args.length;
-        } else {
-            hasOutParamReturn = params.size() > 0;
-        }
-        
-        int paramOffset = 0;
-        int cbParamCount = 0;
-        for (Iterator<ParamType> iter = params.iterator(); iter.hasNext();) {
-            int index = cbParamCount + paramOffset;
-            ParamType pType = iter.next();
-            QName paramName = null;
-            if (pType.getMode().equals(ModeType.OUT) && hasOutParamReturn) {
-                paramName = new QName(callback.getWebResult().targetNamespace(),
-                                      callback.getWebResult().name());
-                paramOffset = 1;
-            } else {
-                paramName = new QName(callback.getWebParam(cbParamCount).targetNamespace(),
-                                      callback.getWebParam(cbParamCount).name());
-                cbParamCount++;
-            }
-            QName paramIdlType = pType.getIdltype();
-            ModeType paramMode = pType.getMode();
-
-            CorbaObjectHandler obj = 
-                CorbaHandlerUtils.initializeObjectHandler(orb, paramName, paramIdlType, typeMaps);
-
-            streamables[index] = new CorbaStreamable(obj, paramName);
-            if (paramMode.value().equals("in")) {
-                streamables[index].setMode(org.omg.CORBA.ARG_IN.value);
-            } else if (paramMode.value().equals("out")) {
-                streamables[index].setMode(org.omg.CORBA.ARG_OUT.value);
-            } else {
-                streamables[index].setMode(org.omg.CORBA.ARG_INOUT.value);
-            }
-
-            Any value = orb.create_any();
-            value.insert_Streamable(streamables[index]);
-            list.add_value(streamables[index].getName(), value, streamables[index].getMode());
-            corbaCtx.getMessage().addStreamableArgument(streamables[index]);
-        }
-        return list;
+    protected void setObserver(MessageObserver observer) {
+        incomingObserver = observer;
+    }
+    
+    protected ORB getOrb() {
+        return orb;
     }
 
-    public void doCeltixInvocation(DataBindingCallback callback, ObjectMessageContext objectCtx) {
-        try {
-            ServerDataBindingCallback method = (ServerDataBindingCallback) callback;
-            new WebServiceContextImpl(objectCtx);
-            method.invoke(objectCtx);
-        } catch (WebServiceException ex) {
-            Throwable cause = ex.getCause();
-            if (cause != null) {
-                objectCtx.setException(cause);
-            } else {
-                objectCtx.setException(ex);
-            }
-        } catch (InvocationTargetException ex) {
-            Throwable cause = ex.getCause();
-            if (cause != null) {
-                objectCtx.setException(cause);
-            } else {
-                objectCtx.setException(ex);
-            }
-        }
+    public CorbaDestination getDestination() {
+        return destination;
     }
     
+    public void invoke(ServerRequest request) throws CorbaBindingException {
+        MessageImpl msgImpl = new MessageImpl();
+        msgImpl.setDestination(getDestination());
+        Exchange exg = new ExchangeImpl();
+        exg.put(String.class, request.operation());
+        exg.put(ORB.class, getOrb());
+        exg.put(ServerRequest.class, request);
+        msgImpl.setExchange(exg);
+               
+        // invokes the interceptors        
+        getObserver().onMessage(msgImpl);              
+    }
+       
     public String[] _all_interfaces(POA poa, byte[] objectId) {
         return interfaces.toArray(new String[interfaces.size()]);
     }

Added: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java?view=auto&rev=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java (added)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java Thu Dec  7 10:10:25 2006
@@ -0,0 +1,221 @@
+/**
+ * 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.corba;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.AttributedURIType;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+
+import org.apache.schemas.yoko.bindings.corba.AddressType;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Policy;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.POAManager;
+
+public class CorbaDestination implements Destination {
+    
+    private static final Logger LOG = LogUtils.getL7dLogger(CorbaDestination.class);
+    private AddressType address;
+    private EndpointReferenceType reference;
+    private ORB orb;
+    private BindingInfo binding;
+    private EndpointInfo endpointInfo;
+
+    public CorbaDestination(EndpointInfo ei) {
+        address = ei.getExtensor(AddressType.class);
+        binding = ei.getBinding();
+        reference = new EndpointReferenceType();
+        AttributedURIType addr = new AttributedURIType();
+        addr.setValue(address.getLocation());
+        reference.setAddress(addr);
+        endpointInfo = ei;
+    }
+
+    public EndpointReferenceType getAddress() {
+        return reference;
+    }    
+
+    public Conduit getBackChannel(Message inMessage,
+                                  Message partialResponse,
+                                  EndpointReferenceType ref)
+        throws IOException {
+        return  new CorbaServerConduit(endpointInfo, reference);                
+    }
+
+    public BindingInfo getBindingInfo() {
+        return binding;
+    }
+    
+    public EndpointInfo getEndPointInfo() {
+        return endpointInfo;
+    }
+
+    public void shutdown() {
+        if (orb != null) {
+            try {
+                orb.destroy();
+            } catch (Exception ex) {
+                // TODO: For now, we just consume.  Revisit.
+            }
+        }
+    }
+    
+    protected ORB getOrb() {
+        return orb;
+    }
+    
+    protected AddressType getAddressType() {
+        return address;
+    }
+
+    public synchronized void setMessageObserver(MessageObserver observer) {
+        String location = address.getLocation();
+        LOG.info("Service address retrieved: " + location);
+        
+        // TODO: Get any configuration options for the ORB and set the appropriate properties.
+        java.util.Properties props = System.getProperties();
+        props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+        props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+        props.put("yoko.orb.id", "Yoko-Server-Binding");
+
+        // If we have one of these two types of addresses, we should specify the address
+        // and port information as properties to the ORB during initialization.
+        if (location.startsWith("IOR:")) {
+            // TODO: How to handle this? Can we obtain port/host information from the IOR
+            // or do we just want to let the ORB pick the port and export the IOR to the 
+            // Logs?
+        } else if (location.startsWith("corbaloc")) {
+            int corbalocIndex = location.indexOf(":");
+            int protocolIndex = location.indexOf(":", corbalocIndex + 1);
+            String protocol = location.substring(corbalocIndex + 1, protocolIndex);
+            int hostIndex = location.indexOf(":", protocolIndex + 1);
+            String host = location.substring(protocolIndex + 1, hostIndex);
+            // the port number should be followed by a '/' character
+            int portIndex = location.indexOf("/", hostIndex + 1);
+            String port = location.substring(hostIndex + 1, portIndex);
+            if (protocol.length() == 0) {
+                // This means no protocol was defined.  Default to iiop
+                protocol = "iiop";
+            }
+            props.put("yoko.orb.oa.endpoint", new String(protocol + " --host " + host + " --port " + port));
+            LOG.info("Set server endpoint: " + protocol + " --host " + host + " --port " + port);
+        }
+        orb = ORB.init(new String[0], props);
+        activate(observer);
+    }
+
+    public void activate(MessageObserver observer) {
+        // Get the address that the DSI servant should be publishing
+        String location = address.getLocation();
+
+        org.omg.CORBA.Object obj = null;
+        try {
+            POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
+            POAManager poaManager = rootPOA.the_POAManager();
+
+            Policy[] policies = new Policy[3];
+            policies[0] = rootPOA
+                    .create_lifespan_policy(
+                        org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
+            policies[1] = rootPOA
+                    .create_implicit_activation_policy(
+                        org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
+            policies[2] = rootPOA
+                    .create_id_uniqueness_policy(
+                        org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
+
+            POA bindingPOA = rootPOA.create_POA("BindingPOA", poaManager, policies);
+           // CorbaDSIServant servant = new CorbaDSIServant(orb, bindingPOA, this, observer);
+            CorbaDSIServant servant = new CorbaDSIServant();
+            servant.init(orb, bindingPOA, this, observer);
+            byte[] objectId = bindingPOA.activate_object(servant);
+            obj = bindingPOA.id_to_reference(objectId);
+            
+            if (location.startsWith("relfile:")) {
+                String iorFile = location.substring("relfile:".length(), location.length());
+                // allow for up to 3 '/' to match common uses of relfile url format
+                for (int n = 0; n < 3; n++) {
+                    if (iorFile.charAt(0) != '/') {
+                        break;
+                    } else {
+                        iorFile = iorFile.substring(1);
+                    }
+                }
+
+                CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
+            } else if (location.startsWith("file:")) {
+                String iorFile = location.substring("file:".length(), location.length());
+                // allow for up to 3 '/' to match common uses of file url format
+                for (int n = 0; n < 3; n++) {
+                    if (iorFile.charAt(0) != '/') {
+                        break;
+                    } else {
+                        iorFile = iorFile.substring(1);
+                    }
+                }
+                // to match the ORB, file must have complete path information, therefore we add
+                // a '/' prefix to the address
+                //iorFile = "/" + iorFile;
+                CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
+            } else if (location.startsWith("corbaloc")) {
+                // Try add the key to the boot manager.  This is required for a corbaloc
+                try {
+                    int keyIndex = location.indexOf('/');
+                    String key = location.substring(keyIndex + 1);
+                    org.apache.yoko.orb.OB.BootManager bootManager = 
+                        org.apache.yoko.orb.OB.BootManagerHelper.narrow(
+                            orb.resolve_initial_references("BootManager"));
+                    bootManager.add_binding(key.getBytes(), obj);
+                    LOG.info("Added key " + key + " to bootmanager");
+                } catch (Exception ex) {
+                    // TODO: Continue without for now
+                }
+                String ior = orb.object_to_string(obj);
+                address.setLocation(ior);
+                String iorFile = "endpoint.ior";
+                CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
+            } else {
+                String ior = orb.object_to_string(obj);
+                address.setLocation(ior);
+                String iorFile = "endpoint.ior";
+                CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
+                LOG.info("Object Reference: " + orb.object_to_string(obj));
+            }
+            // TODO: Provide other export mechanisms? 
+            
+            poaManager.activate();
+        } catch (Exception ex) {
+            // TODO: Throw appropriate exception
+            throw new CorbaBindingException("Unable to activate CORBA servant", ex);
+        }
+    }    
+
+}

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java?view=diff&rev=483585&r1=483584&r2=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java Thu Dec  7 10:10:25 2006
@@ -1,101 +1,105 @@
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.yoko.bindings.corba;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.cxf.message.AbstractWrappedMessage;
+import org.apache.cxf.message.Message;
+
 import org.apache.yoko.bindings.corba.types.CorbaObjectHandler;
+import org.omg.CORBA.NVList;
 
-public class CorbaMessage {
+public class CorbaMessage extends AbstractWrappedMessage {
 
-    private String operation;
     private List<CorbaStreamable> arguments;
     private CorbaStreamable returnParam;
     private CorbaStreamable except;
-    private Exception exception;
-
-    public CorbaMessage() {
-        operation = null;
-        arguments = new ArrayList<CorbaStreamable>();
-        returnParam = null;
-        exception = null;
-        except = null;
-    }
-
-    public String getOperationName() {
-        return operation;
-    }
+    private NVList list;
 
-    public void setOperationName(String opName) {
-        operation = opName;
+    public CorbaMessage(Message m) {
+        super(m);
+        if (m instanceof CorbaMessage) {
+            CorbaMessage msg = (CorbaMessage)m;
+            CorbaStreamable[] data = msg.getStreamableArguments();
+            setStreamableArguments(data);            
+            returnParam = msg.getStreamableReturn();
+            except = msg.getStreamableException();
+            list = msg.getList();
+        } else {
+            this.arguments = new ArrayList<CorbaStreamable>();    
+        }        
     }
 
-    public void setException(Exception ex) {
-        exception = ex;
+    
+    public void setList(NVList lst) {
+        this.list = lst;
     }
-
-    public Exception getException() {
-        return exception;
+    
+    public NVList getList() {
+        return this.list;
     }
     
     public CorbaStreamable getStreamableException() {
-        return except;
-    }
-
-    public CorbaStreamable[] getStreamableArguments() {
-        return arguments.toArray(new CorbaStreamable[0]);
+        return this.except;
     }
 
     public CorbaStreamable getStreamableReturn() {
-        return returnParam;
+        return this.returnParam;
     }
 
     public void addStreamableArgument(CorbaStreamable arg) {
-        if (arguments == null) {
-            arguments = new ArrayList<CorbaStreamable>(1);
+        if (this.arguments == null) {
+            this.arguments = new ArrayList<CorbaStreamable>(1);
         }
 
-        arguments.add(arg);
+        this.arguments.add(arg);
+    }
+    
+    public CorbaStreamable[] getStreamableArguments() {
+        return this.arguments.toArray(new CorbaStreamable[0]);
     }
 
+
     public void setStreamableArguments(CorbaStreamable[] data) {
-        if (arguments == null) {
-            arguments = new ArrayList<CorbaStreamable>(data.length);
+        if (this.arguments == null) {
+            this.arguments = new ArrayList<CorbaStreamable>(data.length);
         }
 
-        for (int i = 0; i < data.length; ++i) {
-            arguments.set(i, data[i]);
-        }
+        for (CorbaStreamable streamable : data) {         
+            addStreamableArgument(streamable);
+        }       
     }
 
     public void setStreamableArgumentValue(CorbaObjectHandler data, int idx) {
-        if (idx >= arguments.size()) {
+        if (idx >= this.arguments.size()) {
             throw new CorbaBindingException("setStreamableArgumentValue: Index out of range");
         }
 
-        arguments.get(idx).setObject(data);
+        this.arguments.get(idx).setObject(data);
     }
 
     public void setStreamableArgumentValues(CorbaObjectHandler[] data) {
         for (int i = 0; i < data.length; ++i) {
-            arguments.get(i).setObject(data[i]);
+            this.arguments.get(i).setObject(data[i]);
         }
     }
 
@@ -117,8 +121,4 @@
         except.setObject(exData);
     }
 
-    public String toString() {
-        // TODO: Add a more complete toString
-        return operation;
-    }
-}
\ No newline at end of file
+}

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java?view=diff&rev=483585&r1=483584&r2=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java Thu Dec  7 10:10:25 2006
@@ -27,6 +27,7 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.schemas.yoko.bindings.corba.CaseType;
 import org.apache.schemas.yoko.bindings.corba.Enum;
 import org.apache.schemas.yoko.bindings.corba.Enumerator;
@@ -43,8 +44,6 @@
 import org.apache.yoko.bindings.corba.types.CorbaStructHandler;
 import org.apache.yoko.bindings.corba.types.CorbaUnionHandler;
 
-import org.objectweb.celtix.common.logging.LogUtils;
-
 import org.omg.CORBA.Any;
 import org.omg.CORBA.TCKind;
 import org.omg.CORBA.TypeCode;
@@ -52,7 +51,7 @@
 
 public class CorbaObjectReader {
 
-    private static final Logger LOG = LogUtils.getL7dLogger(CorbaBindingImpl.class);
+    private static final Logger LOG = LogUtils.getL7dLogger(CorbaObjectReader.class);
 
     private InputStream stream;
 
@@ -287,8 +286,8 @@
         CorbaStructHandler structObj = (CorbaStructHandler)obj;
         List<CorbaObjectHandler> structMembers = structObj.getMembers();
 
-        for (Iterator<CorbaObjectHandler> iter = structMembers.iterator(); iter.hasNext();) {
-            this.read(iter.next());
+        for (int i = 0; i < structMembers.size(); ++i) {
+            this.read(structMembers.get(i));
         }
     }
 
@@ -299,8 +298,8 @@
         String exceptId = stream.read_string();
         exceptObj.setId(exceptId);
 
-        for (Iterator<CorbaObjectHandler> iter = exceptElements.iterator(); iter.hasNext();) {
-            this.read(iter.next());
+        for (int i = 0; i < exceptElements.size(); ++i) {
+            this.read(exceptElements.get(i));
         }
     }
 
@@ -330,8 +329,8 @@
         List<Unionbranch> branches = unionType.getUnionbranch();
         Unionbranch defaultBranch = null;
         boolean caseFound = false;
-        for (Iterator<Unionbranch> iter = branches.iterator(); iter.hasNext();) {
-            Unionbranch branch = iter.next();
+        for (Iterator<Unionbranch> branchIter = branches.iterator(); branchIter.hasNext();) {
+            Unionbranch branch = branchIter.next();
             if (branch.isSetDefault() && branch.isDefault()) {
                 defaultBranch = branch;
             }
@@ -364,8 +363,8 @@
         CorbaArrayHandler arrayObj = (CorbaArrayHandler)obj;
         List<CorbaObjectHandler> arrayElements = arrayObj.getElements();
 
-        for (Iterator<CorbaObjectHandler> iter = arrayElements.iterator(); iter.hasNext();) {
-            this.read(iter.next());
+        for (int i = 0; i < arrayElements.size(); ++i) {
+            this.read(arrayElements.get(i));
         }
     }
 

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectWriter.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectWriter.java?view=diff&rev=483585&r1=483584&r2=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectWriter.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectWriter.java Thu Dec  7 10:10:25 2006
@@ -19,7 +19,6 @@
 package org.apache.yoko.bindings.corba;
 
 import java.math.BigInteger;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.schemas.yoko.bindings.corba.Enum;
@@ -193,8 +192,6 @@
         String enumLabel = enumHandler.getValue();
         List<Enumerator> enumerators = enumType.getEnumerator();
         
-        // We won't use an iterator here so that we have the index number of the enumerator string.
-        // This is how CORBA references enums when reading and writing to streams.
         for (int i = 0; i < enumerators.size(); ++i) {
             if (enumerators.get(i).getValue().equals(enumLabel)) {
                 stream.write_long(i);
@@ -209,8 +206,8 @@
         CorbaStructHandler structHandler = (CorbaStructHandler)obj;
         List<CorbaObjectHandler> structElements = structHandler.getMembers();
 
-        for (Iterator<CorbaObjectHandler> iter = structElements.iterator(); iter.hasNext();) {
-            this.write(iter.next());
+        for (int i = 0; i < structElements.size(); ++i) {
+            this.write(structElements.get(i));
         }
     }
 
@@ -242,8 +239,8 @@
         CorbaArrayHandler arrayHandler = (CorbaArrayHandler)obj;
         List<CorbaObjectHandler> arrayElements = arrayHandler.getElements();
 
-        for (Iterator<CorbaObjectHandler> iter = arrayElements.iterator(); iter.hasNext();) {
-            this.write(iter.next());
+        for (int i = 0; i < arrayElements.size(); ++i) {
+            this.write(arrayElements.get(i));
         }
     }
 
@@ -254,8 +251,8 @@
 
         stream.write_ulong(length);
 
-        for (Iterator<CorbaObjectHandler> iter = seqElements.iterator(); iter.hasNext();) {
-            this.write(iter.next());
+        for (int i = 0; i < length; ++i) {
+            this.write(seqElements.get(i));
         }
     }
-}
\ No newline at end of file
+}

Added: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java?view=auto&rev=483585
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java (added)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java Thu Dec  7 10:10:25 2006
@@ -0,0 +1,207 @@
+/**
+ * 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.corba;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.io.AbstractCachedOutputStream;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.EndpointInfo;
+
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.AttributedURIType;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.schemas.yoko.bindings.corba.AddressType;
+import org.apache.yoko.wsdl.CorbaConstants;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ServerRequest;
+
+
+public class CorbaServerConduit implements Conduit {
+    private static final Logger LOG = LogUtils.getL7dLogger(CorbaConduit.class);
+
+    private EndpointInfo endpointInfo;
+    private EndpointReferenceType target;
+    private MessageObserver incomingObserver;
+    private ORB orb;
+
+    public CorbaServerConduit(EndpointInfo ei, EndpointReferenceType ref) {
+        endpointInfo = ei;
+        target = getTargetReference(ref);
+        // TODO: Set any additional properties needed to initialize the ORB  before
+        // we initialize it. We will get this information from the Celtix configuration 
+        // that is used with the current application.
+        java.util.Properties props = System.getProperties();
+        props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+        props.put("org.omg.CORBA.ORBSingletonClass",
+                "org.apache.yoko.orb.CORBA.ORBSingleton");
+        props.put("yoko.orb.id", "Yoko-Client-Binding");
+
+        orb = ORB.init(new String[0], props);
+        if (orb == null) {
+            LOG.severe("Could not create instance of the ORB");
+            throw new CorbaBindingException("Could not create instance of the ORB");
+        }
+    }
+
+    public void send(Message message) throws IOException {
+        
+        System.out.println("send message...");
+        try {
+            AddressType address = endpointInfo.getExtensor(AddressType.class);
+
+            if (address == null) {
+                LOG.log(Level.SEVERE, "Unable to locate a valid CORBA address");
+                throw new CorbaBindingException("Unable to locate a valid CORBA address");
+            }            
+            org.omg.CORBA.Object targetObject = CorbaUtils.importObjectReference(orb, address.getLocation());
+            message.put(CorbaConstants.ORB, orb);
+            message.put(CorbaConstants.CORBA_ENDPOINT_OBJECT, targetObject);
+            message.setContent(OutputStream.class,
+                               new CorbaOutputStream(message));
+        } catch (java.lang.Exception ex) {
+            LOG.log(Level.SEVERE, "Could not resolve target object");
+            throw new CorbaBindingException(ex);
+        }
+    }
+
+    public void close(Message message) throws IOException {        
+        buildRequestResult((CorbaMessage)message);
+        message.getContent(OutputStream.class).close();
+    }
+
+    public EndpointReferenceType getTarget() {
+        return target;
+    }
+
+    public Destination getBackChannel() {
+        return null;
+    }
+
+    public void close() {
+    }
+
+    public void setMessageObserver(MessageObserver observer) {
+        incomingObserver = observer;
+    }
+
+    public EndpointReferenceType getTargetReference(EndpointReferenceType t) {
+        EndpointReferenceType ref = null;
+        if (null == t) {
+            ref = new EndpointReferenceType();
+            AttributedURIType address = new AttributedURIType();
+            address.setValue(getAddress());
+            ref.setAddress(address);
+        } else {
+            ref = t;
+        }
+        return ref;
+    }
+
+    protected String getAddress() {
+        return endpointInfo.getAddress();
+    }
+    
+    
+    protected void buildRequestResult(CorbaMessage msg) {        
+        Exchange exg = msg.getExchange();        
+        ServerRequest request = exg.get(ServerRequest.class);
+        try {
+            if (!exg.isOneWay()) {                
+                CorbaMessage inMsg = (CorbaMessage)msg.getExchange().getInMessage();
+                NVList list = inMsg.getList();
+
+                if (msg.getStreamableException() != null) {                    
+                    Any exAny = orb.create_any();
+                    CorbaStreamable exception = msg.getStreamableException();
+                    exAny.insert_Streamable(exception);
+                    request.set_exception(exAny);
+                } else {
+                    CorbaStreamable[] arguments = msg.getStreamableArguments();
+                    if (arguments != null) {
+                        for (int i = 0; i < arguments.length; ++i) {
+                            if (list.item(i).flags() != org.omg.CORBA.ARG_IN.value) {
+                                list.item(i).value().insert_Streamable(arguments[i]);
+                            }   
+                        }
+                    }
+
+                    CorbaStreamable resultValue = msg.getStreamableReturn();
+                    if (resultValue != null) {
+                        Any resultAny = orb.create_any();
+                        resultAny.insert_Streamable(resultValue);
+                        request.set_result(resultAny);
+                    }
+                }
+            }
+
+        } catch (java.lang.Exception ex) {
+            throw new CorbaBindingException("Exception during buildRequestResult", ex);
+        }
+    }        
+    
+    private class CorbaOutputStream extends AbstractCachedOutputStream {
+        
+        private Message outMessage;                
+
+        CorbaOutputStream(Message m) {
+            outMessage = m;        
+        }
+
+        /**
+         * Perform any actions required on stream flush (freeze headers, reset
+         * output stream ... etc.)
+         */
+        public void doFlush() throws IOException {
+
+            // do nothing here
+        }
+
+        /**
+         * Perform any actions required on stream closure (handle response etc.)
+         */
+        public void doClose() throws IOException {
+            System.out.println("In do close of outputstream");
+            if (ContextUtils.isRequestor(outMessage) && ContextUtils.isOutbound(outMessage)) {
+                System.out.println("is requester and outbound message");
+            } else  if (!ContextUtils.isRequestor(outMessage) && !ContextUtils.isOutbound(outMessage)) {
+                System.out.println("is not requester and is inbound message");
+            } else if (!ContextUtils.isRequestor(outMessage) && ContextUtils.isOutbound(outMessage)) {
+                System.out.println("is not requester and is outbound message");
+            } else if (ContextUtils.isRequestor(outMessage) && !ContextUtils.isOutbound(outMessage)) {
+                System.out.println("is requester and is inbound message");
+            }
+        }
+
+        public void onWrite() throws IOException {
+
+        }
+    }
+}

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message