You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by dm...@apache.org on 2007/03/22 19:33:30 UTC

svn commit: r521415 - in /incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba: CorbaConduit.java CorbaDestination.java

Author: dmiddlem
Date: Thu Mar 22 12:33:29 2007
New Revision: 521415

URL: http://svn.apache.org/viewvc?view=rev&rev=521415
Log:
Bug fixes for object reference support in the binding runtime (YOKO-270)
* ENDPOINT_ADDRESS property provides a String, not an EndpointReferenceType
* Need to handle obtaining an address for a Destination from an EndpointInfo,
  in addition to from the WSDL file.  This is to support ObjectReferences 
  without having to list all possible endpoint addresses for the reference 
  in the WSDL file.

Modified:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java

Modified: 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=diff&rev=521415&r1=521414&r2=521415
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java Thu Mar 22 12:33:29 2007
@@ -89,13 +89,14 @@
                 throw new CorbaBindingException("Unable to locate a valid CORBA address");
             }
             List args = message.getContent(List.class);
-            EndpointReferenceType ref = (EndpointReferenceType)message.get(Message.ENDPOINT_ADDRESS);
+            //EndpointReferenceType ref = (EndpointReferenceType)message.get(Message.ENDPOINT_ADDRESS);
+            String ref = (String)message.get(Message.ENDPOINT_ADDRESS);
             org.omg.CORBA.Object targetObject;
             // A non-null endpoint address from the message means that we want to invoke on a particular
             // object reference specified by the endpoint reference type.  If the reference is null, then
             // we want to invoke on the default location as specified in the WSDL.
             if (ref != null) {
-                targetObject = CorbaObjectReferenceHelper.getReferenceById(ref.getAddress().getValue());  
+                targetObject = CorbaObjectReferenceHelper.getReferenceById(ref);  
             } else {
                 targetObject = CorbaUtils.importObjectReference(orb, address.getLocation());
             }

Modified: 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=diff&rev=521415&r1=521414&r2=521415
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java Thu Mar 22 12:33:29 2007
@@ -102,9 +102,9 @@
     }
 
     public synchronized void setMessageObserver(MessageObserver observer) {
-        String location = address.getLocation();
+        String location = getDestinationAddress();
         LOG.info("Service address retrieved: " + location);
-        System.out.println("Service address retrieved: " + location);
+        
         orb = CorbaBindingHelper.getAddressSpecificORB(location);
         if (orb == null) {
             LOG.log(Level.INFO, "Creating ORB with address " + location);
@@ -114,8 +114,7 @@
     }
 
     public void activate(MessageObserver observer) {
-        // Get the address that the DSI servant should be publishing
-        String location = address.getLocation();
+        String location = getDestinationAddress();
         
         org.omg.CORBA.Object obj = null;
         try {
@@ -155,7 +154,7 @@
             // parameters and return types.  Note that we need the actual endpoint that
             // this object reference has been created on.  This is available through the
             // endpointInfo object passed during construction.
-            CorbaObjectReferenceHelper.addReference(endpointInfo.getAddress(), obj);
+            CorbaObjectReferenceHelper.addReference(location, obj);
            
             if (location.startsWith("relfile:")) {
                 String iorFile = location.substring("relfile:".length(), location.length());
@@ -185,21 +184,13 @@
                 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(
+                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);
+                bootManager.add_binding(key.getBytes(), obj);
+                LOG.info("Added key " + key + " to bootmanager");
             } else {
                 String ior = orb.object_to_string(obj);
                 address.setLocation(ior);
@@ -211,9 +202,34 @@
             
             poaManager.activate();
         } catch (Exception ex) {
-            // TODO: Throw appropriate exception
             throw new CorbaBindingException("Unable to activate CORBA servant", ex);
         }
-    }    
+    }
 
+    public String getDestinationAddress() {
+        // We should check the endpoint first for an address.  This allows object references
+        // to use the address that is associated with their endpoint instead of the single 
+        // address for a particular port type that is listed in the wsdl.  Otherwise, for all 
+        // object references we want to create, we would need to add the address to the wsdl 
+        // file before running the application.
+        String location = null;
+        if (endpointInfo != null) {
+            location = endpointInfo.getAddress();
+
+            // CXF seems to prefix an address it doesn't understand with the string
+            // "http://localhost" (any address that does not contain the characters '://'. 
+            // Since we know that http is not valid for a corba address, check for the
+            // existance of this string at the beginning of our address and remove if
+            // necessary.
+            if (location.startsWith("http://localhost")) {
+                location = location.substring("http://localhost".length());
+            }
+        }
+
+        if (location == null) {
+            location = address.getLocation();
+        }
+
+        return location;
+    }
 }