hlship      2003/08/30 07:13:17

  Modified:    hivemind/src/java/org/apache/commons/hivemind/service/impl
                        AbstractEJBProxy.java EJBProxyParameters.java
                        EJBProxyFactory.java
               hivemind .classpath project.xml
               hivemind/src/test/hivemind/test/services EJBProxy.xml
                        TestServices.java
               hivemind/src/META-INF hivemodule.xml
  Log:
  Update to newest Javassist JAR (using provisional name).
  Fix EJBProxyFactory.
  Add parameter to EJBProxyFactory service for identifying a non-default NameLookup 
service.
  
  Revision  Changes    Path
  1.2       +2 -10     
jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/AbstractEJBProxy.java
  
  Index: AbstractEJBProxy.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/AbstractEJBProxy.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractEJBProxy.java     20 Aug 2003 20:40:46 -0000      1.1
  +++ AbstractEJBProxy.java     30 Aug 2003 14:13:17 -0000      1.2
  @@ -57,16 +57,8 @@
   
   package org.apache.commons.hivemind.service.impl;
   
  -import java.lang.reflect.InvocationHandler;
  -import java.lang.reflect.InvocationTargetException;
  -import java.lang.reflect.Method;
   import java.rmi.RemoteException;
   
  -import javax.ejb.EJBHome;
  -
  -import org.apache.commons.hivemind.ApplicationRuntimeException;
  -import org.apache.commons.hivemind.HiveMind;
  -import org.apache.commons.hivemind.Registry;
   import org.apache.commons.hivemind.service.NameLookup;
   import org.apache.commons.hivemind.service.RemoteExceptionCoordinator;
   import org.apache.commons.hivemind.service.RemoteExceptionEvent;
  @@ -79,7 +71,7 @@
    * @author Howard Lewis Ship
    * @version $Id$
    */
  -public abstract class AbstractEJBProxy implements InvocationHandler
  +public abstract class AbstractEJBProxy
   {
       private NameLookup _nameLookup;
       private RemoteExceptionCoordinator _coordinator;
  
  
  
  1.3       +24 -4     
jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/EJBProxyParameters.java
  
  Index: EJBProxyParameters.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/EJBProxyParameters.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EJBProxyParameters.java   20 Aug 2003 20:40:46 -0000      1.2
  +++ EJBProxyParameters.java   30 Aug 2003 14:13:17 -0000      1.3
  @@ -57,6 +57,7 @@
   
   package org.apache.commons.hivemind.service.impl;
   
  +import org.apache.commons.hivemind.service.NameLookup;
   
   /**
    * Parameters for the [EMAIL PROTECTED] 
org.apache.commons.hivemind.service.impl.EJBProxyFactory}.
  @@ -66,9 +67,10 @@
    */
   public class EJBProxyParameters
   {
  -     private String _jndiName;
  -     private String _homeInterfaceClassName;
  -     
  +    private String _jndiName;
  +    private String _homeInterfaceClassName;
  +    private NameLookup _nameLookup;
  +
       public String getJndiName()
       {
           return _jndiName;
  @@ -87,6 +89,24 @@
       public void setHomeInterfaceClassName(String string)
       {
           _homeInterfaceClassName = string;
  +    }
  +
  +    public NameLookup getNameLookup()
  +    {
  +        return _nameLookup;
  +    }
  +
  +    public void setNameLookup(NameLookup lookup)
  +    {
  +        _nameLookup = lookup;
  +    }
  +
  +    public NameLookup getNameLookup(NameLookup defaultValue)
  +    {
  +        if (_nameLookup == null)
  +            return defaultValue;
  +
  +        return _nameLookup;
       }
   
   }
  
  
  
  1.10      +6 -4      
jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/EJBProxyFactory.java
  
  Index: EJBProxyFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/EJBProxyFactory.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- EJBProxyFactory.java      23 Aug 2003 22:46:04 -0000      1.9
  +++ EJBProxyFactory.java      30 Aug 2003 14:13:17 -0000      1.10
  @@ -120,6 +120,8 @@
           ClassFab classFab =
               _classFactory.newClass(proxyClassName, AbstractEJBProxy.class, 
invokingModule);
   
  +        classFab.addInterface(serviceInterface);
  +
           classFab.addField("_remote", serviceInterface);
   
           addClearCachedMethod(classFab);
  @@ -132,7 +134,7 @@
   
           Class proxyClass = classFab.createClass();
   
  -        return invokeConstructor(proxyClass);
  +        return invokeConstructor(proxyClass, 
proxyParameters.getNameLookup(_nameLookup));
       }
   
       private void addClearCachedMethod(ClassFab classFab)
  @@ -292,7 +294,7 @@
               "super($1, $2);");
       }
   
  -    private Object invokeConstructor(Class proxyClass)
  +    private Object invokeConstructor(Class proxyClass, NameLookup nameLookup)
       {
           try
           {
  @@ -300,7 +302,7 @@
                   proxyClass.getConstructor(
                       new Class[] { NameLookup.class, 
RemoteExceptionCoordinator.class });
   
  -            return c.newInstance(new Object[] { _nameLookup, _coordinator });
  +            return c.newInstance(new Object[] { nameLookup, _coordinator });
           }
           catch (Exception ex)
           {
  
  
  
  1.14      +1 -1      jakarta-commons-sandbox/hivemind/.classpath
  
  Index: .classpath
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/.classpath,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- .classpath        20 Aug 2003 20:40:46 -0000      1.13
  +++ .classpath        30 Aug 2003 14:13:17 -0000      1.14
  @@ -18,6 +18,6 @@
       <classpathentry kind="var" path="MAVEN_REPO/ant/jars/ant-1.5.1.jar"/>
       <classpathentry kind="var" path="MAVEN_REPO/jboss/jars/jboss-j2ee-3.2.1.jar"/>
       <classpathentry kind="var" path="MAVEN_REPO/oro/jars/oro-2.0.6.jar"/>
  -    <classpathentry kind="var" path="MAVEN_REPO/jboss/jars/javassist-2.5.1.jar"/>
  +    <classpathentry kind="var" path="MAVEN_REPO/jboss/jars/javassist-2.5.2.jar"/>
       <classpathentry kind="output" path="bin"/>
   </classpath>
  
  
  
  1.16      +2 -2      jakarta-commons-sandbox/hivemind/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/project.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- project.xml       8 Aug 2003 13:51:09 -0000       1.15
  +++ project.xml       30 Aug 2003 14:13:17 -0000      1.16
  @@ -110,7 +110,7 @@
       <dependency>
        <groupId>jboss</groupId>
        <artifactId>javassist</artifactId>      
  -     <version>2.5.1</version>
  +     <version>2.5.2</version>
       </dependency>
   
       <dependency>
  
  
  
  1.6       +21 -5     
jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/EJBProxy.xml
  
  Index: EJBProxy.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/EJBProxy.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EJBProxy.xml      20 Aug 2003 20:40:45 -0000      1.5
  +++ EJBProxy.xml      30 Aug 2003 14:13:17 -0000      1.6
  @@ -9,12 +9,28 @@
     
       <invoke-factory service-id="hivemind.EJBProxyFactory">
        <parameters jndi-name="hivemind.test.services.Simple"
  -             home-interface="hivemind.test.services.SimpleHome"/>
  +             home-interface="hivemind.test.services.SimpleHome"
  +             name-lookup-service-id="NameLookup"
  +             />
       </invoke-factory>                        
     </service>
     
  -  <extend-service service-id="hivemind.NameLookup">
  -     <create-instance class="hivemind.test.services.impl.NameLookupHack"/>   
  -  </extend-service>
  +     <service id="NameLookup"
  +                     interface="org.apache.commons.hivemind.service.NameLookup"
  +                     model="singleton">
  +             <description>
  +                     A service which can perform name lookups of objects using JNDI.
  +             </description>  
  +             
  +             <invoke-factory service-id="hivemind.BuilderFactory">
  +               <construct
  +                 class="hivemind.test.services.impl.NameLookupHack">
  +                 <set property="initialFactory" value="fred"/>
  +                 <set property="URLPackages" value="barney"/>
  +                 <set property="providerURL" value="wilma"/>
  +                 <set-service property="coordinator" 
service-id="hivemind.RemoteExceptionCoordinator"/>
  +                </construct>
  +             </invoke-factory>
   
  +  </service>
   </module>
  
  
  
  1.24      +88 -73    
jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java
  
  Index: TestServices.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- TestServices.java 23 Aug 2003 22:46:03 -0000      1.23
  +++ TestServices.java 30 Aug 2003 14:13:17 -0000      1.24
  @@ -59,10 +59,16 @@
   
   import hivemind.test.HiveMindTestCase;
   import hivemind.test.services.impl.CountFactory;
  +import hivemind.test.services.impl.FakeContext;
   import hivemind.test.services.impl.NameLookupHack;
  +import hivemind.test.services.impl.SimpleHomeImpl;
   import hivemind.test.services.impl.TrackerFactory;
   
  +import java.rmi.RemoteException;
   import java.util.List;
  +import java.util.Map;
  +
  +import javax.naming.Context;
   
   import org.apache.commons.hivemind.ApplicationRuntimeException;
   import org.apache.commons.hivemind.Registry;
  @@ -253,78 +259,87 @@
   
       }
   
  -    //    public void testEJBProxy() throws Exception
  -    //    {
  -    //        Registry r = buildRegistry("EJBProxy.xml");
  -    //
  -    //        SimpleHomeImpl home = new SimpleHomeImpl();
  -    //        FakeContext context = new FakeContext();
  -    //        context.bind("hivemind.test.services.Simple", home);
  -    //        NameLookupHack._context = context;
  -    //
  -    //        SimpleRemote object =
  -    //            (SimpleRemote) 
r.getService("hivemind.test.services.SimpleRemote", SimpleRemote.class);
  -    //
  -    //        assertEquals(7, object.add(4, 3));
  -    //        // Exercise several code paths where objects are ready or cached.
  -    //        assertEquals(201, object.add(1, 200));
  -    //    }
  -    //
  -    //    public void testEJBProxyNameFailure() throws Exception
  -    //    {
  -    //        Registry r = buildRegistry("EJBProxy.xml");
  -    //
  -    //        FakeContext context = new FakeContext();
  -    //        context.setForceError(true);
  -    //
  -    //        NameLookupHack._context = context;
  -    //
  -    //        SimpleRemote object =
  -    //            (SimpleRemote) 
r.getService("hivemind.test.services.SimpleRemote", SimpleRemote.class);
  -    //
  -    //        try
  -    //        {
  -    //
  -    //            object.add(4, 3);
  -    //            unreachable();
  -    //        }
  -    //        catch (ApplicationRuntimeException ex)
  -    //        {
  -    //            checkException(ex, "Unable to lookup 
'hivemind.test.services.Simple' in JNDI context");
  -    //
  -    //            Throwable t = findNestedException(ex);
  -    //
  -    //            checkException(t, "Forced error: hivemind.test.services.Simple");
  -    //        }
  -    //    }
  -    //
  -    //    public void testEJBProxyRemoteFailure() throws Exception
  -    //    {
  -    //        Registry r = buildRegistry("EJBProxy.xml");
  -    //
  -    //        SimpleHomeImpl home = new SimpleHomeImpl();
  -    //        home.setForceError(true);
  -    //
  -    //        FakeContext context = new FakeContext();
  -    //        context.bind("hivemind.test.services.Simple", home);
  -    //        NameLookupHack._context = context;
  -    //
  -    //        NameLookupHack._context = context;
  -    //
  -    //        SimpleRemote object =
  -    //            (SimpleRemote) 
r.getService("hivemind.test.services.SimpleRemote", SimpleRemote.class);
  -    //
  -    //        try
  -    //        {
  -    //
  -    //            object.add(4, 3);
  -    //            unreachable();
  -    //        }
  -    //        catch (RemoteException ex)
  -    //        {
  -    //            checkException(ex, "Forced error.");
  -    //        }
  -    //    }
  +    public void testEJBProxy() throws Exception
  +    {
  +        Registry r = buildRegistry("EJBProxy.xml");
  +
  +        SimpleHomeImpl home = new SimpleHomeImpl();
  +        FakeContext context = new FakeContext();
  +        context.bind("hivemind.test.services.Simple", home);
  +        NameLookupHack._context = context;
  +
  +        SimpleRemote object =
  +            (SimpleRemote) r.getService("hivemind.test.services.SimpleRemote", 
SimpleRemote.class);
  +
  +        assertEquals(7, object.add(4, 3));
  +        // Exercise several code paths where objects are ready or cached.
  +        assertEquals(201, object.add(1, 200));
  +
  +             // Tacked on here, a few tests that the NameLookup service builds
  +             // the initial context properties correctly.
  +             
  +        Map p = NameLookupHack._properties;
  +
  +        assertEquals("fred", p.get(Context.INITIAL_CONTEXT_FACTORY));
  +        assertEquals("barney", p.get(Context.URL_PKG_PREFIXES));
  +             assertEquals("wilma", p.get(Context.PROVIDER_URL));
  +    }
  +
  +    public void testEJBProxyNameFailure() throws Exception
  +    {
  +        Registry r = buildRegistry("EJBProxy.xml");
  +
  +        FakeContext context = new FakeContext();
  +        context.setForceError(true);
  +
  +        NameLookupHack._context = context;
  +
  +        SimpleRemote object =
  +            (SimpleRemote) r.getService("hivemind.test.services.SimpleRemote", 
SimpleRemote.class);
  +
  +        try
  +        {
  +
  +            object.add(4, 3);
  +            unreachable();
  +        }
  +        catch (ApplicationRuntimeException ex)
  +        {
  +            checkException(ex, "Unable to lookup 'hivemind.test.services.Simple' in 
JNDI context");
  +
  +            Throwable t = findNestedException(ex);
  +
  +            checkException(t, "Forced error: hivemind.test.services.Simple");
  +        }
  +    }
  +
  +    public void testEJBProxyRemoteFailure() throws Exception
  +    {
  +        Registry r = buildRegistry("EJBProxy.xml");
  +
  +        SimpleHomeImpl home = new SimpleHomeImpl();
  +        home.setForceError(true);
  +
  +        FakeContext context = new FakeContext();
  +        context.bind("hivemind.test.services.Simple", home);
  +        NameLookupHack._context = context;
  +
  +        NameLookupHack._context = context;
  +
  +        SimpleRemote object =
  +            (SimpleRemote) r.getService("hivemind.test.services.SimpleRemote", 
SimpleRemote.class);
  +
  +        try
  +        {
  +
  +            object.add(4, 3);
  +            unreachable();
  +        }
  +        catch (RemoteException ex)
  +        {
  +            checkException(ex, "Forced error.");
  +        }
  +    }
   
       public void testServiceTranslator() throws Exception
       {
  
  
  
  1.20      +9 -1      jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- hivemodule.xml    23 Aug 2003 22:46:04 -0000      1.19
  +++ hivemodule.xml    30 Aug 2003 14:13:17 -0000      1.20
  @@ -335,10 +335,18 @@
                                        </description>  
                                </attribute>
                                
  +                             <attribute name="name-lookup-service-id">
  +                               <description>
  +                               Defines an alternate name lookup service to use when 
  +                               resolving JNDI names to EJB home interfaces.
  +                               </description>        
  +                             </attribute>
  +                             
                                <rules>
                                        <create-object 
class="org.apache.commons.hivemind.service.impl.EJBProxyParameters"/>
                                        <read-attribute property="jndiName" 
attribute="jndi-name"/>
                                        <read-attribute 
property="homeInterfaceClassName" attribute="home-interface"/>
  +                                     <read-attribute property="nameLookup" 
attribute="name-lookup-service-id" translator="service"/>
                                        <invoke-parent method="addElement"/>
                                </rules>
                        </element>      
  
  
  

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

Reply via email to