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/parse InterceptorDescriptor.java DescriptorParser.java DescriptorParser.properties
Date Mon, 28 Feb 2005 12:36:54 GMT
jcarman     2005/02/28 04:36:54

  Modified:    framework/src/test/hivemind/test/parse
                        TestDescriptorParser.java GenericModule.xml
               framework/src/test/org/apache/hivemind/impl
                        TestServicePoint.java
               framework/src/java/org/apache/hivemind/internal
                        ServiceInterceptorContribution.java
               framework/src/java/org/apache/hivemind/impl
                        ServicePointImpl.java
                        ServiceInterceptorContributionImpl.java
               framework/src/java/org/apache/hivemind/parse
                        InterceptorDescriptor.java DescriptorParser.java
                        DescriptorParser.properties
  Added:       framework/src/test/org/apache/hivemind/impl
                        TestServiceInterceptorContributionImpl.java
  Log:
  Allow interceptors to be ordered by name rather than interceptor factory id
  PR: HIVEMIND-96
  
  Revision  Changes    Path
  1.32      +4 -2      jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java
  
  Index: TestDescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- TestDescriptorParser.java	10 Feb 2005 01:04:33 -0000	1.31
  +++ TestDescriptorParser.java	28 Feb 2005 12:35:43 -0000	1.32
  @@ -190,10 +190,12 @@
           InterceptorDescriptor id = (InterceptorDescriptor) l.get(0);
           assertEquals("MyInterceptor", id.getFactoryServiceId());
           assertEquals("OtherInterceptor", id.getBefore());
  -
  +        assertEquals( "MyInterceptorName", id.getName() );
  +        
           id = (InterceptorDescriptor) l.get(1);
           assertEquals("OtherInterceptor", id.getFactoryServiceId());
  -        assertEquals("MyInterceptor", id.getAfter());
  +        assertEquals("MyInterceptorName", id.getAfter());
  +        assertNull(id.getName());
       }
   
       public void testImplementation() throws Exception
  
  
  
  1.11      +3 -3      jakarta-hivemind/framework/src/test/hivemind/test/parse/GenericModule.xml
  
  Index: GenericModule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/parse/GenericModule.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- GenericModule.xml	5 Jan 2005 21:53:32 -0000	1.10
  +++ GenericModule.xml	28 Feb 2005 12:35:43 -0000	1.11
  @@ -68,11 +68,11 @@
   	<service-point id="MyService1" interface="package.MyService">
   		Description of MyService1.
   		<create-instance class="package.impl.MyServiceImpl"/>
  -		<interceptor service-id="MyInterceptor" before="OtherInterceptor"/>
  -		<interceptor service-id="OtherInterceptor" after="MyInterceptor"/>
  +		<interceptor service-id="MyInterceptor" before="OtherInterceptor" name="MyInterceptorName"/>
  +		<interceptor service-id="OtherInterceptor" after="MyInterceptorName"/>
   	</service-point>
   	<implementation service-id="othermodule.OtherService">
  -		<interceptor service-id="MyInterceptor"/>
  +		<interceptor service-id="MyInterceptor" />
   	</implementation>
   	<service-point id="MyServiceFactory"
   		interface="org.apache.hivemind.ServiceImplementationFactory"
  
  
  
  1.5       +86 -1     jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestServicePoint.java
  
  Index: TestServicePoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestServicePoint.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestServicePoint.java	17 Feb 2005 19:46:45 -0000	1.4
  +++ TestServicePoint.java	28 Feb 2005 12:35:43 -0000	1.5
  @@ -16,6 +16,7 @@
   
   import java.util.ArrayList;
   import java.util.List;
  +import java.util.Locale;
   import java.util.Map;
   
   import org.apache.hivemind.ApplicationRuntimeException;
  @@ -41,7 +42,7 @@
   
           result.setClassResolver(new DefaultClassResolver());
           result.setPackageName("");
  -
  +        result.setRegistry(new RegistryInfrastructureImpl( new StrictErrorHandler(), Locale.getDefault()));
           return result;
       }
   
  @@ -73,6 +74,90 @@
           verifyControls();
       }
   
  +    public void testDefaultInterceptorOrdering()
  +    {
  +        Location l = fabricateLocation(12);
  +        Module module = newModule();
  +
  +        replayControls();
  +
  +        ServicePointImpl sp = new ServicePointImpl();
  +        sp.setModule(module);
  +        sp.setServiceInterfaceName("foo.bar.Baz");
  +        sp.setExtensionPointId("zip.zap");
  +        sp.setLocation(l);
  +        final ServiceInterceptorContributionImpl interceptor1 = new ServiceInterceptorContributionImpl();
  +        interceptor1.setFactoryServiceId( "SomeFactory1" );
  +        sp.addInterceptorContribution( interceptor1 );
  +        final ServiceInterceptorContributionImpl interceptor2 = new ServiceInterceptorContributionImpl();
  +        interceptor2.setFactoryServiceId( "SomeFactory2" );
  +        sp.addInterceptorContribution( interceptor2 );
  +        sp.setExtensionPointId( "ExtensionPointId" );
  +        final List ordered = sp.getOrderedInterceptorContributions();
  +        assertNotNull( ordered );
  +        assertEquals( 2, ordered.size() );
  +        assertEquals( interceptor1, ordered.get( 0 ) );
  +        assertEquals( interceptor2, ordered.get( 1 ) );
  +        verifyControls();
  +    }
  +
  +    public void testCustomInterceptorOrdering()
  +    {
  +        Location l = fabricateLocation(12);
  +        Module module = newModule();
  +
  +        replayControls();
  +
  +        ServicePointImpl sp = new ServicePointImpl();
  +        sp.setModule(module);
  +        sp.setServiceInterfaceName("foo.bar.Baz");
  +        sp.setExtensionPointId("zip.zap");
  +        sp.setLocation(l);
  +        final ServiceInterceptorContributionImpl interceptor1 = new ServiceInterceptorContributionImpl();
  +        interceptor1.setFactoryServiceId( "SomeFactory1" );
  +        sp.addInterceptorContribution( interceptor1 );
  +        final ServiceInterceptorContributionImpl interceptor2 = new ServiceInterceptorContributionImpl();
  +        interceptor2.setFactoryServiceId( "SomeFactory2" );
  +        interceptor2.setFollowingInterceptorIds("SomeFactory1");
  +        sp.addInterceptorContribution( interceptor2 );
  +        sp.setExtensionPointId( "ExtensionPointId" );
  +        final List ordered = sp.getOrderedInterceptorContributions();
  +        assertNotNull( ordered );
  +        assertEquals( 2, ordered.size() );
  +        assertEquals( interceptor2, ordered.get( 0 ) );
  +        assertEquals( interceptor1, ordered.get( 1 ) );
  +        verifyControls();
  +    }
  +
  +    public void testInterceptorOrderingByName()
  +    {
  +        Location l = fabricateLocation(12);
  +        Module module = newModule();
  +
  +        replayControls();
  +
  +        ServicePointImpl sp = new ServicePointImpl();
  +        sp.setModule(module);
  +        sp.setServiceInterfaceName("foo.bar.Baz");
  +        sp.setExtensionPointId("zip.zap");
  +        sp.setLocation(l);
  +        final ServiceInterceptorContributionImpl interceptor1 = new ServiceInterceptorContributionImpl();
  +        interceptor1.setFactoryServiceId( "SomeFactory1" );
  +        interceptor1.setName( "Interceptor1" );
  +        sp.addInterceptorContribution( interceptor1 );
  +        final ServiceInterceptorContributionImpl interceptor2 = new ServiceInterceptorContributionImpl();
  +        interceptor2.setFactoryServiceId( "SomeFactory2" );
  +        interceptor2.setFollowingInterceptorIds("Interceptor1");
  +        sp.addInterceptorContribution( interceptor2 );
  +        sp.setExtensionPointId( "ExtensionPointId" );
  +        final List ordered = sp.getOrderedInterceptorContributions();
  +        assertNotNull( ordered );
  +        assertEquals( 2, ordered.size() );
  +        assertEquals( interceptor2, ordered.get( 0 ) );
  +        assertEquals( interceptor1, ordered.get( 1 ) );
  +        verifyControls();
  +    }
  +    
       public void testResultNotAssignableToServiceInterface()
       {
           Location l = fabricateLocation(187);
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestServiceInterceptorContributionImpl.java
  
  Index: TestServiceInterceptorContributionImpl.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;
  
  import org.apache.hivemind.test.HiveMindTestCase;
  
  /**
   * Tests for {@link ServiceInterceptorContributionImpl}.
   * @author James Carman
   * @since 1.1
   */
  public class TestServiceInterceptorContributionImpl extends HiveMindTestCase
  {
      private static final String NAME = "SomeName";
      private static final String FACTORY_ID = "SomeFactoryId";
      
      /**
       * Tests to make sure that the name defaults to the factory id.
       *
       */
      public void testNameDefault()
      {
          final ServiceInterceptorContributionImpl impl = new ServiceInterceptorContributionImpl();
          impl.setFactoryServiceId( FACTORY_ID );
          assertEquals( FACTORY_ID, impl.getName() );
      }
      
      /**
       * Tests to make sure that the name override works.
       *
       */
      public void testNameOverride()
      {
          final ServiceInterceptorContributionImpl impl = new ServiceInterceptorContributionImpl();
          impl.setFactoryServiceId( FACTORY_ID );
          impl.setName( NAME );
          assertEquals( NAME, impl.getName() );
      }    
  }
  
  
  
  1.5       +9 -1      jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/ServiceInterceptorContribution.java
  
  Index: ServiceInterceptorContribution.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/ServiceInterceptorContribution.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServiceInterceptorContribution.java	19 Feb 2005 02:40:54 -0000	1.4
  +++ ServiceInterceptorContribution.java	28 Feb 2005 12:35:59 -0000	1.5
  @@ -25,6 +25,15 @@
   public interface ServiceInterceptorContribution extends Locatable
   {
       /**
  +     * Returns the name of the service interceptor.  The name is used for ordering the
  +     * service interceptor with respect to other interceptors.  The name defaults
  +     * to the factoryServiceId if no name is specified.
  +     * @return the name of the service interceptor
  +     * @since 1.1
  +     */
  +    public String getName();
  +    
  +    /**
        * Returns the id of the factory that creates the interceptor. Interceptor factories
are simply
        * another HiveMind service, one that implements
        * {@link org.apache.hivemind.ServiceInterceptorFactory}.
  @@ -42,7 +51,6 @@
        * <p>
        * Each service id is fully qualified. May return null.
        */
  -
       public String getPrecedingInterceptorIds();
   
       /**
  
  
  
  1.12      +1 -1      jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java
  
  Index: ServicePointImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ServicePointImpl.java	17 Feb 2005 19:46:44 -0000	1.11
  +++ ServicePointImpl.java	28 Feb 2005 12:36:28 -0000	1.12
  @@ -282,7 +282,7 @@
               // the interceptor stack we'll apply them in reverse order,
               // building outward from the core service implementation.
   
  -            orderer.add(sic, sic.getFactoryServiceId(), sic.getPrecedingInterceptorIds(),
sic
  +            orderer.add(sic, sic.getName(), sic.getPrecedingInterceptorIds(), sic
                       .getFollowingInterceptorIds());
           }
   
  
  
  
  1.11      +21 -1     jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ServiceInterceptorContributionImpl.java
  
  Index: ServiceInterceptorContributionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ServiceInterceptorContributionImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ServiceInterceptorContributionImpl.java	6 Jan 2005 01:45:12 -0000	1.10
  +++ ServiceInterceptorContributionImpl.java	28 Feb 2005 12:36:52 -0000	1.11
  @@ -47,6 +47,8 @@
   
       private String _followingInterceptorIds;
   
  +    private String _name;
  +    
       public String toString()
       {
           ToStringBuilder builder = new ToStringBuilder(this);
  @@ -54,10 +56,28 @@
           builder.append("parameters", _parameters);
           builder.append("precedingInterceptorIds", _precedingInterceptorIds);
           builder.append("followingInterceptorIds", _followingInterceptorIds);
  -
  +        builder.append("name", _name );
           return builder.toString();
       }
   
  +    
  +    /**
  +     * @return Returns the name.
  +     */
  +    public String getName()
  +    {
  +        if( _name == null )
  +        {
  +            return getFactoryServiceId();
  +        }
  +        return _name;
  +    }
  +    
  +    public void setName( String name )
  +    {
  +        _name = name;
  +    }
  +    
       public String getFactoryServiceId()
       {
           return _factoryServiceId;
  
  
  
  1.7       +18 -1     jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/InterceptorDescriptor.java
  
  Index: InterceptorDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/InterceptorDescriptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- InterceptorDescriptor.java	5 Jan 2005 18:05:37 -0000	1.6
  +++ InterceptorDescriptor.java	28 Feb 2005 12:36:54 -0000	1.7
  @@ -25,7 +25,8 @@
   {
       private String _before;
       private String _after;
  -
  +    private String _name;
  +    
       public String getAfter()
       {
           return _after;
  @@ -46,10 +47,26 @@
           _before = string;
       }
   
  +    /**
  +     * @return Returns the name.
  +     */
  +    public String getName()
  +    {
  +        return _name;
  +    }
  +    /**
  +     * @param name The name to set.
  +     */
  +    public void setName(String name)
  +    {
  +        this._name = name;
  +    }
  +    
       protected void extendDescription(ToStringBuilder builder)
       {
           builder.append("before", _before);
           builder.append("after", _after);
  +        builder.append("name", _name);
       }
   
   }
  
  
  
  1.49      +1 -1      jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java
  
  Index: DescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- DescriptorParser.java	19 Feb 2005 13:42:56 -0000	1.48
  +++ DescriptorParser.java	28 Feb 2005 12:36:54 -0000	1.49
  @@ -935,7 +935,7 @@
   
           id.setBefore(getAttribute("before"));
           id.setAfter(getAttribute("after"));
  -
  +        id.setName(getAttribute("name" ));
           sd.addInterceptor(id);
   
       }
  
  
  
  1.19      +1 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.properties
  
  Index: DescriptorParser.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.properties,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DescriptorParser.properties	10 Feb 2005 01:04:34 -0000	1.18
  +++ DescriptorParser.properties	28 Feb 2005 12:36:54 -0000	1.19
  @@ -38,6 +38,7 @@
   
   required.interceptor.before=false
   required.interceptor.after=false
  +required.interceptor.name=false
   required.interceptor.service-id=true
   
   required.element.name=true
  
  
  

---------------------------------------------------------------------
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