mcconnell 2002/08/17 21:10:05 Modified: assembly/src/java/org/apache/excalibur/meta/info ExtensionDescriptor.java assembly/src/java/org/apache/excalibur/meta/info/builder XMLTypeCreator.java Log: Updates to the clasases to incorporate the list concensus concerning the community consunsus of the stage/phase terminology. Revision Changes Path 1.7 +3 -134 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/ExtensionDescriptor.java Index: ExtensionDescriptor.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/ExtensionDescriptor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ExtensionDescriptor.java 12 Aug 2002 02:00:11 -0000 1.6 +++ ExtensionDescriptor.java 18 Aug 2002 04:10:05 -0000 1.7 @@ -10,61 +10,13 @@ import java.util.Properties; /** - * A descriptor that describes a name and inteface of a lifecycle phase. + * A descriptor that describes a name and inteface of a lifecycle stage. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a> * @version $Revision$ $Date$ */ public final class ExtensionDescriptor extends Descriptor { - /** - * Constant emumeration referring to the creation stage in a component - * management lifecycle. An extension declaring CREATE will be invoked - * prior to component initialization. - */ - public static final int CREATE = 0; - - /** - * Constant emumeration referring to the access stage in a component - * management lifecycle. An extension declaring ACCESS will be invoked - * prior to component lookup within a component or service manager. - */ - public static final int ACCESS = 1; - - /** - * Constant emumeration referring to the release stage in a component - * management lifecycle. An extension declaring RELEASSE will be invoked - * after a component release within a component or service manager. - */ - public static final int RELEASE = 2; - - /** - * Constant emumeration referring to the destruction stage in a component - * management lifecycle. An extension declaring DESTROY will be invoked - * prior to component disposal. - */ - public static final int DESTROY = 3; - - /** - * Constant emumeration that is equivalent to ACCESS and RELEASE. - */ - public static final int INNER = 4; - - /** - * Constant emumeration that is equivalent to CREATE and DESTROY. - */ - public static final int OUTER = 5; - - /** - * Constant emumeration that is equivalent to OUTER and INNER. - */ - public static final int ALL = 6; - - /** - * The lifecycle stage. - */ - private final int m_stage; - /** * The name of the lifecycle phase. */ @@ -86,11 +38,10 @@ * @param interface the phase type */ public ExtensionDescriptor( final String name, - final int stage, final ContextDescriptor context, final ReferenceDescriptor reference ) { - this( name, stage, reference, context, null ); + this( name, reference, context, null ); } /** @@ -99,7 +50,6 @@ * @param interface the phase type */ public ExtensionDescriptor( final String name, - final int stage, final ReferenceDescriptor reference, final ContextDescriptor context, final Properties attributes ) @@ -112,13 +62,10 @@ throw new NullPointerException( "reference" ); if( null == context ) throw new NullPointerException( "context" ); - if( (ALL < stage) || (stage < CREATE )) - throw new IllegalArgumentException( "stage: " + stage ); m_name = name; m_reference = reference; m_context = context; - m_stage = stage; } /** @@ -150,82 +97,4 @@ { return m_context; } - - /** - * Return the component management lifecycle stage that this - * extension is to be applied under. - * - * @return one of the phase values {@link #CREATE}, {@link #ACCESS}, - * {@link #RELEASE}, {@link #DESTROY}, - * {@link #INNER}, {@link #OUTER}, or {@link #ALL}. - */ - public int getStage() - { - return m_stage; - } - - /** - * Returns TRUE if the supplied stage matches a stage applicable to this extension. - * @param stage the lifecycle management stage enumeration - * @return true if the supplied stage is applicable - */ - public boolean isApplicable( int stage ) - { - final int policy = getStage(); - if( policy == ALL ) - return true; - if( policy == stage ) - return true; - if(( stage == CREATE ) || ( stage == DESTROY )) - { - return ( policy == OUTER ); - } - else if(( stage == ACCESS ) || ( stage == RELEASE )) - { - return ( policy == INNER ); - } - return false; - } - - /** - * Return a string representation of the stage enumeration. - * @param stage the component lifecycle management stage enumeration - * @return the string representation of the stage value - */ - public static String stageToString( int stage ) - { - if( stage == CREATE ) - { - return "CREATE"; - } - else if( stage == ACCESS ) - { - return "ACCESS"; - } - else if( stage == RELEASE ) - { - return "RELEASE"; - } - else if( stage == DESTROY ) - { - return "DESTROY"; - } - else if( stage == INNER ) - { - return "INNER"; - } - else if( stage == OUTER ) - { - return "OUTER"; - } - else if( stage == ALL ) - { - return "ALL"; - } - else - { - throw new IllegalArgumentException( "stage: " + stage ); - } - } - } 1.11 +2 -44 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/builder/XMLTypeCreator.java Index: XMLTypeCreator.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/builder/XMLTypeCreator.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- XMLTypeCreator.java 15 Aug 2002 04:14:50 -0000 1.10 +++ XMLTypeCreator.java 18 Aug 2002 04:10:05 -0000 1.11 @@ -469,55 +469,13 @@ { Configuration extension = extensions[i]; final String name = extension.getChild("name").getValue(); - final int stage = getStageValue( extension ); ReferenceDescriptor reference = buildReferenceDescriptor( extension.getChild("reference") ); ContextDescriptor context = buildContext( extension.getChild("context") ); final Properties attributes = buildAttributes( extension.getChild( "attributes" ) ); - list.add( new ExtensionDescriptor( name, stage, reference, context, attributes ) ); + list.add( new ExtensionDescriptor( name, reference, context, attributes ) ); } return (ExtensionDescriptor[]) list.toArray( new ExtensionDescriptor[0] ); } - - private int getStageValue( Configuration phase ) - { - final String stage = phase.getAttribute("stage","CREATE"); - if( stage.equalsIgnoreCase("CREATE") ) - { - return ExtensionDescriptor.CREATE; - } - else if( stage.equalsIgnoreCase("DESTORY") ) - { - return ExtensionDescriptor.DESTROY; - } - else if( stage.equalsIgnoreCase("ACCESS") ) - { - return ExtensionDescriptor.ACCESS; - } - else if( stage.equalsIgnoreCase("RELEASE") ) - { - return ExtensionDescriptor.RELEASE; - } - else if( stage.equalsIgnoreCase("INNER") ) - { - return ExtensionDescriptor.INNER; - } - else if( stage.equalsIgnoreCase("OUTER") ) - { - return ExtensionDescriptor.OUTER; - } - else if( stage.equalsIgnoreCase("ALL") ) - { - return ExtensionDescriptor.ALL; - } - else - { - final String error = "Supplied stage argument '" + stage + " invalid at " - + phase.getLocation() - + ". Allowable values: CREATE,DESTORY,ACCESS, RELEASE, INNER, OUTER or ALL."; - - throw new IllegalArgumentException( error ); - } - } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>