mcconnell 2003/06/18 04:23:50
Modified: merlin/meta/src/java/org/apache/avalon/meta/model/builder
XMLProfileCreator.java
Log:
Moved activation policy handling to profile reader.
Revision Changes Path
1.7 +28 -1
avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/model/builder/XMLProfileCreator.java
Index: XMLProfileCreator.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/model/builder/XMLProfileCreator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XMLProfileCreator.java 15 Jun 2003 18:29:05 -0000 1.6
+++ XMLProfileCreator.java 18 Jun 2003 11:23:50 -0000 1.7
@@ -281,6 +281,8 @@
// create the profile instance
//
+ boolean activation = getActivationPolicy( config );
+
try
{
Profile profile = (Profile) m_clazz.newInstance();
@@ -292,6 +294,7 @@
context.put( Profile.CATEGORIES_KEY, categories );
context.put( Profile.TYPE_KEY, type );
context.put( Profile.MODE_KEY, mode );
+ context.put( Profile.ACTIVATION_KEY, new Boolean( activation ) );
profile.contextualize( context );
return profile;
}
@@ -303,6 +306,30 @@
throw new ModelRuntimeException( error, e );
}
}
+
+ /**
+ * Get the activation policy from a configuration. If no activation attribute
+ * is present the value return defaults to FALSE (i.e. activation is deferred).
+ *
+ * @param config a configuration fragment holding a activation attribute
+ * @return TRUE is the value of the activation attribute is 'true' or 'startup'
+ * otherwise the return value is FALSE
+ */
+ protected boolean getActivationPolicy( Configuration config )
+ {
+ final String value = config.getAttribute( "activation", null );
+ if( value == null )
+ {
+ return false;
+ }
+ final String string = value.toLowerCase().trim();
+ if( string.equals( "startup" ) )
+ {
+ return true;
+ }
+ return string.equals( "true" );
+ }
+
private Profile createImplicitProfile( Type type ) throws Exception
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]