avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/assembler/test assembly3.xml assembly4.xml AssemblerTestCase.java
Date Tue, 15 Oct 2002 22:14:08 GMT
donaldp     2002/10/15 15:14:07

  Modified:    src/java/org/apache/avalon/phoenix/metadata Tag:
                        FACTORY-branch BlockMetaData.java
               src/java/org/apache/avalon/phoenix/tools/assembler Tag:
                        FACTORY-branch Assembler.java
               src/java/org/apache/avalon/phoenix/tools/infobuilder Tag:
                        FACTORY-branch Resources.properties
               src/schema Tag: FACTORY-branch assembly.dtd
               src/test/org/apache/avalon/phoenix/tools/assembler/test Tag:
                        FACTORY-branch AssemblerTestCase.java
  Added:       src/java/org/apache/avalon/phoenix/metainfo Tag:
                        FACTORY-branch InterceptorInfo.java
               src/java/org/apache/avalon/phoenix/tools/infobuilder Tag:
                        FACTORY-branch InterceptorInfoBuilder.java
               src/test/org/apache/avalon/phoenix/test/data Tag:
                        FACTORY-branch Interceptor1.java Interceptor2.java
               src/test/org/apache/avalon/phoenix/tools/assembler/test Tag:
                        FACTORY-branch assembly3.xml assembly4.xml
  Log:
  Start integrating more of Igors work on Interceptors.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.16.4.1  +15 -1     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/metadata/BlockMetaData.java
  
  Index: BlockMetaData.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/metadata/BlockMetaData.java,v
  retrieving revision 1.16
  retrieving revision 1.16.4.1
  diff -u -r1.16 -r1.16.4.1
  --- BlockMetaData.java	1 Oct 2002 07:27:43 -0000	1.16
  +++ BlockMetaData.java	15 Oct 2002 22:14:06 -0000	1.16.4.1
  @@ -8,6 +8,7 @@
   package org.apache.avalon.phoenix.metadata;
   
   import org.apache.avalon.phoenix.metainfo.BlockInfo;
  +import org.apache.avalon.phoenix.metainfo.InterceptorInfo;
   
   /**
    * This is the structure describing each block.
  @@ -20,16 +21,19 @@
       private final DependencyMetaData[] m_dependencies;
       private final boolean m_disableProxy;
       private final BlockInfo m_blockInfo;
  +    private final InterceptorInfo[] m_interceptors;
   
       public BlockMetaData( final String name,
                             final DependencyMetaData[] dependencies,
                             final boolean disableProxy,
  -                          final BlockInfo blockInfo )
  +                          final BlockInfo blockInfo,
  +                          final InterceptorInfo[] interceptors )
       {
           m_name = name;
           m_dependencies = dependencies;
           m_disableProxy = disableProxy;
           m_blockInfo = blockInfo;
  +        m_interceptors = interceptors;
       }
   
       public String getName()
  @@ -76,5 +80,15 @@
       public boolean isDisableProxy()
       {
           return m_disableProxy;
  +    }
  +
  +    /**
  +     * Returns the interceptors.
  +     * 
  +     * @return InterceptorInfo[]
  +     */
  +    public InterceptorInfo[] getInterceptors()
  +    {
  +        return m_interceptors;
       }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +29 -0     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/metainfo/Attic/InterceptorInfo.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.22.4.1  +6 -2      jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/assembler/Assembler.java
  
  Index: Assembler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/assembler/Assembler.java,v
  retrieving revision 1.22
  retrieving revision 1.22.4.1
  diff -u -r1.22 -r1.22.4.1
  --- Assembler.java	1 Oct 2002 07:04:05 -0000	1.22
  +++ Assembler.java	15 Oct 2002 22:14:07 -0000	1.22.4.1
  @@ -21,8 +21,10 @@
   import org.apache.avalon.phoenix.metadata.DependencyMetaData;
   import org.apache.avalon.phoenix.metadata.SarMetaData;
   import org.apache.avalon.phoenix.metainfo.BlockInfo;
  +import org.apache.avalon.phoenix.metainfo.InterceptorInfo;
   import org.apache.avalon.phoenix.tools.configuration.ConfigurationBuilder;
   import org.apache.avalon.phoenix.tools.infobuilder.BlockInfoBuilder;
  +import org.apache.avalon.phoenix.tools.infobuilder.InterceptorInfoBuilder;
   
   /**
    * Assemble a {@link SarMetaData} object from a Configuration
  @@ -39,6 +41,7 @@
           ResourceManager.getPackageResources( Assembler.class );
   
       private final BlockInfoBuilder m_builder = new BlockInfoBuilder();
  +    private final InterceptorInfoBuilder m_interceptorBuilder = new InterceptorInfoBuilder();
   
       /**
        * Overidden setLogger() method to setup BlockInfoBuilder
  @@ -122,12 +125,13 @@
               final Configuration proxy = block.getChild( "proxy" );
               final boolean disableProxy =
                   proxy.getAttributeAsBoolean( "disable", false );
  +            final InterceptorInfo[] interceptors = m_interceptorBuilder.build( proxy );

   
               final DependencyMetaData[] roles = buildDependencyMetaDatas( provides );
               final BlockInfo info = getBlockInfo( name, classname, classLoader );
   
   
  -            return new BlockMetaData( name, roles, disableProxy, info );
  +            return new BlockMetaData( name, roles, disableProxy, info, interceptors );
           }
           catch( final ConfigurationException ce )
           {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.5.8.1   +2 -1      jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder/Resources.properties,v
  retrieving revision 1.5
  retrieving revision 1.5.8.1
  diff -u -r1.5 -r1.5.8.1
  --- Resources.properties	17 Aug 2002 02:34:44 -0000	1.5
  +++ Resources.properties	15 Oct 2002 22:14:07 -0000	1.5.8.1
  @@ -2,4 +2,5 @@
   missing-block=Warning: Unspecified <block/> section in BlockInfo for class {0}.
   redundent-role=Warning: BlockInfo for class {0} redundently specifies role name "{1}" in
dependency when it is identical to the name of service. It is recomended that the <role/>
section be elided.
   creating-blockinfo=Creating a BlockInfo for class "{0}".
  -deprecated-management-declaration=The BlockInfo for "{0}" uses the deprecated mechanism
to declare management services. It is recomended you replace <management> with <management-access-points>.
  \ No newline at end of file
  +deprecated-management-declaration=The BlockInfo for "{0}" uses the deprecated mechanism
to declare management services. It is recomended you replace <management> with <management-access-points>.
  +interceptors-without-proxy=Block invocation interceptors cannot be used if block proxy
is disabled. ({0}).
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +75 -0     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder/Attic/InterceptorInfoBuilder.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.4.1   +15 -3     jakarta-avalon-phoenix/src/schema/assembly.dtd
  
  Index: assembly.dtd
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/schema/assembly.dtd,v
  retrieving revision 1.6
  retrieving revision 1.6.4.1
  diff -u -r1.6 -r1.6.4.1
  --- assembly.dtd	1 Oct 2002 07:34:55 -0000	1.6
  +++ assembly.dtd	15 Oct 2002 22:14:07 -0000	1.6.4.1
  @@ -55,12 +55,24 @@
     <!ATTLIST provide alias CDATA #IMPLIED>
   
   <!--
  -This indicates whether the block should be proxied.
  +This indicates whether the block should be proxied and defines block invocation
  +interceptor chain.
   
  -disable set this to true to disable proxying of the block implementation
  +disable     set this to true to disable proxying of the block implementation
  +interceptor configures block invocation interceptor chain. interceptors
  +      will be invoked in the order they defined here. disable should be false
  +      (or not specified) in order to use interceptors.
   -->
  -<!ELEMENT proxy EMPTY>
  +<!ELEMENT proxy (interceptor*)>
     <!ATTLIST proxy disable CDATA #REQUIRED>
  +
  +<!--
  +This configures block invocation interceptor.
  +
  +class           the class of block invocation interceptor
  +-->
  +<!ELEMENT interceptor EMPTY>
  +  <!ATTLIST interceptor class CDATA #REQUIRED>
   
   <!--
   The block element declares a listener exists in the application.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +21 -0     jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/test/data/Attic/Interceptor1.java
  
  
  
  
  1.1.2.1   +21 -0     jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/test/data/Attic/Interceptor2.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.4.1   +44 -1     jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/assembler/test/AssemblerTestCase.java
  
  Index: AssemblerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/assembler/test/AssemblerTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.6.4.1
  diff -u -r1.6 -r1.6.4.1
  --- AssemblerTestCase.java	1 Oct 2002 06:17:58 -0000	1.6
  +++ AssemblerTestCase.java	15 Oct 2002 22:14:07 -0000	1.6.4.1
  @@ -10,11 +10,15 @@
   import org.apache.avalon.phoenix.metadata.BlockMetaData;
   import org.apache.avalon.phoenix.metadata.DependencyMetaData;
   import org.apache.avalon.phoenix.metadata.SarMetaData;
  +import org.apache.avalon.phoenix.metainfo.InterceptorInfo;
   import org.apache.avalon.phoenix.test.AbstractContainerTestCase;
   import org.apache.avalon.phoenix.test.data.Component1;
   import org.apache.avalon.phoenix.test.data.Component2;
   import org.apache.avalon.phoenix.test.data.Component3;
  +import org.apache.avalon.phoenix.test.data.Interceptor1;
  +import org.apache.avalon.phoenix.test.data.Interceptor2;
   import org.apache.avalon.phoenix.test.data.Service2;
  +import org.apache.avalon.phoenix.tools.assembler.AssemblyException;
   
   /**
    *  An basic test case for the LogManager.
  @@ -133,5 +137,44 @@
           assertTrue( "Block4 getBlockInfo non null",
                          null != block4.getBlockInfo() );
           assertEquals( "Block4 isDisableProxy", false, block4.isDisableProxy() );
  +    }
  +
  +    public void testInterceptorBasic()
  +        throws Exception
  +    {
  +        final SarMetaData sarMetaData = assembleSar( "assembly3.xml" );
  +        final BlockMetaData[] blocks = sarMetaData.getBlocks();
  +        assertEquals( "Block Count", 2, blocks.length );
  +
  +        final BlockMetaData block1 = blocks[ 0 ];
  +        final BlockMetaData block2 = blocks[ 1 ];
  +        final InterceptorInfo[] interceptor1 = block1.getInterceptors();
  +        final InterceptorInfo[] interceptor2 = block2.getInterceptors();
  +        
  +        assertEquals( "Block1 Interceptor count", 1, interceptor1.length );
  +        assertEquals( "Block1 Interceptor class",
  +                      Interceptor1.class.getName(),
  +                      interceptor1[ 0 ].getClassname() );
  +       
  +        assertEquals( "Block2 Interceptor count", 2, interceptor2.length );
  +        assertEquals( "Block2 Interceptor1 class",
  +                      Interceptor1.class.getName(),
  +                      interceptor2[ 0 ].getClassname() );
  +        assertEquals( "Block2 Interceptor2 class",
  +                      Interceptor2.class.getName(),
  +                      interceptor2[ 1 ].getClassname() );
  +    }
  +
  +    public void testInterceptorInvalid()
  +        throws Exception
  +    {
  +        try 
  +        {
  +            /*final SarMetaData sarMetaData =*/ assembleSar( "assembly4.xml" );
  +            fail( "Invalid assemble.xml did not fail" );
  +        }
  +        catch ( AssemblyException expected )
  +        {
  +        }
       }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +21 -0     jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/assembler/test/Attic/assembly3.xml
  
  
  
  
  1.1.2.1   +14 -0     jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/assembler/test/Attic/assembly4.xml
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message