crafterm 2002/08/27 14:25:31
Modified: fortress build.xml default.properties
fortress/examples build.xml
fortress/examples/src/java/org/apache/excalibur/fortress/examples/extended
ExtendedContainer.java
fortress/examples/src/java/org/apache/excalibur/fortress/examples/extended/extensions
Extensions.java
fortress/src/java/org/apache/excalibur/fortress/lifecycle
AbstractLifecycleExtensionManager.java
LifecycleExtensionManager.java
Removed: fortress/src/java/org/apache/excalibur/fortress/lifecycle
AbstractLifecycleExtension.java
LifecycleExtension.java
Log:
First cut at updating Fortress to use the new
org.apache.excalibur.container.lifecycle.* interfaces to perform
Lifecycle extensions.
Revision Changes Path
1.48 +3 -0 jakarta-avalon-excalibur/fortress/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/build.xml,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- build.xml 27 Aug 2002 20:16:45 -0000 1.47
+++ build.xml 27 Aug 2002 21:25:31 -0000 1.48
@@ -24,6 +24,7 @@
<pathelement location="${excalibur-logger.jar}"/>
<pathelement location="${excalibur-sourceresolve.jar}"/>
<pathelement location="${excalibur-concurrent.jar}"/>
+ <pathelement location="${excalibur-container.jar}"/>
<pathelement location="${checkstyle.jar}"/>
<pathelement path="${java.class.path}"/>
</path>
@@ -76,6 +77,7 @@
<copy file="${excalibur-logger.jar}" todir="${build.dir}/tempjars"/>
<copy file="${excalibur-sourceresolve.jar}" todir="${build.dir}/tempjars"/>
<copy file="${excalibur-concurrent.jar}" todir="${build.dir}/tempjars"/>
+ <copy file="${excalibur-container.jar}" todir="${build.dir}/tempjars"/>
<copy file="${excalibur-threadcontext.jar}" todir="${build.dir}/tempjars"/>
<copy file="${build.lib}/${jar.name}" todir="${build.dir}/tempjars"/>
<unzip dest="${build.dir}/tempjars"
src="../assembly/distributions/merlin-2.0a.zip">
@@ -120,6 +122,7 @@
<ant antfile="${depchecker.prefix}/depchecker.xml" target="checkEvent"/>
<ant antfile="${depchecker.prefix}/depchecker.xml"
target="checkThreadcontext"/>
<ant antfile="${depchecker.prefix}/depchecker.xml" target="checkLogger"/>
+ <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkContainer"/>
<ant antfile="../assembly/build.xml" target="dist" inheritAll="false"/>
<ant antfile="${depchecker.prefix}/depchecker.xml"
target="checkRequiredClass">
<property name="proj.jar.name" value="xml-apis.jar"/>
1.33 +5 -0 jakarta-avalon-excalibur/fortress/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/default.properties,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- default.properties 14 Aug 2002 14:58:23 -0000 1.32
+++ default.properties 27 Aug 2002 21:25:31 -0000 1.33
@@ -74,6 +74,11 @@
excalibur-threadcontext.lib=${excalibur-threadcontext.home}
excalibur-threadcontext.jar=${excalibur-threadcontext.lib}/excalibur-threadcontext-1.0.jar
+# ----- Excalibur container, version 1.0 or later -----
+excalibur-container.home=${basedir}/../container/dist
+excalibur-container.lib=${excalibur-container.home}
+excalibur-container.jar=${excalibur-container.lib}/excalibur-container-1.0.jar
+
# ----- Altrmi -----
excalibur-altrmi.home=${basedir}/../altrmi/dist
excalibur-altrmi-common.jar=${excalibur-altrmi.home}/excalibur-altrmi-common.jar
1.11 +1 -1 jakarta-avalon-excalibur/fortress/examples/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/examples/build.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- build.xml 9 Aug 2002 05:31:22 -0000 1.10
+++ build.xml 27 Aug 2002 21:25:31 -0000 1.11
@@ -13,7 +13,7 @@
<property name="name" value="fortress-examples"/>
<property name="Name" value="Fortress-Examples"/>
- <!-- Directories build by ant -->
+ <!-- Directories built by ant -->
<property name="build.dir" value="${basedir}/build"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<property name="build.javadocs.dir" value="${build.dir}/javadocs"/>
1.6 +1 -1
jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/extended/ExtendedContainer.java
Index: ExtendedContainer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/extended/ExtendedContainer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ExtendedContainer.java 7 Aug 2002 13:27:18 -0000 1.5
+++ ExtendedContainer.java 27 Aug 2002 21:25:31 -0000 1.6
@@ -61,7 +61,7 @@
{
super.initialize();
- m_extManager.addExtension( new Extensions() );
+ m_extManager.addAccessorExtension( new Extensions() );
}
public void doLookups()
1.5 +3 -3
jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/extended/extensions/Extensions.java
Index: Extensions.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/examples/src/java/org/apache/excalibur/fortress/examples/extended/extensions/Extensions.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Extensions.java 13 Aug 2002 07:57:25 -0000 1.4
+++ Extensions.java 27 Aug 2002 21:25:31 -0000 1.5
@@ -50,8 +50,8 @@
package org.apache.excalibur.fortress.examples.extended.extensions;
import org.apache.avalon.framework.context.Context;
+import org.apache.excalibur.container.lifecycle.AbstractAccessor;
import org.apache.excalibur.fortress.AbstractContainer;
-import org.apache.excalibur.fortress.lifecycle.AbstractLifecycleExtension;
/**
* Some custom extensions for this container's components.
@@ -60,7 +60,7 @@
* @version CVS $Revision$ $Date$
*/
public class Extensions
- extends AbstractLifecycleExtension
+ extends AbstractAccessor
{
/**
* Access, called when the given component is being
1.6 +36 -44
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/lifecycle/AbstractLifecycleExtensionManager.java
Index: AbstractLifecycleExtensionManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/lifecycle/AbstractLifecycleExtensionManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractLifecycleExtensionManager.java 13 Aug 2002 07:57:26 -0000 1.5
+++ AbstractLifecycleExtensionManager.java 27 Aug 2002 21:25:31 -0000 1.6
@@ -49,49 +49,27 @@
*/
package org.apache.excalibur.fortress.lifecycle;
-import java.lang.reflect.Method;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.excalibur.container.lifecycle.Accessor;
+import org.apache.excalibur.container.lifecycle.Creator;
+
/**
* <code>AbstractLifecycleExtensionManager</code> class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Revision$ $Date$
*/
-public abstract class AbstractLifecycleExtensionManager extends AbstractLogEnabled
+public abstract class AbstractLifecycleExtensionManager
+ extends AbstractLogEnabled
{
// Lifecycle method constants, these are passed to executeExtensions()
- protected final Method ACCESS;
- protected final Method RELEASE;
- protected final Method CREATION;
- protected final Method DESTRUCTION;
-
- /**
- * Constructor, creates a lifecycle manager, and caches all lifecycle
- * <code>Method</code> objects for later use.
- */
- public AbstractLifecycleExtensionManager()
- {
- final Class[] params = { Object.class, Context.class };
- final Class clazz = LifecycleExtension.class;
-
- try
- {
- ACCESS = clazz.getDeclaredMethod( "access", params );
- RELEASE = clazz.getDeclaredMethod( "release", params );
- CREATION = clazz.getDeclaredMethod( "create", params );
- DESTRUCTION = clazz.getDeclaredMethod( "destroy", params );
- }
- catch ( NoSuchMethodException e )
- {
- throw new IllegalStateException(
- "Bad environment, cannot reference LifecycleExtension class: " +
- e.getMessage()
- );
- }
- }
+ protected static final int ACCESS = 0;
+ protected static final int RELEASE = 1;
+ protected static final int CREATE = 2;
+ protected static final int DESTROY = 3;
/**
* <code>executeExtensions</code> method, executes a given array of
@@ -99,30 +77,44 @@
*
* @param component a <code>Component</code> instance
* @param context a <code>Context</code> instance
- * @param type a <code>Method</code> instance, referencing which phase the
+ * @param type a constant, referencing which phase the
* extensions array adheres to
*
* @exception Exception if an error occurs
*/
protected void executeExtensions(
- Object[] extensions, Object component, Context context, Method type
+ Object[] extensions, Object component, Context context, int type
)
throws Exception
{
- final Object[] params = { component, context };
- for ( int i = 0; i < extensions.length; ++i )
+ switch (type)
{
- if ( getLogger().isDebugEnabled() )
+ case ACCESS:
+ for ( int i = 0; i < extensions.length; ++i )
+ ( (Accessor) extensions[i] ).access( component, context );
+ break;
+
+ case RELEASE:
+ for ( int i = 0; i < extensions.length; ++i )
+ ( (Accessor) extensions[i] ).release( component, context );
+ break;
+
+ case CREATE:
+ for ( int i = 0; i < extensions.length; ++i )
+ ( (Creator) extensions[i] ).create( component, context );
+ break;
+
+ case DESTROY:
+ for ( int i = 0; i < extensions.length; ++i )
+ ( (Creator) extensions[i] ).destroy( component, context );
+ break;
+
+ default:
+ if ( getLogger().isErrorEnabled() )
{
- getLogger().debug(
- "Executing extension " + extensions[i] +
- " on component " + component +
- " (" + type.getName() + " phase)"
- );
+ getLogger().error( "Incorrect extension phase specified: " + type );
}
-
- type.invoke( ( LifecycleExtension ) extensions[i], params );
}
}
}
1.8 +100 -36
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/lifecycle/LifecycleExtensionManager.java
Index: LifecycleExtensionManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/lifecycle/LifecycleExtensionManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- LifecycleExtensionManager.java 13 Aug 2002 07:57:26 -0000 1.7
+++ LifecycleExtensionManager.java 27 Aug 2002 21:25:31 -0000 1.8
@@ -53,9 +53,13 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.context.Context;
+import org.apache.excalibur.container.lifecycle.Accessor;
+import org.apache.excalibur.container.lifecycle.Creator;
+
/**
* <code>LifecycleExtensionManager</code> class. This class manages a list
* of extensions objects that are executed on components during the various
@@ -81,7 +85,8 @@
extends AbstractLifecycleExtensionManager
{
// extensions objects
- private final CachedArrayList m_extensions = new CachedArrayList();
+ private final CachedArrayList m_accessorExtensions = new CachedArrayList();
+ private final CachedArrayList m_creatorExtensions = new CachedArrayList();
/**
* <code>executeAccessExtensions</code> method, executes all access
@@ -94,7 +99,7 @@
public void executeAccessExtensions( Object component, Context context )
throws Exception
{
- executeExtensions( m_extensions.toArray(), component, context, ACCESS );
+ executeExtensions( m_accessorExtensions.toArray(), component, context,
ACCESS );
}
/**
@@ -108,7 +113,7 @@
public void executeReleaseExtensions( Object component, Context context )
throws Exception
{
- executeExtensions( m_extensions.toArray(), component, context, RELEASE );
+ executeExtensions( m_accessorExtensions.toArray(), component, context,
RELEASE );
}
/**
@@ -122,7 +127,7 @@
public void executeCreationExtensions( Object component, Context context )
throws Exception
{
- executeExtensions( m_extensions.toArray(), component, context, CREATION );
+ executeExtensions( m_creatorExtensions.toArray(), component, context,
CREATE );
}
/**
@@ -136,7 +141,7 @@
public void executeDestructionExtensions( Object component, Context context )
throws Exception
{
- executeExtensions( m_extensions.toArray(), component, context, DESTRUCTION
);
+ executeExtensions( m_creatorExtensions.toArray(), component, context,
DESTROY );
}
// The following methods define operations that modify the internal list
@@ -156,35 +161,67 @@
// I'm open to suggestions though if there's any better ideas ?
/**
- * Adds an extension to the manager
+ * Adds an accessor extension to the manager
+ *
+ * @param extension a <code>Accessor</code> instance
+ */
+ public void addAccessorExtension( Accessor extension )
+ {
+ m_accessorExtensions.add( extension );
+ }
+
+ /**
+ * Adds a creator extension to the manager
+ *
+ * @param extension a <code>Creator</code> instance
+ */
+ public void addCreatorExtension( Creator extension )
+ {
+ m_creatorExtensions.add( extension );
+ }
+
+ /**
+ * Inserts an accessor extension at a given index in the manager
*
- * @param extension a <code>LifecycleExtension</code> instance
+ * @param position an <code>int</code> index value
+ * @param extension a <code>Accessor</code> instance
+ */
+ public void insertAccessorExtension( int position, Accessor extension )
+ {
+ m_accessorExtensions.insert( position, extension );
+ }
+
+ /**
+ * Inserts a creator extension at a given index in the manager
+ *
+ * @param position an <code>int</code> index value
+ * @param extension a <code>Creator</code> instance
*/
- public void addExtension( LifecycleExtension extension )
+ public void insertCreatorExtension( int position, Creator extension )
{
- m_extensions.add( extension );
+ m_accessorExtensions.insert( position, extension );
}
/**
- * Inserts an extension at a given index in the manager
+ * Removes a particular accessor extension from the manager
*
* @param position an <code>int</code> index value
- * @param extension a <code>LifecycleExtension</code> instance
+ * @return a <code>Accessor</code> instance
*/
- public void insertExtension( int position, LifecycleExtension extension )
+ public Accessor removeAccessorExtension( int position )
{
- m_extensions.insert( position, extension );
+ return (Accessor) m_accessorExtensions.remove( position );
}
/**
- * Removes a particular extension from the manager
+ * Removes a particular creator extension from the manager
*
* @param position an <code>int</code> index value
- * @return a <code>LifecycleExtension</code> instance
+ * @return a <code>Creator</code> instance
*/
- public LifecycleExtension removeExtension( int position )
+ public Creator removeCreatorExtension( int position )
{
- return (LifecycleExtension) m_extensions.remove( position );
+ return (Creator) m_creatorExtensions.remove( position );
}
/**
@@ -192,50 +229,77 @@
*
* @return an <code>Iterator</code> instance
*/
- public Iterator extensionsIterator()
+ public Iterator accessorExtensionsIterator()
{
- return m_extensions.iterator();
+ return m_accessorExtensions.iterator();
}
/**
- * Find out the total number of extensions registered with this manager
+ * Obtain an iterator.
+ *
+ * @return an <code>Iterator</code> instance
+ */
+ public Iterator creatorExtensionsIterator()
+ {
+ return m_creatorExtensions.iterator();
+ }
+
+ /**
+ * Find out the total number of accessor extensions registered with this manager
*
* @return an <code>int</code> value
*/
- public int extensionsCount()
+ public int accessorExtensionsCount()
{
- return m_extensions.size();
+ return m_accessorExtensions.size();
}
/**
- * Obtain the particular extension at the given index
+ * Find out the total number of creator extensions registered with this manager
+ *
+ * @return an <code>int</code> value
+ */
+ public int creatorExtensionsCount()
+ {
+ return m_creatorExtensions.size();
+ }
+
+ /**
+ * Obtain the particular accessor extension at the given index
*
* @param index an <code>int</code> index value
- * @return a <code>LifecycleExtension</code> instance
+ * @return a <code>Accessor</code> instance
*/
- public LifecycleExtension getExtension( int index )
+ public Accessor getAccessorExtension( int index )
{
- return (LifecycleExtension) m_extensions.get( index );
+ return (Accessor) m_accessorExtensions.get( index );
}
/**
- * Check whether the given extension is already registered
- * with this manager
+ * Obtain the particular creator extension at the given index
*
- * @param extension a <code>LifecycleExtension</code> instance
- * @return index of given extension, -1 if non-existing.
+ * @param index an <code>int</code> index value
+ * @return a <code>Creator</code> instance
+ */
+ public Creator getCreatorExtension( int index )
+ {
+ return (Creator) m_creatorExtensions.get( index );
+ }
+
+ /**
+ * Clears all accessor extensions registered with this manager
*/
- public int indexOfExtension( LifecycleExtension extension )
+ public void clearAccessorExtensions()
{
- return m_extensions.indexOf( extension );
+ m_accessorExtensions.clear();
}
/**
- * Clears all extensions registered with this manager
+ * Clears all creator extensions registered with this manager
*/
- public void clearExtensions()
+ public void clearCreatorExtensions()
{
- m_extensions.clear();
+ m_creatorExtensions.clear();
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>