hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcar...@apache.org
Subject cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl BuilderFactoryLogic.java
Date Wed, 27 Apr 2005 02:08:26 GMT
jcarman     2005/04/26 19:08:26

  Modified:    framework/src/test/org/apache/hivemind TestBeanService.java
                        BeanService.xml
               framework/src/test/hivemind/test/services
                        TestBuilderFactory.java
               framework/src/java/org/apache/hivemind/service/impl
                        BuilderFactoryLogic.java
  Added:       framework/src/test/org/apache/hivemind BeanB.java BeanA.java
  Log:
  Bean services cannot be autowired into other services.
  PR: HIVEMIND-108
  
  Revision  Changes    Path
  1.2       +7 -0      jakarta-hivemind/framework/src/test/org/apache/hivemind/TestBeanService.java
  
  Index: TestBeanService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/TestBeanService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestBeanService.java	17 Feb 2005 19:46:44 -0000	1.1
  +++ TestBeanService.java	27 Apr 2005 02:08:26 -0000	1.2
  @@ -65,4 +65,11 @@
       {
           attempt("bean.PooledReverser");
       }    
  +    
  +    public void testAutowireBeanServiceProperty() throws Exception
  +    {
  +        Registry reg = buildFrameworkRegistry("BeanService.xml");
  +        BeanA beanA = ( BeanA )reg.getService( BeanA.class );
  +        beanA.methodA();
  +    }
   }
  \ No newline at end of file
  
  
  
  1.2       +11 -0     jakarta-hivemind/framework/src/test/org/apache/hivemind/BeanService.xml
  
  Index: BeanService.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/BeanService.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanService.xml	17 Feb 2005 19:46:44 -0000	1.1
  +++ BeanService.xml	27 Apr 2005 02:08:26 -0000	1.2
  @@ -37,5 +37,16 @@
     <service-point id="PooledReverser" interface="Reverser">
       <create-instance class="Reverser" model="pooled"/>
     </service-point>  
  +   
  +  <service-point id="BeanA" interface="BeanA">
  +    <invoke-factory>
  +      <construct class="BeanA"/>
  +    </invoke-factory>
  +  </service-point>
     
  +  <service-point id="BeanB" interface="BeanB">
  +    <invoke-factory>
  +      <construct class="BeanB"/>
  +    </invoke-factory>
  +  </service-point>
   </module>
  \ No newline at end of file
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/BeanB.java
  
  Index: BeanB.java
  ===================================================================
  // 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;
  
  /**
   * @author James Carman
   * @version 1.0
   */
  public class BeanB
  {
      public void methodB()
      {
      }
  }
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/BeanA.java
  
  Index: BeanA.java
  ===================================================================
  // 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;
  
  
  /**
   * @author James Carman
   * @version 1.0
   */
  public class BeanA
  {
      BeanB beanB; 
      
      public void methodA()
      {
          beanB.methodB();
      }
      
      public void setBeanB( BeanB beanB )
      {
          this.beanB = beanB;
      }
  }
  
  
  
  1.26      +10 -18    jakarta-hivemind/framework/src/test/hivemind/test/services/TestBuilderFactory.java
  
  Index: TestBuilderFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/services/TestBuilderFactory.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TestBuilderFactory.java	4 Apr 2005 15:20:38 -0000	1.25
  +++ TestBuilderFactory.java	27 Apr 2005 02:08:26 -0000	1.26
  @@ -24,7 +24,6 @@
   import org.apache.hivemind.Messages;
   import org.apache.hivemind.Registry;
   import org.apache.hivemind.ServiceImplementationFactoryParameters;
  -import org.apache.hivemind.impl.DefaultClassResolver;
   import org.apache.hivemind.internal.Module;
   import org.apache.hivemind.service.impl.BuilderClassResolverFacet;
   import org.apache.hivemind.service.impl.BuilderErrorHandlerFacet;
  @@ -35,10 +34,7 @@
   import org.apache.hivemind.service.impl.BuilderMessagesFacet;
   import org.apache.hivemind.service.impl.BuilderParameter;
   import org.apache.hivemind.service.impl.BuilderServiceIdFacet;
  -import org.apache.hivemind.test.AggregateArgumentsMatcher;
  -import org.apache.hivemind.test.ArgumentMatcher;
   import org.apache.hivemind.test.HiveMindTestCase;
  -import org.apache.hivemind.test.TypeMatcher;
   import org.easymock.MockControl;
   
   /**
  @@ -397,6 +393,10 @@
   
           StringHolder h = new StringHolderImpl();
   
  +        module.containsService( String.class );
  +        mc.setReturnValue( false );
  +        module.containsService( StringHolder.class );
  +        mc.setReturnValue( true );
           module.getService(StringHolder.class);
           mc.setReturnValue(h);
   
  @@ -443,20 +443,12 @@
           module.resolveType("hivemind.test.services.ServiceAutowireTarget");
           mc.setReturnValue(ServiceAutowireTarget.class);
   
  -        module.getService(StringHolder.class);
  -        mc.setThrowable(new ApplicationRuntimeException("Simulated failure."));
  -
  -        module.getErrorHandler();
  -        mc.setReturnValue(eh);
  -
  -        eh.error(
  -                log,
  -                "Unable to autowire property stringHolder of service foo.bar: Simulated
failure.",
  -                null,
  -                new ApplicationRuntimeException(""));
  -        ehc.setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher[]
  -        { null, null, null, new TypeMatcher() }));
  -
  +        module.containsService( String.class );
  +        mc.setReturnValue( false );
  +        module.containsService( StringHolder.class );
  +        mc.setReturnValue( false );
  +        
  +        
           replayControls();
   
           BuilderParameter parameter = new BuilderParameter();
  
  
  
  1.15      +14 -11    jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/BuilderFactoryLogic.java
  
  Index: BuilderFactoryLogic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/BuilderFactoryLogic.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- BuilderFactoryLogic.java	14 Mar 2005 22:28:48 -0000	1.14
  +++ BuilderFactoryLogic.java	27 Apr 2005 02:08:26 -0000	1.15
  @@ -392,26 +392,29 @@
           // properties for which there are no service points. This is why autowiring
           // can be turned off.
   
  -        if (!propertyType.isInterface())
  -            return;
  +        //if (!propertyType.isInterface())
  +        //    return;
   
           // Here's the problem with autowiring; there can be other stuff besides
           // services that are writable; since lots of classes inherite from
           // BaseLocatable, Location is one of those property types.
   
  -        if (propertyType.equals(Location.class))
  -            return;
  +        //if (propertyType.equals(Location.class))
  +        //    return;
   
           try
           {
  -            Object collaboratingService = _contributingModule.getService(propertyType);
  -
  -            PropertyUtils.write(service, propertyName, collaboratingService);
  -
  -            if (_log.isDebugEnabled())
  -                _log.debug("Autowired service property " + propertyName + " to "
  +            if( _contributingModule.containsService( propertyType ) )
  +            {
  +                Object collaboratingService = _contributingModule.getService(propertyType);
  +                PropertyUtils.write(service, propertyName, collaboratingService);
  +            
  +                if (_log.isDebugEnabled())
  +                {
  +                    _log.debug("Autowired service property " + propertyName + " to "
                           + collaboratingService);
  -
  +                }
  +            }
           }
           catch (Exception ex)
           {
  
  
  

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


Mime
View raw message