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/03/28 03:08:49 UTC

cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/servicemodel PrimitiveServiceModel.java SingletonServiceModel.java

jcarman     2005/03/27 17:08:49

  Modified:    framework/src/java/org/apache/hivemind/impl/servicemodel
                        PrimitiveServiceModel.java
                        SingletonServiceModel.java
  Added:       framework/src/test/org/apache/hivemind/impl/servicemodel
                        TestSingletonServiceModel.java
                        SingletonShutdownListenerService.xml
                        TestPrimitiveServiceModel.java
                        PrimitiveShutdownListenerService.xml
                        BooleanHolder.java Simple.java SimpleImpl.java
  Log:
  Core service implementations which implement RegistryShutdownListener are not notified for primitive and singleton service models
  PR: HIVEMIND-103
  
  Revision  Changes    Path
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/TestSingletonServiceModel.java
  
  Index: TestSingletonServiceModel.java
  ===================================================================
  package org.apache.hivemind.impl.servicemodel;
  
  import org.apache.hivemind.Registry;
  import org.apache.hivemind.test.HiveMindTestCase;
  
  /**
   * @author James Carman
   * @version 1.0
   */
  public class TestSingletonServiceModel extends HiveMindTestCase
  {
      public void testRegistryShutdownCalled() throws Exception
      {
         Registry registry = buildFrameworkRegistry( "SingletonShutdownListenerService.xml" );
         Simple simple = ( Simple )registry.getService( Simple.class );
         BooleanHolder holder = new BooleanHolder();
         holder.setValue( false );
         simple.setHolder( holder );
         registry.shutdown();
         assertTrue( holder.getValue() );
      }
  }
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/SingletonShutdownListenerService.xml
  
  Index: SingletonShutdownListenerService.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     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.
  -->
  
  <module id="hivemind.lib.test" version="1.0.0">
    
    <service-point id="simple" interface="org.apache.hivemind.impl.servicemodel.Simple">
      <invoke-factory>
        <construct class="org.apache.hivemind.impl.servicemodel.SimpleImpl" />
      </invoke-factory>
    </service-point>
    
  </module>
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/TestPrimitiveServiceModel.java
  
  Index: TestPrimitiveServiceModel.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.Registry;
  import org.apache.hivemind.test.HiveMindTestCase;
  
  /**
   * @author James Carman
   * @version 1.0
   */
  public class TestPrimitiveServiceModel extends HiveMindTestCase
  {
      public void testRegistryShutdownCalled() throws Exception
      {
         Registry registry = buildFrameworkRegistry( "PrimitiveShutdownListenerService.xml" );
         Simple simple = ( Simple )registry.getService( Simple.class );
         BooleanHolder holder = new BooleanHolder();
         holder.setValue( false );
         simple.setHolder( holder );
         registry.shutdown();
         assertTrue( holder.getValue() );
      }
  }
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/PrimitiveShutdownListenerService.xml
  
  Index: PrimitiveShutdownListenerService.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     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.
  -->
  
  <module id="hivemind.lib.test" version="1.0.0">
    
    <service-point id="simple" interface="org.apache.hivemind.impl.servicemodel.Simple">
      <invoke-factory model="primitive">
        <construct class="org.apache.hivemind.impl.servicemodel.SimpleImpl" />
      </invoke-factory>
    </service-point>
    
  </module>
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/BooleanHolder.java
  
  Index: BooleanHolder.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;
  
  /**
   * @author James Carman
   * @version 1.0
   */
  public class BooleanHolder
  {
      private boolean value;
      
      public boolean getValue()
      {
          return value;
      }
      
      public void setValue(boolean value)
      {
          this.value = value;
      }
  }
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/Simple.java
  
  Index: Simple.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;
  
  /**
   * @author James Carman
   * @version 1.0
   */
  public interface Simple
  {
      public void setHolder( BooleanHolder holder );
  }
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/servicemodel/SimpleImpl.java
  
  Index: SimpleImpl.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 SimpleImpl implements Simple, RegistryShutdownListener
  {
      private BooleanHolder holder;
      
      public void setHolder(BooleanHolder holder)
      {
          this.holder = holder;
  
      }
      
      public void registryDidShutdown()
      {
          holder.setValue( true );
      }
  }
  
  
  
  1.9       +8 -1      jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/servicemodel/PrimitiveServiceModel.java
  
  Index: PrimitiveServiceModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/servicemodel/PrimitiveServiceModel.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PrimitiveServiceModel.java	19 Feb 2005 02:40:54 -0000	1.8
  +++ PrimitiveServiceModel.java	28 Mar 2005 01:08:49 -0000	1.9
  @@ -14,6 +14,7 @@
   
   package org.apache.hivemind.impl.servicemodel;
   
  +import org.apache.hivemind.events.RegistryShutdownListener;
   import org.apache.hivemind.impl.ConstructableServicePoint;
   
   /**
  @@ -37,13 +38,19 @@
       public synchronized Object getService()
       {
           if (_constructedService == null)
  +        {
               _constructedService = constructServiceImplementation();
  +            if( _constructedService instanceof RegistryShutdownListener )
  +            {
  +                getServicePoint().getShutdownCoordinator().addRegistryShutdownListener( ( RegistryShutdownListener )_constructedService );
  +            }
  +        }
   
           // Note: if the service's declared interface is a class AND
           // the service has interceptors, then it will not be possible
           // to cast the result (since the returned interceptor will implement
           // the synthetic service interface).
  -
  +        
           return _constructedService;
       }
   
  
  
  
  1.11      +1 -1      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SingletonServiceModel.java	19 Feb 2005 02:40:54 -0000	1.10
  +++ SingletonServiceModel.java	28 Mar 2005 01:08:49 -0000	1.11
  @@ -153,7 +153,7 @@
           classFab.addInterface(RegistryShutdownListener.class);
   
           classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
  -                "registryDidShutdown", null, null), "{ _shutdown = true; }");
  +                "registryDidShutdown", null, null), "{ _shutdown = true; if( _inner instanceof org.apache.hivemind.events.RegistryShutdownListener ) { ( ( org.apache.hivemind.events.RegistryShutdownListener )_inner ).registryDidShutdown(); } }");
   
           classFab.addMethod(
                   Modifier.PUBLIC | Modifier.SYNCHRONIZED | Modifier.FINAL,
  
  
  

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