CVS: plexus-container-new/src/java/org/apache/plexus/lifecycle LifecycleHandlerFactory.java,1.1,1.2

[email protected] Sun, 27 Apr 2003 15:20:06 -0500
Newsgroups gmane.comp.java.plexus.devel
Message-ID <[email protected]>
Update of /cvsroot/plexus/plexus-container-new/src/java/org/apache/plexus/lifecycle
In directory eng.werken.com:/tmp/cvs-serv9114/src/java/org/apache/plexus/lifecycle

Modified Files:
	LifecycleHandlerFactory.java 
Log Message:
o Added an abstract factory that will be the basis for allowing pluggable
  base entities in Plexus. Currently the logger manager and lifecycle handler
  are pluggable.


Index: LifecycleHandlerFactory.java
===================================================================
RCS file: /cvsroot/plexus/plexus-container-new/src/java/org/apache/plexus/lifecycle/LifecycleHandlerFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- LifecycleHandlerFactory.java	25 Apr 2003 19:22:04 -0000	1.1
+++ LifecycleHandlerFactory.java	27 Apr 2003 20:20:03 -0000	1.2
@@ -2,30 +2,32 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.plexus.lifecycle.phase.Phase;
+import org.apache.plexus.factory.AbstractPlexusFactory;
 
 public class LifecycleHandlerFactory
+    extends AbstractPlexusFactory
 {
     public static LifecycleHandler create( Configuration configuration, ClassLoader classLoader )
         throws Exception
     {
-        Class c;
-
-        c = classLoader.loadClass( configuration.getChild( "implementation" ).getValue() );
-        LifecycleHandler lh = (LifecycleHandler) c.newInstance();
+        LifecycleHandler lh =
+            (LifecycleHandler) getInstance( configuration.getChild( "implementation" ).getValue(),
+                                            classLoader );
 
         Configuration[] a = configuration.getChild( "start-segment" ).getChildren( "phase" );
         for ( int i = 0; i < a.length; i++ )
         {
-            c = classLoader.loadClass( a[i].getAttribute( "implementation" ) );
-            lh.addBeginSegmentPhase( (Phase) c.newInstance()  );
+            lh.addBeginSegmentPhase(
+                (Phase) getInstance( a[i].getAttribute( "implementation" ), classLoader) );
         }
 
         Configuration[] b = configuration.getChild( "end-segment" ).getChildren( "phase" );
         for ( int i = 0; i < b.length; i++ )
         {
-            c = classLoader.loadClass( b[i].getAttribute( "implementation" ) );
-            lh.addEndSegmentPhase( (Phase) c.newInstance()  );
+            lh.addEndSegmentPhase(
+                (Phase) getInstance( b[i].getAttribute( "implementation" ), classLoader) );
         }
+
         return lh;
     }
 }