tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r562382 - in /incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util: EJBLocator.java EJBObjectFactory.java
Date Fri, 03 Aug 2007 08:16:31 GMT
Author: rfeng
Date: Fri Aug  3 01:16:31 2007
New Revision: 562382

URL: http://svn.apache.org/viewvc?view=rev&rev=562382
Log:
Workaround an Apache Yoko ORB issue for locating stubs

Modified:
    incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
    incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java

Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java?view=diff&rev=562382&r1=562381&r2=562382
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
Fri Aug  3 01:16:31 2007
@@ -489,6 +489,22 @@
         private Context context;
 
         private JndiLocator() throws NamingException {
+            /*
+            final Properties props = AccessController.doPrivileged(new PrivilegedAction<Properties>()
{
+                public Properties run() {
+                    return System.getProperties();
+                }
+            });
+            Properties properties = new Properties();
+            for (Map.Entry e : props.entrySet()) {
+                String name = (String)e.getKey();
+                if (name.startsWith("java.naming.")) {
+                    properties.setProperty(name, (String)e.getValue());
+                }
+            }
+            // System.out.println(properties);
+            this.context = new InitialContext(properties);
+            */
             this.context = new InitialContext();
         }
 

Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java?view=diff&rev=562382&r1=562381&r2=562382
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java
Fri Aug  3 01:16:31 2007
@@ -20,7 +20,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.rmi.Remote;
 import java.rmi.RemoteException;
 import java.rmi.UnexpectedException;
 
@@ -33,6 +32,7 @@
 import org.omg.CORBA.portable.ApplicationException;
 import org.omg.CORBA.portable.ObjectImpl;
 import org.omg.CORBA.portable.RemarshalException;
+import org.omg.stub.java.rmi._Remote_Stub;
 import org.osoa.sca.ServiceRuntimeException;
 
 public final class EJBObjectFactory {
@@ -53,8 +53,8 @@
      * of the pregenerated EJB stub classes be avaiable in the classpath.
      * <p>
      */
-    public static Object createStub(NamingEndpoint namingEndpoint, InterfaceInfo ejbInterface)
throws NamingException, RemoteException,
-        CreateException {
+    public static Object createStub(NamingEndpoint namingEndpoint, InterfaceInfo ejbInterface)
throws NamingException,
+        RemoteException, CreateException {
 
         EJBLocator locator = namingEndpoint.getLocator();
         Object homeObject = locator.locate(namingEndpoint.getJndiName());
@@ -75,23 +75,20 @@
      * @return
      * @throws RemoteException
      */
-    protected static Object getEJBStub(Object homeObject, InterfaceInfo ejbInterface) throws
RemoteException, CreateException {
+    protected static Object getEJBStub(Object homeObject, InterfaceInfo ejbInterface) throws
RemoteException,
+        CreateException {
 
         Object stub = null;
 
         // Get the business interface of the EJB 
         Class ejbInterfaceClass = null;
-        try
-        {
+        try {
             ejbInterfaceClass = Thread.currentThread().getContextClassLoader().loadClass(ejbInterface.getName());
-        }
-        catch (ClassNotFoundException e)
-        {
+        } catch (ClassNotFoundException e) {
             // ignore
         }
-        
-        if (ejbInterfaceClass != null && ejbInterfaceClass.isInstance(homeObject))
-        {
+
+        if (ejbInterfaceClass != null && ejbInterfaceClass.isInstance(homeObject))
{
             // EJB 3
             stub = homeObject;
         } else if (homeObject instanceof EJBLocalHome) {
@@ -102,20 +99,20 @@
             if (homeObject instanceof ObjectImpl) {
                 ObjectImpl objectImpl = (ObjectImpl)homeObject;
                 stub = createEJBObject(objectImpl);
-            } /**
-            	* Above checks will be satisfied if Bean is running on servers like Websphere.
With this 
-            	* logic, client (SCA composite with EJB ref binding) doesn't need to include
home class or 
-            	* client stubs.
-            	* 
-            	* Below check is needed SCA composite with EJB ref binding is accessing openEJB
implementation. 
-            	* For e.g if the bean is running on Geronimo. 
-            	*/
-            else if ((javax.rmi.PortableRemoteObject.narrow(homeObject, javax.ejb.EJBHome.class))
instanceof javax.ejb.EJBHome) { 
+            }/**
+                       	* Above checks will be satisfied if Bean is running on servers like
Websphere. With this 
+                       	* logic, client (SCA composite with EJB ref binding) doesn't need
to include home class or 
+                       	* client stubs.
+                       	* 
+                       	* Below check is needed SCA composite with EJB ref binding is accessing
openEJB implementation. 
+                       	* For e.g if the bean is running on Geronimo. 
+                       	*/
+            else if ((javax.rmi.PortableRemoteObject.narrow(homeObject, javax.ejb.EJBHome.class))
instanceof javax.ejb.EJBHome) {
                 stub = createEJBObjectFromHome(homeObject);
             } else
                 throw new ServiceRuntimeException("Invalid stub type: " + homeObject.getClass());
-            }
-        	return stub;
+        }
+        return stub;
     }
 
     /**
@@ -169,7 +166,7 @@
         }
         return stub;
     }
-    
+
     /**
      * Create an EJBObject using RMI/IIOP APIs
      * 
@@ -186,7 +183,8 @@
                 org.omg.CORBA.portable.OutputStream out = ejbHomeObject._request("create",
true);
                 in = (org.omg.CORBA_2_3.portable.InputStream)ejbHomeObject._invoke(out);
                 // The Remote stub should be available in JDK
-                return in.read_Object(Remote.class);
+                // TODO: [rfeng] Work around an issue in Apache Yoko which doesn't understand
the org.omg.stub.*
+                return in.read_Object(_Remote_Stub.class);
             } catch (ApplicationException ex) {
                 in = (org.omg.CORBA_2_3.portable.InputStream)ex.getInputStream();
                 String id = in.read_string();



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message