You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by sg...@apache.org on 2005/02/16 12:26:14 UTC
cvs commit: jakarta-turbine-fulcrum/yaafi/src/test/org/apache/fulcrum/yaafi/testcontainer Container.java
sgoeschl 2005/02/16 03:26:14
Modified: yaafi/src/test/org/apache/fulcrum/yaafi/testcontainer
Container.java
Log:
Synchronizing the current development mit Fulcrum YAAFI
Revision Changes Path
1.4 +28 -50 jakarta-turbine-fulcrum/yaafi/src/test/org/apache/fulcrum/yaafi/testcontainer/Container.java
Index: Container.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/yaafi/src/test/org/apache/fulcrum/yaafi/testcontainer/Container.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Container.java 20 Jan 2005 15:47:31 -0000 1.3
+++ Container.java 16 Feb 2005 11:26:14 -0000 1.4
@@ -22,15 +22,12 @@
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.ConsoleLogger;
-import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.fulcrum.yaafi.framework.container.ServiceContainer;
-import org.apache.fulcrum.yaafi.framework.container.ServiceContainerImpl;
-import org.apache.fulcrum.yaafi.framework.factory.ServiceManagerFactory;
-import org.apache.fulcrum.yaafi.service.servicemanager.ServiceManagerService;
+import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerConfiguration;
+import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerFactory;
/**
@@ -41,27 +38,11 @@
*/
public class Container extends AbstractLogEnabled implements Initializable, Disposable
{
- /** Key used in the context for defining the application root */
- public static String COMPONENT_APP_ROOT = "componentAppRoot";
-
- /** Alternate Merlin Friendly Key used in the context for defining the application root */
- public static String URN_AVALON_HOME = "urn:avalon:home";
-
- /** Alternate Merlin Friendly Key used in the context for defining the application root */
- public static String URN_AVALON_TEMP = "urn:avalon:temp";
-
- /** Component manager */
- private ServiceContainer manager;
-
- /** Configuration file name */
- private String configFileName;
-
- /** Role file name */
- private String roleFileName;
-
- /** Parameters file name */
- private String parametersFileName;
+ /** The YAAFI configuration */
+ private ServiceContainerConfiguration config;
+ /** Component manager */
+ private ServiceContainer manager;
/**
* Constructor
@@ -69,8 +50,8 @@
public Container()
{
// org.apache.log4j.BasicConfigurator.configure();
- this.manager = new ServiceContainerImpl();
this.enableLogging( new ConsoleLogger( ConsoleLogger.LEVEL_DEBUG ) );
+ this.config = new ServiceContainerConfiguration();
}
/**
@@ -79,14 +60,18 @@
* @param configFileName Name of the component configuration file
* @param roleFileName Name of the role configuration file
*/
- public void startup(String configFileName, String roleFileName, String parametersFileName )
+ public void startup(
+ String configFileName,
+ String roleFileName,
+ String parametersFileName )
{
getLogger().debug("Starting container...");
-
- this.configFileName = configFileName;
- this.roleFileName = roleFileName;
- this.parametersFileName = parametersFileName;
-
+
+ this.config.setComponentConfigurationLocation( configFileName );
+ this.config.setComponentRolesLocation( roleFileName );
+ this.config.setParametersLocation( parametersFileName );
+ this.config.setLogger( new ConsoleLogger( ConsoleLogger.LEVEL_DEBUG ) );
+
File configFile = new File(configFileName);
if (!configFile.exists())
@@ -110,6 +95,7 @@
// -------------------------------------------------------------
// Avalon lifecycle interfaces
// -------------------------------------------------------------
+
/**
* Initializes the container
*
@@ -117,19 +103,8 @@
*/
public void initialize() throws Exception
{
- DefaultContext context = new DefaultContext();
- String absolutePath = new File("").getAbsolutePath();
- context.put(COMPONENT_APP_ROOT, absolutePath);
- context.put(URN_AVALON_HOME, new File( new File("").getAbsolutePath() ) );
-
- Logger logger = new ConsoleLogger( ConsoleLogger.LEVEL_DEBUG );
-
- this.manager = ServiceManagerFactory.create(
- logger,
- this.roleFileName,
- this.configFileName,
- this.parametersFileName,
- context
+ this.manager = ServiceContainerFactory.create(
+ this.config
);
}
@@ -142,6 +117,7 @@
this.manager.dispose();
getLogger().info("YaffiContainer has been disposed.");
}
+
/**
* Returns an instance of the named component
*
@@ -152,7 +128,7 @@
{
try
{
- return ServiceManagerService.getServiceManager().lookup(roleName);
+ return this.manager.lookup(roleName);
}
catch( Exception e )
{
@@ -160,6 +136,7 @@
throw new ComponentException(roleName,msg,e);
}
}
+
/**
* Releases the component implementing the Component interface. This
* interface is depracted but still around in Fulcrum
@@ -168,8 +145,9 @@
*/
public void release(Component component)
{
- ServiceManagerService.getServiceManager().release(component);
+ this.manager.release(component);
}
+
/**
* Releases the component
*
@@ -177,9 +155,10 @@
*/
public void release(Object component)
{
- ServiceManagerService.getServiceManager().release(component);
+ //ServiceManagerService.getServiceManager().release(component);
+ this.manager.release(component);
}
-
+
/**
* Decommision the service
* @param name the name of the service
@@ -192,5 +171,4 @@
this.manager.decommision( name );
}
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org