You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by jc...@apache.org on 2005/05/04 05:09:04 UTC

cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl ClassFabImpl.java

jcarman     2005/05/03 20:09:04

  Modified:    framework/src/test/org/apache/hivemind/impl/servicemodel
                        TestRegistryShutdownListenerServices.java
                        ShutdownListenerServices.xml
               framework/src/java/org/apache/hivemind/impl
                        ProxyBuilder.java ProxyUtils.java
               .        status.xml version.properties
               framework/src/java/org/apache/hivemind/service ClassFab.java
               framework/src/java/org/apache/hivemind/impl/servicemodel
                        SingletonServiceModel.java
               framework/src/java/org/apache/hivemind/service/impl
                        ClassFabImpl.java
  Added:       framework/src/test/org/apache/hivemind/impl/servicemodel
                        RegistryShutdownBean.java
  Log:
  Bean services cannot implement RegistryShutdownListener.
  PR: HIVEMIND-115
  
  Revision  Changes    Path
  1.3       +26 -1     jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/TestRegistryShutdownListenerServices.java
  
  Index: TestRegistryShutdownListenerServices.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/TestRegistryShutdownListenerServices.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestRegistryShutdownListenerServices.java	3 Apr 2005 13:10:12 -0000	1.2
  +++ TestRegistryShutdownListenerServices.java	4 May 2005 03:09:03 -0000	1.3
  @@ -34,7 +34,7 @@
           assertEquals(1, counter.getValue());
       }
   
  -    public void testPooled() throws Exception
  +    public void testPooledCalled() throws Exception
       {
           executeShutdownListenerTest("pooledManual");
           executeShutdownListenerTest("pooledAuto");
  @@ -51,5 +51,30 @@
           executeShutdownListenerTest("primitiveManual");
           executeShutdownListenerTest("primitiveAuto");        
       }
  +    
  +    public void testSingletonBeanRegistryShutdownListener() throws Exception
  +    {
  +        Registry registry = buildFrameworkRegistry("ShutdownListenerServices.xml");
  +        RegistryShutdownBean bean = ( RegistryShutdownBean )registry.getService( "hivemind.lib.test.registryShutdownBeanSingleton", RegistryShutdownBean.class );
  +        bean.someMethod();
  +    }
   
  +    public void testThreadedBeanRegistryShutdownListener() throws Exception
  +    {
  +        Registry registry = buildFrameworkRegistry("ShutdownListenerServices.xml");
  +        RegistryShutdownBean bean = ( RegistryShutdownBean )registry.getService( "hivemind.lib.test.registryShutdownBeanThreaded", RegistryShutdownBean.class );
  +        bean.someMethod();
  +    }
  +    public void testPooledBeanRegistryShutdownListener() throws Exception
  +    {
  +        Registry registry = buildFrameworkRegistry("ShutdownListenerServices.xml");
  +        RegistryShutdownBean bean = ( RegistryShutdownBean )registry.getService( "hivemind.lib.test.registryShutdownBeanPooled", RegistryShutdownBean.class );
  +        bean.someMethod();
  +    }
  +    public void testPrimitiveBeanRegistryShutdownListener() throws Exception
  +    {
  +        Registry registry = buildFrameworkRegistry("ShutdownListenerServices.xml");
  +        RegistryShutdownBean bean = ( RegistryShutdownBean )registry.getService( "hivemind.lib.test.registryShutdownBeanPrimitive", RegistryShutdownBean.class );
  +        bean.someMethod();
  +    }
   }
  
  
  
  1.3       +20 -0     jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/ShutdownListenerServices.xml
  
  Index: ShutdownListenerServices.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/ShutdownListenerServices.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ShutdownListenerServices.xml	3 Apr 2005 13:10:12 -0000	1.2
  +++ ShutdownListenerServices.xml	4 May 2005 03:09:03 -0000	1.3
  @@ -47,4 +47,24 @@
         <construct class="org.apache.hivemind.impl.servicemodel.SimpleImpl" autowire-services="false"/>
       </invoke-factory>
     </service-point>
  +  <service-point id="registryShutdownBeanSingleton" interface="org.apache.hivemind.impl.servicemodel.RegistryShutdownBean">
  +    <invoke-factory>
  +      <construct class="org.apache.hivemind.impl.servicemodel.RegistryShutdownBean" />
  +    </invoke-factory>
  +  </service-point>
  +  <service-point id="registryShutdownBeanPooled" interface="org.apache.hivemind.impl.servicemodel.RegistryShutdownBean">
  +    <invoke-factory model="pooled">
  +      <construct class="org.apache.hivemind.impl.servicemodel.RegistryShutdownBean" />
  +    </invoke-factory>
  +  </service-point>
  +  <service-point id="registryShutdownBeanPrimitive" interface="org.apache.hivemind.impl.servicemodel.RegistryShutdownBean">
  +    <invoke-factory model="primitive">
  +      <construct class="org.apache.hivemind.impl.servicemodel.RegistryShutdownBean" />
  +    </invoke-factory>
  +  </service-point>
  +  <service-point id="registryShutdownBeanThreaded" interface="org.apache.hivemind.impl.servicemodel.RegistryShutdownBean">
  +    <invoke-factory model="threaded">
  +      <construct class="org.apache.hivemind.impl.servicemodel.RegistryShutdownBean" />
  +    </invoke-factory>
  +  </service-point>
   </module>
  \ No newline at end of file
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/RegistryShutdownBean.java
  
  Index: RegistryShutdownBean.java
  ===================================================================
  // Copyright 2004, 2005 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.impl.servicemodel;
  
  import org.apache.hivemind.events.RegistryShutdownListener;
  
  /**
   * @author James Carman
   * @version 1.0
   */
  public class RegistryShutdownBean implements RegistryShutdownListener
  {
      public void registryDidShutdown()
      {
      }
      
      public void someMethod()
      {
          
      }
  }
  
  
  
  1.13      +12 -12    jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ProxyBuilder.java
  
  Index: ProxyBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ProxyBuilder.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ProxyBuilder.java	17 Feb 2005 19:46:44 -0000	1.12
  +++ ProxyBuilder.java	4 May 2005 03:09:03 -0000	1.13
  @@ -123,21 +123,21 @@
           BodyBuilder builder = new BodyBuilder();
   
           MethodIterator mi = new MethodIterator(_serviceInterface);
  -
           while (mi.hasNext())
           {
               MethodSignature m = mi.next();
  -
  -            builder.clear();
  -            builder.begin();
  -            builder.add("return ($r) ");
  -            builder.add(indirection);
  -            builder.add(".");
  -            builder.add(m.getName());
  -            builder.addln("($$);");
  -            builder.end();
  -
  -            _classFab.addMethod(Modifier.PUBLIC, m, builder.toString());
  +            if( !_classFab.containsMethod( m ) )
  +            {
  +                builder.clear();
  +                builder.begin();
  +                builder.add("return ($r) ");
  +                builder.add(indirection);
  +                builder.add(".");
  +                builder.add(m.getName());
  +                builder.addln("($$);");
  +                builder.end();
  +                _classFab.addMethod(Modifier.PUBLIC, m, builder.toString());
  +            }
           }
   
           if (!mi.getToString())
  
  
  
  1.11      +10 -4     jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ProxyUtils.java
  
  Index: ProxyUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ProxyUtils.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ProxyUtils.java	29 Apr 2005 07:40:54 -0000	1.10
  +++ ProxyUtils.java	4 May 2005 03:09:03 -0000	1.11
  @@ -136,10 +136,16 @@
           { delegateClass }, null, "{ super(); _delegate = $1; }");
   
           classFab.addInterface(RegistryShutdownListener.class);
  -
  -        classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
  -                "registryDidShutdown", null, null), "{ _delegate = null; _shutdown = true; }");
  -
  +        if( RegistryShutdownListener.class.isAssignableFrom( delegateClass ) )
  +        {
  +        	classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
  +                    "registryDidShutdown", null, null), "{ _delegate.registryDidShutdown(); _delegate = null; _shutdown = true; }");
  +        }
  +        else
  +        {
  +            classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
  +                    "registryDidShutdown", null, null), "{ _delegate = null; _shutdown = true; }");
  +        }
           BodyBuilder builder = new BodyBuilder();
   
           builder.begin();
  
  
  
  1.129     +4 -2      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.128
  retrieving revision 1.129
  diff -u -r1.128 -r1.129
  --- status.xml	29 Apr 2005 01:56:16 -0000	1.128
  +++ status.xml	4 May 2005 03:09:03 -0000	1.129
  @@ -30,9 +30,11 @@
       </actions>
     </todo>
     <changes>
  -    <release version="1.1-beta-1" date="unreleased">
  -    
  +    <release version="1.1-beta-2" date="unreleased">
         <action type="add" dev="JC" fixes-bug="HIVEMIND-112" >Add getServiceIds() Method to Registry Interface.</action>
  +      <action type="fix" dev="JC" fixes-bug="HIVEMIND-115" >Bean services cannot implement RegistryShutdownListener.</action>
  +    </release>
  +    <release version="1.1-beta-1" date="Apr 29 2005">
         <action type="fix" dev="JC" fixes-bug="HIVEMIND-108" >Bean services could not be autowired into other services.</action>
         <action type="fix" dev="JC" fixes-bug="HIVEMIND-102" >Multiple interceptors with different names for the same interceptor factory id were treated as duplicates.</action>
         <action type="fix" dev="JC" fixes-bug="HIVEMIND-103" >Core service implementations which implement RegistryShutdownListener are not notified for primitive and singleton service models.</action>
  
  
  
  1.14      +1 -1      jakarta-hivemind/version.properties
  
  Index: version.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/version.properties,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- version.properties	28 Apr 2005 23:49:29 -0000	1.13
  +++ version.properties	4 May 2005 03:09:03 -0000	1.14
  @@ -12,4 +12,4 @@
   # See the License for the specific language governing permissions and
   # limitations under the License.
   
  -project.version=1.1-beta-1
  \ No newline at end of file
  +project.version=1.1-beta-2
  \ No newline at end of file
  
  
  
  1.5       +8 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/service/ClassFab.java
  
  Index: ClassFab.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/ClassFab.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ClassFab.java	6 Jan 2005 01:45:14 -0000	1.4
  +++ ClassFab.java	4 May 2005 03:09:04 -0000	1.5
  @@ -58,6 +58,14 @@
       public void addField(String name, Class type);
   
       /**
  +     * Convenience method for checking whether the fabricated class already contains
  +     * a method.
  +     * @param signature the signature
  +     * @return whether or not the fabricated class already contains the method
  +     */
  +    public boolean containsMethod( MethodSignature signature );
  +    
  +    /**
        * Adds a method.  The method is a public instance method.
        * @return a method fabricator, used to add catch handlers.
        * @param modifiers Modifiers for the method (see {@link java.lang.reflect.Modifier}).
  
  
  
  1.15      +5 -4      jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/servicemodel/SingletonServiceModel.java
  
  Index: SingletonServiceModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/servicemodel/SingletonServiceModel.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SingletonServiceModel.java	29 Apr 2005 07:40:54 -0000	1.14
  +++ SingletonServiceModel.java	4 May 2005 03:09:04 -0000	1.15
  @@ -153,12 +153,13 @@
   
           classFab.addField("_inner", serviceInterface);
           classFab.addField("_shutdown", boolean.class);
  +        if( !RegistryShutdownListener.class.isAssignableFrom( serviceInterface ) )
  +        {
  +            classFab.addInterface(RegistryShutdownListener.class);
   
  -        classFab.addInterface(RegistryShutdownListener.class);
  -
  -        classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
  +            classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
                   "registryDidShutdown", null, null), "{ _shutdown = true; }");
  -
  +        }
           classFab.addMethod(
                   Modifier.PUBLIC | Modifier.SYNCHRONIZED | Modifier.FINAL,
                   new MethodSignature(void.class, "_setInner", new Class[]
  
  
  
  1.10      +5 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFabImpl.java
  
  Index: ClassFabImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFabImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ClassFabImpl.java	17 Feb 2005 19:46:44 -0000	1.9
  +++ ClassFabImpl.java	4 May 2005 03:09:04 -0000	1.10
  @@ -265,6 +265,11 @@
           }
       }
   
  +    public boolean containsMethod( MethodSignature ms )
  +    {
  +        return _methods.get( ms ) != null;
  +    }
  +    
       public MethodFab addMethod(int modifiers, MethodSignature ms, String body)
       {
           if (_methods.get(ms) != null)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org