Hi, Ant.

Good point. It seems that Geronimo is very close to have the 2.0 release out and hopefully we can move to it soon.

Thanks,
Raymond

----- Original Message ----- From: "ant elder" <[EMAIL PROTECTED]>
To: <tuscany-dev@ws.apache.org>
Sent: Friday, August 03, 2007 2:37 AM
Subject: Re: svn commit: r562291 - in /incubator/tuscany/java/sca/modules: binding-ejb/ binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/ binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/java2idl/ binding-ejb/src/main/java/org/apache/t


Just a reminder we can't release with snapshot dependencies so we'll if
there's something we require in these OpenEJB and Geronimo snapshots then we
wont be able to include the EJB binding in a Tuscany release till there's
non-snapshot releases we can use.

  ...ant

On 8/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Author: rfeng
Date: Thu Aug  2 16:37:30 2007
New Revision: 562291

URL: http://svn.apache.org/viewvc?view=rev&rev=562291
Log:
Improve the binding-ejb:
* OpenEJB 3.0.0 SNAPSHOT and Geronimo 2.0 SNAPSHOT
* Support for OpenEJB JNDI and CosNaming
* Simplified Java2IDL

Removed:


incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/java2idl/
Modified:
    incubator/tuscany/java/sca/modules/binding-ejb/pom.xml


incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBTargetInvoker.java


incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java


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


incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java


incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java


incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java


incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java


incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java


incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java


incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java


incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite

incubator/tuscany/java/sca/modules/implementation-java-runtime/pom.xml

Modified: incubator/tuscany/java/sca/modules/binding-ejb/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/pom.xml?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/pom.xml Thu Aug  2
16:37:30 2007
@@ -50,7 +50,7 @@
             <groupId>cglib</groupId>
             <artifactId>cglib-nodep</artifactId>
             <version>2.1_3</version>
-            <scope>runtime</scope>
+            <scope>compile</scope>
         </dependency>

         <dependency>
@@ -85,11 +85,16 @@
         <!-- yuk. all the exclusions are necessary as otherwise just
about every geronimo
             jar gets downloaded, and also there's a problem with one of
the pom's causing
             the build to always fail -->
-
         <dependency>
-            <groupId>openejb</groupId>
+            <groupId>org.apache.openejb</groupId>
+            <artifactId>openejb-client</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openejb</groupId>
             <artifactId>openejb-core</artifactId>
-            <version>2.1.1</version>
+            <version>3.0.0-SNAPSHOT</version>
             <scope>test</scope>

             <exclusions>
@@ -181,18 +186,22 @@
                     <groupId>org.apache.geronimo.specs</groupId>
                     <artifactId>geronimo-servlet_2.4_spec</artifactId>
                 </exclusion>
-                <exclusion>
+                <!--
+                    <exclusion>
                     <groupId>org.apache.geronimo.specs</groupId>

<artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
-                </exclusion>
+                    </exclusion>
+                -->
                 <exclusion>
                     <groupId>org.apache.geronimo.specs</groupId>
                     <artifactId>geronimo-j2ee-jacc_1.0_spec</artifactId>
                 </exclusion>
+                <!--
                 <exclusion>
                     <groupId>org.apache.geronimo.specs</groupId>
                     <artifactId>geronimo-jms_1.1_spec</artifactId>
                 </exclusion>
+                 -->
                 <exclusion>
                     <groupId>org.apache.geronimo.specs</groupId>

<artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
@@ -249,10 +258,12 @@
                     <groupId>concurrent</groupId>
                     <artifactId>concurrent</artifactId>
                 </exclusion>
-                <exclusion>
+                <!--
+                    <exclusion>
                     <groupId>log4j</groupId>
                     <artifactId>log4j</artifactId>
-                </exclusion>
+                    </exclusion>
+                -->
                 <exclusion>
                     <groupId>mx4j</groupId>
                     <artifactId>mx4j</artifactId>
@@ -273,10 +284,12 @@
                     <groupId>commons-cli</groupId>
                     <artifactId>commons-cli</artifactId>
                 </exclusion>
-                <exclusion>
+                <!--
+                    <exclusion>
                     <groupId>asm</groupId>
                     <artifactId>asm</artifactId>
-                </exclusion>
+                    </exclusion>
+                -->
                 <exclusion>
                     <groupId>axis</groupId>
                     <artifactId>axis</artifactId>

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBTargetInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBTargetInvoker.java?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBTargetInvoker.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBTargetInvoker.java
Thu Aug  2 16:37:30 2007
@@ -45,7 +45,7 @@
             msg.setBody(resp);
         } catch (Throwable e) {
             e.printStackTrace();
-            msg.setBody(e);
+            msg.setFaultBody(e);
         }
         return msg;
     }

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
Thu Aug  2 16:37:30 2007
@@ -18,12 +18,9 @@
  */
package org.apache.tuscany.sca.binding.ejb.util;

-import java.io.Externalizable;
-import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.rmi.RemoteException;
-import java.rmi.UnexpectedException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
@@ -32,8 +29,6 @@
import javax.ejb.EJBObject;
import javax.rmi.CORBA.Util;

-import org.apache.tuscany.sca.binding.ejb.java2idl.ExceptionType;
-import org.apache.tuscany.sca.binding.ejb.java2idl.Java2IDLUtil;
import org.omg.CORBA.ORB;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.portable.ApplicationException;
@@ -306,25 +301,12 @@

             } catch (ApplicationException ex) {
                 in = (InputStream)ex.getInputStream();
-                String id = in.read_string();
- // Check if the id matches to any declared exceptions for
the
-                // method
- String[] exceptionTypes = methodInfo.getExceptionTypes();
-                for (int i = 0; i < exceptionTypes.length; i++) {
-                    Class exceptionType = loadClass(exceptionTypes[i]);
-                    String exceptionId = ExceptionType.getExceptionType
(exceptionType).getExceptionRepositoryId();
-                    if (id.equals(exceptionId)) {
-                        Throwable t =
(Throwable)in.read_value(exceptionType);
-                        throw new ServiceRuntimeException(t); // FIXME
should
-                        // be
-                        // ServcieBusinessException?
-                        // no support by
-                        // Tuscany core
-                        // for
-                        // ServcieBusinessException.
-                    }
+                try {
+
org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.throwException(
methodInfo.getMethod(), in);
+                    return null;
+                } catch (Throwable e) {
+                    throw new RemoteException(e.getMessage(), e);
                 }
-                throw new UnexpectedException(id);
             } catch (RemarshalException ex) {
                 return invokeRemoteCORBACall(stub, methodName, args);
             } finally {
@@ -341,39 +323,7 @@
      * @param type
      */
protected void writeValue(OutputStream out, Object value, Class type)
{
-        if (type == null)
-            out.write_value((Serializable)value);
-        else if (type == Object.class || type == Serializable.class ||
type == Externalizable.class) {
-            // Any
-            Util.writeAny(out, value);
-        } else if (type == Integer.TYPE) {
-            // java int maps to CORBA long
-            out.write_long(((Integer)value).intValue());
-        } else if (type == Short.TYPE) {
-            out.write_short(((Short)value).shortValue());
-        } else if (type == Boolean.TYPE) {
-            out.write_boolean(((Boolean)value).booleanValue());
-        } else if (type == Byte.TYPE) {
-            out.write_octet(((Byte)value).byteValue());
-        } else if (type == Long.TYPE) {
-            out.write_longlong(((Long)value).longValue());
-        } else if (type == Double.TYPE) {
-            out.write_double(((Double)value).doubleValue());
-        } else if (type == Float.TYPE) {
-            out.write_float(((Float)value).floatValue());
-        } else if (type == Character.TYPE) {
-            out.write_wchar(((Character)value).charValue());
-        } else if (type.isArray()) {
-            out.write_value((Serializable)value, type);
-        } else if (Java2IDLUtil.isRemoteInterface(type)) {
-            // Remote interface
-            Util.writeRemoteObject(out, value);
-        } else if (Java2IDLUtil.isAbstractInterface(type)) {
-            // Non-remote Interface
-            Util.writeAbstractObject(out, value);
-        } else {
-            out.write_value((Serializable)value, type);
-        }
+ org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.writeObject(type,
value, out);
     }

     /**
@@ -382,40 +332,6 @@
      * @return
      */
     protected Object readValue(InputStream in, Class type) {
-        Object value = null;
-        if (type == null) {
-            value = in.read_value();
-        } else if (type == Object.class || type == Serializable.class ||
type == Externalizable.class) {
-            value = Util.readAny(in);
-        } else if (type == Integer.TYPE) {
-            value = Integer.valueOf(in.read_long());
-        } else if (type == Short.TYPE) {
-            value = new Short(in.read_short());
-        } else if (type == Boolean.TYPE) {
-            value = Boolean.valueOf(in.read_boolean());
-        } else if (type == Byte.TYPE) {
-            value = new Byte(in.read_octet());
-        } else if (type == Long.TYPE) {
-            value = new Long(in.read_longlong());
-        } else if (type == Float.TYPE) {
-            value = new Float(in.read_float());
-        } else if (type == Double.TYPE) {
-            value = new Double(in.read_double());
-        } else if (type == Character.TYPE) {
-            value = new Character(in.read_wchar());
-        } else if (type.isArray()) {
-            // []
-            value = in.read_value(type);
-        } else if (Java2IDLUtil.isRemoteInterface(type)) {
-            // java.rmi.Remote
-            value = in.read_Object(type);
-        } else if (Java2IDLUtil.isAbstractInterface(type)) {
-            // Non-remote Interface
-            value = in.read_abstract_interface(type);
-        } else {
-            // java.io.Serializable
-            value = in.read_value(type);
-        }
-        return value;
+        return
org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.readObject(type,
in);
     }
}

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=562291&r1=562290&r2=562291

==============================================================================
---
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
Thu Aug  2 16:37:30 2007
@@ -20,6 +20,7 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.UnexpectedException;

@@ -184,7 +185,8 @@
             try {
                 org.omg.CORBA.portable.OutputStream out =
ejbHomeObject._request("create", true);
                 in = (org.omg.CORBA_2_3.portable.InputStream
)ejbHomeObject._invoke(out);
-                return (Object)in.read_Object(Object.class);
+                // The Remote stub should be available in JDK
+                return in.read_Object(Remote.class);
             } catch (ApplicationException ex) {
                 in = (org.omg.CORBA_2_3.portable.InputStream
)ex.getInputStream();
                 String id = in.read_string();

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java
Thu Aug  2 16:37:30 2007
@@ -28,8 +28,7 @@
import java.util.Map;
import java.util.WeakHashMap;

-import org.apache.tuscany.sca.binding.ejb.java2idl.Java2IDL;
-import org.apache.tuscany.sca.binding.ejb.java2idl.OperationType;
+import org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil;

// import commonj.sdo.DataObject;

@@ -59,16 +58,15 @@
          */
         Map idlNames = AccessController.doPrivileged(new
PrivilegedAction<Map>() {
             public Map run() {
-                return Java2IDL.getIDLMapping(iface);
+                return Java2IDLUtil.mapMethodToOperation(iface);
             }
         });
         Iterator i = idlNames.entrySet().iterator();
         while (i.hasNext()) {
             Map.Entry entry = (Map.Entry)i.next();
             Method method = (Method)entry.getKey();
-            OperationType operationType =
(OperationType)entry.getValue();
             MethodInfo methodInfo = new MethodInfo(method);
-            methodInfo.setIDLName(operationType.getIDLName());
+            methodInfo.setIDLName((String) entry.getValue());
             methods.put(method.getName(), methodInfo);
         }
     }

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java
Thu Aug  2 16:37:30 2007
@@ -36,6 +36,8 @@
     private String[] exceptionTypes;

     private String IDLName;
+
+    private transient Method method;

     /**
* Type Signature Java Type -------------- --------- Z boolean B byte
C char
@@ -172,5 +174,12 @@
      */
     public void setIDLName(String name) {
         IDLName = name;
+    }
+
+    /**
+     * @return the method
+     */
+    public Method getMethod() {
+        return method;
     }
}

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java
Thu Aug  2 16:37:30 2007
@@ -60,7 +60,7 @@
                 throw new IllegalArgumentException("Invalid corbaname: "
+ name);
             }

-            this.jndiName = parts[1]; // The logical jndi name
+            this.jndiName = name; // The logical jndi name
             this.locator = new EJBLocator(parts[0], managed);

         } else {

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java
Thu Aug  2 16:37:30 2007
@@ -22,17 +22,19 @@
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;

+import calculator.AddService;
+
@Service(Customer.class)
public class CustomerImpl implements Customer {

-    private BankManagerFacade extEJBService = null;
+    private AddService extEJBService = null;

-    public BankManagerFacade getExtEJBService() {
+    public AddService getExtEJBService() {
         return extEJBService;
     }

     @Reference
-    public void setExtEJBService(BankManagerFacade extEJBService) {
+    public void setExtEJBService(AddService extEJBService) {
         this.extEJBService = extEJBService;
     }

@@ -44,7 +46,7 @@
         System.out.println("In component implementation. Invoking
external EJB through EJB reference binding  ");

         try {
-            Double balance = extEJBService.getAccountBalance(accountNo);
//invoke external ejb through ejb reference binding
+            Double balance = extEJBService.add(amount.doubleValue(),
1000); //invoke external ejb through ejb reference binding
             total =  balance + amount;
         } catch (Exception e) {
             throw new ServiceRuntimeException(e);

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
Thu Aug  2 16:37:30 2007
@@ -18,6 +18,11 @@
  */
package org.apache.tuscany.sca.binding.ejb.tests;

+import java.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import junit.framework.TestCase;

import org.apache.tuscany.sca.host.embedded.SCADomain;
@@ -28,17 +33,33 @@
  * Invokes the component which calls the reference using the EJB binding
  */
public class EJBReferenceTestCase extends TestCase {
-
+    private static final int MOCK_PORT = 8085;
+    private static final int OPENEJB_PORT = 4201;
     private SCADomain scaDomain;

     protected void setUp() throws Exception {
+        System.setProperty("java.naming.factory.initial", "
org.apache.openejb.client.RemoteInitialContextFactory");
+        System.setProperty("java.naming.provider.url",
"ejbd://localhost:" + MOCK_PORT);
         System.setProperty("managed", "false");
-        System.setProperty("java.naming.factory.initial", "
org.openejb.client.RemoteInitialContextFactory");
- System.setProperty("java.naming.provider.url", "localhost:4321");
+
         scaDomain = SCADomain.newInstance("account/account.composite");
-
-//        new Thread(new SocketTracer(4321, 4201)).start();
-        new Thread(new MockServer(4321)).start();
+
+        // To capture the network traffice for the MockServer, uncomment
the next line
+ // new Thread(new SocketTracer(MOCK_PORT, OPENEJB_PORT)).start();
+
+        // Start the mock server to simulate the remote EJB
+        new Thread(new MockServer(MOCK_PORT)).start();
+    }
+
+    private InitialContext getRemoteInitialContext() throws
NamingException {
+        Properties properties = new Properties();
+
+        properties.setProperty("java.naming.factory.initial", "
org.apache.openejb.client.RemoteInitialContextFactory");
+        properties.setProperty("java.naming.provider.url",
"ejbd://localhost:" + OPENEJB_PORT);
+
+        InitialContext context = new InitialContext(properties);
+        // System.out.println(context.lookup
("hello-addservice/AddServiceBean/calculator.AddService"));
+        return context;
     }

     protected void tearDown() throws Exception {
@@ -48,9 +69,9 @@
     public void testCalculator() throws Exception {
         Customer customer = scaDomain.getService(Customer.class,
"CustomerComponent");
         // This is one of the customer numbers in bank application
running on Geronimo
-        String accountNo = "1234567890";
+        String accountNo = "1234567890";
         Double balance = customer.depositAmount(accountNo, new
Double(100));
-        System.out.println("Balance amount for account " + accountNo + "
is $" + balance);
-        assertEquals(1105.35, balance);
+ // System.out.println("Balance amount for account " + accountNo +
" is $" + balance);
+        assertEquals(1200.0, balance);
     }
}

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java
Thu Aug  2 16:37:30 2007
@@ -28,48 +28,122 @@
public class MockServer implements Runnable {

     private int listen;
+    byte seq[][] =
+        {
+         {79, 69, 74, 80, 47, 51, 46, 48, 1, -84, -19, 0, 5, 119, 58, 1,
27, 0, 54, 47, 104, 101, 108, 108, 111, 45,
+          97, 100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100,
100, 83, 101, 114, 118, 105, 99, 101, 66, 101,
+          97, 110, 47, 99, 97, 108, 99, 117, 108, 97, 116, 111, 114, 46,
65, 100, 100, 83, 101, 114, 118, 105, 99, 101,
+          112},
+
+         {79, 69, 74, 80, 47, 50, 46, 48, -84, -19, 0, 5, 119, 3, 1, 13,
1, 118, 114, 0, 25, 99, 97, 108, 99, 117, 108,
+          97, 116, 111, 114, 46, 65, 100, 100, 83, 101, 114, 118, 105,
99, 101, 72, 111, 109, 101, 0, 0, 0, 0, 0, 0, 0,
+          0, 0, 0, 0, 120, 112, 118, 114, 0, 21, 99, 97, 108, 99, 117,
108, 97, 116, 111, 114, 46, 65, 100, 100, 83,
+          101, 114, 118, 105, 99, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
120, 112, 112, 112, 119, 38, 7, 0, 31, 104,
+          101, 108, 108, 111, 45, 97, 100, 100, 115, 101, 114, 118, 105,
99, 101, 47, 65, 100, 100, 83, 101, 114, 118,
+          105, 99, 101, 66, 101, 97, 110, -1, -1, 0, 0},
+
+         {79, 69, 74, 80, 47, 51, 46, 48, 0, -84, -19, 0, 5, 119, 1, 10,
116, 0, 31, 104, 101, 108, 108, 111, 45, 97,
+          100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100,
83, 101, 114, 118, 105, 99, 101, 66, 101, 97,
+          110, 119, 2, -1, -1, 112, 119, 1, 1, 112, 118, 114, 0, 25, 99,
97, 108, 99, 117, 108, 97, 116, 111, 114, 46,
+          65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 72, 111, 109,
101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 112,
+          119, 9, 0, 6, 99, 114, 101, 97, 116, 101, 0},
+         {79, 69, 74, 80, 47, 50, 46, 48, -84, -19, 0, 5, 119, 2, 1, 4,
112},
+
+         {79, 69, 74, 80, 47, 51, 46, 48, 0, -84, -19, 0, 5, 119, 1, 23,
116, 0, 31, 104, 101, 108, 108, 111, 45, 97,
+          100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100,
83, 101, 114, 118, 105, 99, 101, 66, 101, 97,
+          110, 119, 2, -1, -1, 112, 119, 1, 1, 112, 118, 114, 0, 21, 99,
97, 108, 99, 117, 108, 97, 116, 111, 114, 46,
+          65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 120, 112, 119, 24, 0, 3, 97,
+          100, 100, 2, 4, 64, 89, 0, 0, 0, 0, 0, 0, 4, 64, -113, 64, 0,
0, 0, 0, 0},
+         {79, 69, 74, 80, 47, 50, 46, 48, -84, -19, 0, 5, 119, 2, 1, 4,
115, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97,
+          110, 103, 46, 68, 111, 117, 98, 108, 101, -128, -77, -62, 74,
41, 107, -5, 4, 2, 0, 1, 68, 0, 5, 118, 97,
+          108, 117, 101, 120, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97,
110, 103, 46, 78, 117, 109, 98, 101, 114,
+          -122, -84, -107, 29, 11, -108, -32, -117, 2, 0, 0, 120, 112,
64, -111, 48, 0, 0, 0, 0, 0}

-    private int[] r1 = new int[] {79, 69, 74, 80, 47, 50, 46, 48, 172,
237, 0, 5, 119, 1, 1, 116, 0, 5, 71, 85, 69, 83, 84};
-    private int[] r2 = new int[] {79, 69, 74, 80, 47, 50, 46, 48, 172,
237, 0, 5, 119, 1, 13, 118, 114, 0, 58, 111, 114, 103, 46, 97, 112, 97, 99, 104, 101, 46, 103, 101, 114, 111, 110, 105, 109, 111, 46, 115, 97, 109, 112, 108, 101, 115, 46, 98, 97, 110, 107, 46, 101, 106, 98, 46, 66, 97, 110, 107, 77, 97, 110, 97, 103, 101, 114, 70, 97, 99, 97, 100, 101, 72, 111, 109, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 112, 118, 114, 0, 54, 111, 114, 103, 46, 97, 112, 97, 99, 104, 101, 46, 103, 101, 114, 111, 110, 105, 109, 111,
46, 115, 97, 109, 112, 108, 101, 115, 46, 98, 97, 110, 107, 46, 101, 106,
98, 46, 66, 97, 110, 107, 77, 97, 110, 97, 103, 101, 114, 70, 97, 99, 97,
100, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 112, 112, 112, 119, 185, 1,
0, 180, 111, 114, 103, 46, 97, 112, 97, 99, 104, 101, 46, 103, 101, 114,
111, 110, 105, 109, 111, 46, 115, 97, 109, 112, 108, 101, 115, 47, 66, 97, 110, 107, 47, 49, 46, 49, 46, 49, 47, 99, 97, 114, 63, 69, 74, 66, 77, 111,
100, 117, 108
, 101, 61, 66, 97, 110, 107, 69, 74, 66, 46, 106, 97, 114, 44, 74, 50, 69, 69, 65, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 61, 111, 114, 103, 46, 97, 112, 97, 99, 104, 101, 46, 103, 101, 114, 111, 110, 105, 109, 111, 46, 115, 97, 109, 112, 108, 101, 115, 47, 66, 97, 110, 107, 47, 49, 46, 49, 46, 49, 47, 99, 97, 114, 44, 106, 50, 101, 101, 84, 121, 112, 101, 61, 83, 116, 97, 116, 101, 108, 101, 115, 115, 83, 101, 115, 115, 105, 111, 110, 66, 101, 97, 110, 44, 110, 97, 109, 101, 61, 66, 97, 110, 107, 77, 97, 110, 97,
103, 101, 114, 70, 97, 99, 97, 100, 101, 66, 101, 97, 110, 0, 1};
-    private int[] r3 = new int[] {79, 69, 74, 80, 47, 50, 46, 48, 172,
237, 0, 5, 119, 1, 4, 112};
-    private int[] r4 = new int[] {79, 69, 74, 80, 47, 50, 46, 48, 172,
237, 0, 5, 119, 1, 4, 115, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 68, 111, 117, 98, 108, 101, 128, 179, 194, 74, 41, 107, 251, 4, 2, 0, 1, 68, 0, 5, 118, 97, 108, 117, 101, 120, 114, 0, 16, 106, 97, 118, 97,
46, 108, 97, 110, 103, 46, 78, 117, 109, 98, 101, 114, 134, 172, 149, 29,
11, 148, 224, 139, 2, 0, 0, 120, 112, 64, 143, 106, 204, 204, 204, 204,
205};
+        };

     public MockServer(int listen) {
         this.listen = listen;
     }
-
+
     public void run() {
         try {
             ServerSocket ss = new ServerSocket(listen);
-
-            doExchange(ss.accept(), 15, r1);
-            doExchange(ss.accept(), 80, r2);
-            doExchange(ss.accept(), 109, r3);
-            doExchange(ss.accept(), 163, r4);
+            for (int i = 0; i < seq.length; i += 2) {
+ // System.out.println("Processing request[" + i/2 + "]");
+                doExchange(ss.accept(), seq[i], seq[i + 1]);
+            }

         } catch (Exception e) {
             e.printStackTrace();
         }
     }

-    private void doExchange(Socket sin, int readCount, int[] write)
throws IOException, InterruptedException {
-        InputStream is = sin.getInputStream();
-        OutputStream os = sin.getOutputStream();
-        readBytes(is, readCount);
-        writeBytes(os, write);
-        sin.close();
+    private void doExchange(Socket socket, byte[] read, byte[] write)
throws IOException, InterruptedException {
+        Thread t2 = readBytes(socket, read.length);
+        Thread t1 = writeBytes(socket, write);
+        t1.join();
+        t2.join();
+        socket.close();
+    }
+
+    private Thread readBytes(Socket socket, int x) throws IOException,
InterruptedException {
+        byte[] buf = new byte[x];
+        Thread t = new Reader(socket, buf);
+        t.start();
+        return t;
     }

-    private void readBytes(InputStream is, int x) throws IOException,
InterruptedException {
-        for (int i = 0; i < x; i++) {
-            is.read();
+    private Thread writeBytes(Socket socket, byte[] bs) throws
IOException, InterruptedException {
+        Thread t = new Writer(socket, bs);
+        t.start();
+        return t;
+    }
+
+    private static class Reader extends Thread {
+
+        private InputStream is;
+        private byte[] buf;
+
+        Reader(Socket socket, byte[] buf) throws IOException {
+            this.is = socket.getInputStream();
+            this.buf = buf;
         }
+
+        public void run() {
+            try {
+                int totalSize = buf.length;
+                int readSize = 0;
+                int offset = 0;
+                while (totalSize > 0 && (readSize = is.read(buf, offset,
totalSize)) != -1) {
+                    offset += readSize;
+                    totalSize -= readSize;
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
     }

-    private void writeBytes(OutputStream os, int[] bs) throws
IOException, InterruptedException {
-        for (int i = 0; i < bs.length; i++) {
-            os.write(bs[i]);
+    private static class Writer extends Thread {
+
+        private OutputStream os;
+        private byte[] buf;
+
+        Writer(Socket socket, byte[] buf) throws IOException {
+            this.os = socket.getOutputStream();
+            this.buf = buf;
+        }
+
+        public void run() {
+            try {
+                os.write(buf);
+                os.flush();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
         }
+
     }

}

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java
Thu Aug  2 16:37:30 2007
@@ -45,23 +45,39 @@
                 Socket sin = ss.accept();

                 Socket sout = new Socket("localhost", send);
-
+
                 Thread st = new Thread(new Send(sin, sout));
                 st.start();
             }
-
+
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
-
+
+    /**
+     * @param buf
+     * @param count
+     */
+    static synchronized void dump(String str, byte[] buf, int count) {
+        // System.out.println(Thread.currentThread());
+        System.out.print(str+"{");
+        for (int j = 0; j < count; j++) {
+            if (j == count - 1) {
+                System.out.println(buf[j] + "}, ");
+            } else {
+                System.out.print(buf[j] + ", ");
+            }
+        }
+    }
}

+
class Send implements Runnable {

     Socket sin;
     Socket sout;
-
+
     Send(Socket sin, Socket sout) {
         this.sin = sin;
         this.sout = sout;
@@ -75,17 +91,21 @@
             rt.start();

             OutputStream outout = sout.getOutputStream();
-
             InputStream is = sin.getInputStream();
+            byte[] buf = new byte[4096];
             int i = 0;
+            int count = 0;
             while ((i = is.read()) != -1) {
-                System.out.println("out: " + i);
+                buf[count++] = (byte)i;
                 outout.write(i);
             }
+            SocketTracer.dump("Req: ", buf, count);
+
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
+
}

class Reply implements Runnable {
@@ -100,11 +120,14 @@

     public void run() {
         try {
+            byte[] buf = new byte[4096];
             int i = 0;
+            int count = 0;
             while ((i = is.read()) != -1) {
-                System.out.println("reply: " + i);
+                buf[count++] = (byte)i;
                 outout.write(i);
             }
+            SocketTracer.dump("Res: ", buf, count);
         } catch (Exception e) {
             e.printStackTrace();
         }

Modified:
incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite
(original)
+++
incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite
Thu Aug  2 16:37:30 2007
@@ -1,31 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- * 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.
+    * 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.
-->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0";
-           name="account">
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"; name="account">

-       <!-- composite refrence with ejb binding. Modify host and port
number in uri attribute based on where you have installed target ResumeBank
EJB -->
+ <!-- composite refrence with ejb binding. Modify host and port number in uri attribute based on where you have installed target ResumeBank EJB -->

     <component name="CustomerComponent">
-               <implementation.java class="account.CustomerImpl"/>
-        <reference name="extEJBService">
-           <binding.ejb uri="corbaname:iiop:[EMAIL PROTECTED]
:4201#org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean"/>
+        <implementation.java class="account.CustomerImpl" />
+        <reference name="extEJBService">
+            <!-- To use the CosNaming, use the following URI -->
+            <!--
+ <binding.ejb uri="corbaname:iiop:[EMAIL PROTECTED]:1050#AddServiceBean"
/>
+            -->
+ <binding.ejburi="hello-addservice/AddServiceBean/calculator.AddService" />
         </reference>
     </component>


Modified:
incubator/tuscany/java/sca/modules/implementation-java-runtime/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/pom.xml?view=diff&rev=562291&r1=562290&r2=562291

==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/pom.xml
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/pom.xml
Thu Aug  2 16:37:30 2007
@@ -66,7 +66,7 @@
         </dependency>
         <dependency>
             <groupId>cglib</groupId>
-            <artifactId>cglib</artifactId>
+            <artifactId>cglib-nodep</artifactId>
             <version>2.1_3</version>
         </dependency>
     </dependencies>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to