hlship      2004/08/31 13:02:14

  Modified:    framework/src/java/org/apache/hivemind/service/impl
                        LoggingUtils.java ClassFactoryImpl.java
                        CtClassSource.java ClassFactoryClassLoader.java
               .        .classpath status.xml
               framework/src/test/hivemind/test TestContains.java
               library/src/java/org/apache/hivemind/lib/impl
                        ServicePropertyFactory.java
               library/src/test/org/apache/hivemind/lib/impl
                        TestServicePropertyFactory.java
  Added:       framework/src/java/org/apache/hivemind/service/impl
                        HiveMindClassPool.java
               framework/src/test/org/apache/hivemind/service/impl
                        TestClassFab.java
               library/src/test/org/apache/hivemind/lib/impl wonk.xml
                        ServicePropertyFactoryMaster.xml
  Removed:     framework/src/test/hivemind/test/services TestClassFab.java
  Log:
  HIVEMIND-48: Fix class loader issues surrounding fabricated classes that are 
used in multiple modules.
  
  Revision  Changes    Path
  1.2       +10 -10    
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/LoggingUtils.java
  
  Index: LoggingUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/LoggingUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LoggingUtils.java 15 Aug 2004 15:41:57 -0000      1.1
  +++ LoggingUtils.java 31 Aug 2004 20:02:13 -0000      1.2
  @@ -1,16 +1,16 @@
  -//Copyright 2004 The Apache Software Foundation
  +//  Copyright 2004 The Apache Software Foundation
   //
  -//Licensed 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
  +// Licensed 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
  +//     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.
  +// 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.hivemind.service.impl;
   
  
  
  
  1.6       +6 -1      
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFactoryImpl.java
  
  Index: ClassFactoryImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFactoryImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ClassFactoryImpl.java     29 Jul 2004 13:18:52 -0000      1.5
  +++ ClassFactoryImpl.java     31 Aug 2004 20:02:13 -0000      1.6
  @@ -36,6 +36,11 @@
        */
       private Map _ctClassSourceMap = new HashMap();
   
  +    /**
  +     * ClassPool shared by all modules (all CtClassSource instances).
  +     */
  +    private HiveMindClassPool _pool = new HiveMindClassPool();
  +
       public ClassFab newClass(String name, Class superClass, Module module)
       {
           CtClassSource source = findCtClassSource(module);
  @@ -63,7 +68,7 @@
   
           if (result == null)
           {
  -            result = new 
CtClassSource(module.getClassResolver().getClassLoader());
  +            result = new CtClassSource(_pool, 
module.getClassResolver().getClassLoader());
   
               _ctClassSourceMap.put(id, result);
           }
  
  
  
  1.2       +11 -9     
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/CtClassSource.java
  
  Index: CtClassSource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/CtClassSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CtClassSource.java        6 Jun 2004 00:29:25 -0000       1.1
  +++ CtClassSource.java        31 Aug 2004 20:02:13 -0000      1.2
  @@ -15,7 +15,6 @@
   package org.apache.hivemind.service.impl;
   
   import javassist.ClassPath;
  -import javassist.ClassPool;
   import javassist.CtClass;
   import javassist.LoaderClassPath;
   import javassist.NotFoundException;
  @@ -33,18 +32,15 @@
    */
   public class CtClassSource
   {
  -    private ClassPool _pool;
  -    private ClassFactoryClassLoader _loader;
  +    private HiveMindClassPool _pool;
   
  -    public CtClassSource(ClassLoader parentLoader)
  +    public CtClassSource(HiveMindClassPool pool, ClassLoader parentLoader)
       {
  -        _pool = new ClassPool(null);
  +        _pool = pool;
   
           ClassPath path = new LoaderClassPath(parentLoader);
   
           _pool.appendClassPath(path);
  -
  -        _loader = new ClassFactoryClassLoader(parentLoader);
       }
   
       public CtClass getCtClass(Class searchClass)
  @@ -67,7 +63,9 @@
       {
           CtClass ctSuperClass = getCtClass(superClass);
   
  -        return _pool.makeClass(name, ctSuperClass);
  +        CtClass result = _pool.makeClass(name, ctSuperClass);
  +
  +        return result;
       }
   
       public Class createClass(CtClass ctClass)
  @@ -80,7 +78,11 @@
   
               byte[] bytecode = _pool.write(className);
   
  -            return _loader.loadClass(className, bytecode);
  +            Class result = _pool.loadClass(className, bytecode);
  +
  +            // _cache.add(className, bytecode);
  +
  +            return result;
           }
           catch (Throwable ex)
           {
  
  
  
  1.3       +1 -5      
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFactoryClassLoader.java
  
  Index: ClassFactoryClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFactoryClassLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClassFactoryClassLoader.java      6 Jun 2004 00:29:25 -0000       1.2
  +++ ClassFactoryClassLoader.java      31 Aug 2004 20:02:13 -0000      1.3
  @@ -18,14 +18,10 @@
    * ClassLoader used to properly instantiate newly created classes.
    *
    * @author Howard Lewis Ship / Essl Christian
  + * @see org.apache.hivemind.service.impl.CtClassSource
    */
   class ClassFactoryClassLoader extends ClassLoader
   {
  -    public ClassFactoryClassLoader(ClassLoader parent)
  -    {
  -        super(parent);
  -    }
  -
       public Class loadClass(String name, byte[] bytecodes)
       {
           Class result = defineClass(name, bytecodes, 0, bytecodes.length);
  
  
  
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/HiveMindClassPool.java
  
  Index: HiveMindClassPool.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed 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.hivemind.service.impl;
  
  import javassist.ClassPath;
  import javassist.ClassPool;
  
  /**
   * Used to ensure that [EMAIL PROTECTED] 
javassist.ClassPool#appendClassPath(javassist.ClassPath)} is
   * invoked with a synchronized lock. Additionally, wraps around a shared
   * [EMAIL PROTECTED] 
org.apache.hivemind.service.impl.ClassFactoryClassLoader}.
   *
   * @author Howard Lewis Ship
   */
  public class HiveMindClassPool extends ClassPool
  {
      private ClassFactoryClassLoader _loader = new ClassFactoryClassLoader();
  
      public HiveMindClassPool()
      {
          super(null);
      }
  
      /**
       * Synchronizes this operation.  [EMAIL PROTECTED] 
ClassPool#get(java.lang.String)} is already
       * synchronized. 
       *
       */
      public synchronized ClassPath appendClassPath(ClassPath cp)
      {
          return super.appendClassPath(cp);
      }
  
      public Class loadClass(String name, byte[] bytecodes)
      {
          return _loader.loadClass(name, bytecodes);
      }
  }
  
  
  
  1.37      +1 -1      jakarta-hivemind/.classpath
  
  Index: .classpath
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/.classpath,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- .classpath        3 Aug 2004 14:02:18 -0000       1.36
  +++ .classpath        31 Aug 2004 20:02:13 -0000      1.37
  @@ -17,7 +17,7 @@
       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
       <classpathentry kind="lib" 
path="ext-package/lib/commons-logging-1.0.3.jar"/>
       <classpathentry kind="lib" path="ext-package/lib/easymock-1.1.jar"/>
  -    <classpathentry kind="lib" path="ext-package/lib/javassist-2.6.jar"/>
  +    <classpathentry kind="lib" path="ext-package/lib/javassist-2.6.jar" 
sourcepath="C:/Documents and 
Settings/Howard/Desktop/Downloads/Misc/javassist-2.6.zip"/>
       <classpathentry kind="lib" path="ext-package/lib/log4j-1.2.7.jar"/>
       <classpathentry kind="lib" path="ext-package/lib/oro-2.0.6.jar"/>
       <classpathentry kind="lib" path="ext-package/lib/servletapi-2.3.jar"/>
  
  
  
  1.55      +3 -0      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- status.xml        25 Aug 2004 22:42:24 -0000      1.54
  +++ status.xml        31 Aug 2004 20:02:13 -0000      1.55
  @@ -34,6 +34,9 @@
         <action type="add" dev="HLS">
           Add method <code>getSymbolValue()</code> to RegistryInfrastructure 
and Module
         </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-48">
  +        Fix class loader issues concerning fabricated classes in different 
modules.
  +      </action>
         
       </release>
     
  
  
  
  1.1                  
jakarta-hivemind/framework/src/test/org/apache/hivemind/service/impl/TestClassFab.java
  
  Index: TestClassFab.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed 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.hivemind.service.impl;
  
  import hivemind.test.services.AbstractIntWrapper;
  import hivemind.test.services.FailService;
  import hivemind.test.services.SimpleService;
  
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Modifier;
  import java.util.List;
  
  import javassist.CtClass;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.service.ClassFab;
  import org.apache.hivemind.service.MethodFab;
  import org.apache.hivemind.service.MethodSignature;
  import org.apache.hivemind.test.HiveMindTestCase;
  import org.apache.hivemind.util.PropertyUtils;
  
  /**
   * Tests related to [EMAIL PROTECTED] 
org.apache.hivemind.service.impl.ClassFabImpl},
   * [EMAIL PROTECTED] org.apache.hivemind.service.impl.CtClassSource}, etc.
   *
   * @author Howard Lewis Ship
   */
  public class TestClassFab extends HiveMindTestCase
  {
      private CtClassSource _source =
          new CtClassSource(new HiveMindClassPool(), 
Thread.currentThread().getContextClassLoader());
  
      private ClassFab newClassFab(String className, Class superClass)
      {
          CtClass ctClass = _source.newClass(className, superClass);
  
          return new ClassFabImpl(_source, ctClass);
      }
  
      public void testCreateBean() throws Exception
      {
          ClassFab cf = newClassFab("TargetBean", Object.class);
  
          cf.addField("_stringValue", String.class);
  
          MethodSignature setStringValue =
              new MethodSignature(void.class, "setStringValue", new Class[] { 
String.class }, null);
  
          cf.addMethod(Modifier.PUBLIC, setStringValue, "_stringValue = $1;");
  
          MethodSignature getStringValue =
              new MethodSignature(String.class, "getStringValue", null, null);
  
          cf.addMethod(Modifier.PUBLIC, getStringValue, "return _stringValue;");
  
          Class targetClass = cf.createClass();
  
          Object targetBean = targetClass.newInstance();
  
          PropertyUtils.write(targetBean, "stringValue", "Fred");
  
          String actual = (String) PropertyUtils.read(targetBean, 
"stringValue");
  
          assertEquals("Fred", actual);
      }
  
      public void testConstructor() throws Exception
      {
          ClassFab cf = newClassFab("ConstructableBean", Object.class);
  
          cf.addField("_stringValue", String.class);
          cf.addConstructor(new Class[] { String.class }, null, "{ _stringValue 
= $1; }");
  
          MethodSignature getStringValue =
              new MethodSignature(String.class, "getStringValue", null, null);
  
          cf.addMethod(Modifier.PUBLIC, getStringValue, "return _stringValue;");
  
          Class targetClass = cf.createClass();
  
          try
          {
              targetClass.newInstance();
              unreachable();
          }
          catch (InstantiationException ex)
          {
          }
  
          Constructor c = targetClass.getConstructors()[0];
  
          Object targetBean = c.newInstance(new Object[] { "Buffy" });
  
          String actual = (String) PropertyUtils.read(targetBean, 
"stringValue");
  
          assertEquals("Buffy", actual);
      }
  
      public void testConstructorFromBaseClass() throws Exception
      {
          ClassFab cf = newClassFab("MyIntHolder", AbstractIntWrapper.class);
  
          cf.addField("_intValue", int.class);
          cf.addConstructor(new Class[] { int.class }, null, "{ _intValue = $1; 
}");
  
          cf.addMethod(
              Modifier.PUBLIC,
              new MethodSignature(int.class, "getIntValue", null, null),
              "return _intValue;");
  
          Class targetClass = cf.createClass();
          Constructor c = targetClass.getConstructors()[0];
  
          AbstractIntWrapper targetBean =
              (AbstractIntWrapper) c.newInstance(new Object[] { new 
Integer(137)});
  
          assertEquals(137, targetBean.getIntValue());
      }
  
      public void testInvalidSuperClass() throws Exception
      {
          ClassFab cf = newClassFab("InvalidSuperClass", List.class);
  
          try
          {
              cf.createClass();
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, "Unable to create class 
InvalidSuperClass");
          }
      }
  
      public void testAddInterface() throws Exception
      {
          ClassFab cf = newClassFab("SimpleService", Object.class);
  
          cf.addInterface(SimpleService.class);
  
          cf.addMethod(
              Modifier.PUBLIC,
              new MethodSignature(int.class, "add", new Class[] { int.class, 
int.class }, null),
              "return $1 + $2;");
  
          Class targetClass = cf.createClass();
  
          SimpleService s = (SimpleService) targetClass.newInstance();
  
          assertEquals(207, s.add(99, 108));
      }
  
      public void testSubclassFromFinal() throws Exception
      {
          ClassFab cf = newClassFab("StringSubclass", String.class);
  
          try
          {
              cf.createClass();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertEquals(
                  "Unable to create class StringSubclass: Cannot inherit from 
final class",
                  ex.getMessage());
          }
      }
  
      public void testInPackage() throws Exception
      {
          ClassFab cf = newClassFab("org.apache.hivemind.InPackage", 
Object.class);
  
          Class c = cf.createClass();
  
          Object o = c.newInstance();
  
          assertEquals("org.apache.hivemind.InPackage", o.getClass().getName());
      }
  
      public void testBadMethodBody() throws Exception
      {
          ClassFab cf = newClassFab("BadMethodBody", Object.class);
  
          cf.addInterface(Runnable.class);
  
          try
          {
              cf.addMethod(
                  Modifier.PUBLIC,
                  new MethodSignature(void.class, "run", null, null),
                  "fail;");
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, "Unable to add method void run() to 
class BadMethodBody:");
          }
      }
  
      public void testGetMethodFab() throws Exception
      {
          ClassFab cf = newClassFab("GetMethodFab", Object.class);
  
          MethodSignature s = new MethodSignature(void.class, "run", null, 
null);
          MethodFab mf = cf.addMethod(Modifier.PUBLIC, s, null);
  
          assertSame(mf, cf.getMethodFab(s));
  
          assertNull(cf.getMethodFab(new MethodSignature(void.class, "skip", 
null, null)));
      }
  
      public void testExtendMethod() throws Exception
      {
          ClassFab cf = newClassFab("ExtendMethod", Object.class);
  
          MethodFab mf =
              cf.addMethod(
                  Modifier.PUBLIC,
                  new MethodSignature(int.class, "getValue", null, null),
                  "return 1;");
  
          mf.extend("return 2 * $_;", false);
  
          Object bean = cf.createClass().newInstance();
  
          assertEquals(new Integer(2), PropertyUtils.read(bean, "value"));
      }
  
      public void testExtendMethodAlterReturn() throws Exception
      {
          ClassFab cf = newClassFab("ExtendMethodAlterReturn", Object.class);
  
          MethodFab mf =
              cf.addMethod(
                  Modifier.PUBLIC,
                  new MethodSignature(int.class, "getValue", null, null),
                  "return 2;");
  
          mf.extend("$_ = 3 * $_;", false);
  
          Object bean = cf.createClass().newInstance();
  
          assertEquals(new Integer(6), PropertyUtils.read(bean, "value"));
      }
  
      public void testExtendMethodFailure() throws Exception
      {
          ClassFab cf = newClassFab("ExtendMethodFailure", Object.class);
  
          MethodFab mf =
              cf.addMethod(
                  Modifier.PUBLIC,
                  new MethodSignature(int.class, "getValue", null, null),
                  "return 1;");
  
          try
          {
              mf.extend("$_ =", true);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(
                  ex,
                  "Unable to extend method int getValue() of class 
ExtendMethodFailure:");
          }
      }
  
      public void testDupeMethodAdd() throws Exception
      {
          ClassFab cf = newClassFab("DupeMethodAdd", Object.class);
  
          cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "foo", 
null, null), "{}");
  
          try
          {
              cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, 
"foo", null, null), "{}");
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertEquals(
                  "Attempt to redefine method void foo() of class 
DupeMethodAdd.",
                  ex.getMessage());
          }
      }
  
      public void testBadConstructor() throws Exception
      {
          ClassFab cf = newClassFab("BadConstructor", Object.class);
  
          try
          {
              cf.addConstructor(null, null, " woops!");
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, "Unable to add constructor to class 
BadConstructor");
          }
  
      }
  
      public void testCatchException() throws Exception
      {
          ClassFab cf = newClassFab("Fail", Object.class);
  
          cf.addInterface(FailService.class);
  
          MethodFab mf =
              cf.addMethod(
                  Modifier.PUBLIC,
                  new MethodSignature(void.class, "fail", null, null),
                  "throw new java.lang.RuntimeException(\"Ouch!\");");
  
          mf.addCatch(RuntimeException.class, "throw new 
java.io.IOException($e.getMessage());");
  
          Class targetClass = cf.createClass();
  
          FailService fs = (FailService) targetClass.newInstance();
  
          try
          {
              fs.fail();
              unreachable();
          }
          catch (IOException ex)
          {
              assertEquals("Ouch!", ex.getMessage());
          }
      }
  
      public void testBadCatch() throws Exception
      {
          ClassFab cf = newClassFab("BadCatch", Object.class);
  
          cf.addInterface(Runnable.class);
  
          MethodFab mf =
              cf.addMethod(
                  Modifier.PUBLIC,
                  new MethodSignature(void.class, "run", null, null),
                  "return;");
  
          try
          {
              mf.addCatch(RuntimeException.class, "woops!");
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(
                  ex,
                  "Unable to add catch block for exception 
java.lang.RuntimeException to class BadCatch");
          }
      }
  
      public void testInvalidField() throws Exception
      {
          ClassFab cf = newClassFab("InvalidField", Object.class);
  
          cf.addField(".", String.class);
          cf.addField("buffy", int.class);
          cf.addField("", int.class);
  
          try
          {
              cf.createClass();
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, "Unable to create class 
InvalidField");
          }
  
          // Javassist lets us down here; I can't think of a way to get 
addField() to actually
          // fail.
      }
  }
  
  
  
  1.3       +1 -1      
jakarta-hivemind/framework/src/test/hivemind/test/TestContains.java
  
  Index: TestContains.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/TestContains.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestContains.java 19 Aug 2004 22:24:00 -0000      1.2
  +++ TestContains.java 31 Aug 2004 20:02:14 -0000      1.3
  @@ -1,4 +1,4 @@
  -//Copyright 2004 The Apache Software Foundation
  +//  Copyright 2004 The Apache Software Foundation
   //
   // Licensed under the Apache License, Version 2.0 (the "License");
   // you may not use this file except in compliance with the License.
  
  
  
  1.4       +1 -1      
jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactory.java
  
  Index: ServicePropertyFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServicePropertyFactory.java       18 Aug 2004 23:20:11 -0000      1.3
  +++ ServicePropertyFactory.java       31 Aug 2004 20:02:14 -0000      1.4
  @@ -92,7 +92,7 @@
           {
               return ConstructorUtils.invokeConstructor(proxyClass, new 
Object[] { targetService });
           }
  -        catch (ApplicationRuntimeException ex)
  +        catch (Throwable ex)
           {
               throw new ApplicationRuntimeException(ex.getMessage(), 
p.getLocation(), ex);
           }
  
  
  
  1.3       +28 -0     
jakarta-hivemind/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
  
  Index: TestServicePropertyFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestServicePropertyFactory.java   18 Aug 2004 19:34:12 -0000      1.2
  +++ TestServicePropertyFactory.java   31 Aug 2004 20:02:14 -0000      1.3
  @@ -181,4 +181,32 @@
   
           verifyControls();
       }
  +    
  +    /**
  +     * HIVEMIND-48: ServicePropertyFactory fails when the holding service
  +     * and the property are in different modules.  Class loader issue 
involving
  +     * Javasssist.
  +     */
  +     public void testIntegratedTwoModules() throws Exception
  +     {
  +             Registry r = 
buildFrameworkRegistry("ServicePropertyFactoryMaster.xml");
  +
  +             WonkSource source = (WonkSource) r.getService(WonkSource.class);
  +             Wonk wonkService = (Wonk) r.getService(Wonk.class);
  +
  +             Wonk wonk = (Wonk) newMock(Wonk.class);
  +        
  +             source.setWonk(wonk);
  +
  +             wonk.wonkVoid();
  +
  +             replayControls();
  +
  +             // Invoking this (on the proxy) will cause the corresponding
  +             // method (on the mock) to be invoked.
  +             
  +             wonkService.wonkVoid();
  +
  +             verifyControls();
  +     }    
   }
  
  
  
  1.1                  
jakarta-hivemind/library/src/test/org/apache/hivemind/lib/impl/wonk.xml
  
  Index: wonk.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2004 The Apache Software Foundation
  
     Licensed 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.
  -->
    
  <module id="wonk" version="1.0.0">
    
    <service-point id="WonkSource" 
interface="org.apache.hivemind.lib.impl.WonkSource">
      <create-instance class="org.apache.hivemind.lib.impl.WonkHolder"/>
    </service-point>
    
  </module>
  
  
  1.1                  
jakarta-hivemind/library/src/test/org/apache/hivemind/lib/impl/ServicePropertyFactoryMaster.xml
  
  Index: ServicePropertyFactoryMaster.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2004 The Apache Software Foundation
  
     Licensed 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.
  -->
  
  <module id="hivemind.lib.test" version="1.0.0">
    
    <sub-module descriptor="wonk.xml"/>
    
    <service-point id="Wonk" interface="org.apache.hivemind.lib.impl.Wonk">
      <invoke-factory service-id="hivemind.lib.ServicePropertyFactory">
        <construct service-id="wonk.WonkSource" property="wonk"/>
      </invoke-factory>
    </service-point>
    
  </module>
  
  

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

Reply via email to