sgoeschl 2005/04/26 05:31:20
Modified: yaafi/src/java/org/apache/fulcrum/yaafi/framework/factory
ServiceContainerConfiguration.java
yaafi/src/java/org/apache/fulcrum/yaafi/framework/container
ServiceContainerImpl.java
Log:
Using directory names instead of files
Revision Changes Path
1.3 +40 -9
jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerConfiguration.java
Index: ServiceContainerConfiguration.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerConfiguration.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServiceContainerConfiguration.java 1 Mar 2005 10:44:36 -0000
1.2
+++ ServiceContainerConfiguration.java 26 Apr 2005 12:31:20 -0000
1.3
@@ -83,10 +83,10 @@
private Logger logger;
/** the application directory */
- private File applicationRootDir;
+ private String applicationRootDir;
/** the temporary directory */
- private File tempRootDir;
+ private String tempRootDir;
/** the class loader passed in the Avalon Context */
private ClassLoader componentClassLoader;
@@ -110,8 +110,8 @@
this.parametersLocation =
ServiceConstants.COMPONENT_PARAMETERS_VALUE;
this.isParametersEncrypted = "false";
this.context = new DefaultContext();
- this.applicationRootDir = new File( new File("").getAbsolutePath() );
- this.tempRootDir = new File(
System.getProperty("java.io.tmpdir","."));
+ this.applicationRootDir = new File("").getAbsolutePath();
+ this.tempRootDir = System.getProperty("java.io.tmpdir",".");
this.componentClassLoader = this.getClass().getClassLoader();
}
@@ -372,6 +372,7 @@
public void setComponentConfigurationLocation(
String componentConfigurationLocation)
{
+
Validate.notNull(componentConfigurationLocation,"componentConfigurationLocation");
this.componentConfigurationLocation = componentConfigurationLocation;
}
@@ -459,6 +460,7 @@
*/
public void setParametersEncrypted(String isParametersEncrypted)
{
+ Validate.notEmpty(isParametersEncrypted,"isParametersEncrypted");
this.isParametersEncrypted = isParametersEncrypted;
}
@@ -499,15 +501,24 @@
*/
private File getApplicationRootDir()
{
- return applicationRootDir;
+ return new File(applicationRootDir);
}
/**
* @param applicationRootDir The applicationRootDir to set.
*/
- public void setApplicationRootDir(File applicationRootDir)
+ public void setApplicationRootDir(String applicationRootDir)
{
- this.applicationRootDir = applicationRootDir;
+ Validate.notNull(applicationRootDir, "applicationRootDir");
+
+ if( applicationRootDir.equals(".") )
+ {
+ this.applicationRootDir = new File("").getAbsolutePath();
+ }
+ else
+ {
+ this.applicationRootDir = new File( applicationRootDir
).getAbsolutePath();
+ }
}
/**
@@ -515,14 +526,15 @@
*/
private File getTempRootDir()
{
- return tempRootDir;
+ return
makeAbsoluteFile(this.getApplicationRootDir(),this.tempRootDir);
}
/**
* @param tempRootDir The tempRootDir to set.
*/
- public void setTempRootDir(File tempRootDir)
+ public void setTempRootDir(String tempRootDir)
{
+ Validate.notNull(tempRootDir, "tempRootDir");
this.tempRootDir = tempRootDir;
}
@@ -539,6 +551,7 @@
*/
public void setComponentClassLoader(ClassLoader componentClassLoader)
{
+ Validate.notNull(componentClassLoader, "componentClassLoader");
this.componentClassLoader = componentClassLoader;
}
@@ -652,4 +665,22 @@
throw new IOException(msg);
}
}
+
+ /**
+ * Determines the absolute file.
+ * @param baseDir the base directory
+ * @param fileName the filename
+ * @return the absolute path
+ */
+ private static File makeAbsoluteFile( File baseDir, String fileName )
+ {
+ File result = new File(fileName);
+
+ if( result.isAbsolute() == false )
+ {
+ result = new File( baseDir, fileName );
+ }
+
+ return result;
+ }
}
1.8 +46 -17
jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainerImpl.java
Index: ServiceContainerImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainerImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ServiceContainerImpl.java 9 Mar 2005 14:37:49 -0000 1.7
+++ ServiceContainerImpl.java 26 Apr 2005 12:31:20 -0000 1.8
@@ -32,6 +32,7 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.fulcrum.jce.crypto.CryptoStreamFactoryImpl;
@@ -258,12 +259,18 @@
"false" )
);
}
-
+
/**
- * Initializes the service container implementation.
- * @see
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ * @see
org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
+ */
+ public synchronized void parameterize(Parameters parameters) throws
ParameterException
+ {
+ this.parameters = parameters;
+ }
+
+ /**
+ * @see org.apache.avalon.framework.activity.Initializable#initialize()
*/
-
public synchronized void initialize() throws Exception
{
this.getLogger().debug( "YAAFI Service Framework is starting up");
@@ -331,7 +338,7 @@
// we are up and running
this.isDisposed = false;
- this.getLogger().debug( "Service Framework is up and running");
+ this.getLogger().info( "YAAFI Avalon Service Container is up and
running");
}
@@ -349,7 +356,7 @@
if( this.getLogger() != null )
{
- this.getLogger().info("Disposing all services");
+ this.getLogger().debug("Disposing all services");
}
// decommision all servcies
@@ -543,10 +550,36 @@
this.decommision(serviceComponent);
}
+ /**
+ * @see
org.apache.fulcrum.yaafi.framework.container.ServiceContainer#getParameters()
+ */
+ public Parameters getParameters()
+ {
+ return this.parameters;
+ }
+
/////////////////////////////////////////////////////////////////////////
// Service Implementation
/////////////////////////////////////////////////////////////////////////
+ private File makeAbsolutePath( String fileName )
+ {
+ return this.makeAbsolutePath( new File(fileName) );
+ }
+
+ private File makeAbsolutePath( File file )
+ {
+ File result = file;
+
+ if( result.isAbsolute() == false )
+ {
+ String temp = file.getPath() + "/" + file.getName();
+ result = new File( this.getApplicationRootDir(), temp );
+ }
+
+ return result;
+ }
+
private RoleConfigurationParser createRoleConfigurationParser()
{
return new RoleConfigurationParserImpl(
@@ -906,9 +939,11 @@
*/
private File setApplicationRootDir(File dir)
{
+ this.getLogger().debug( "Setting applicationRootDir to " +
dir.getAbsolutePath() );
+
Validate.notNull(dir,"applicationRootDir is <null>");
Validate.isTrue(dir.exists(),"applicationRootDir does not exist");
- this.getLogger().debug( "Setting applicationRootDir to " +
dir.getAbsolutePath() );
+
this.applicationRootDir = dir;
return this.applicationRootDir;
}
@@ -926,10 +961,12 @@
*/
private File setTempRootDir(File dir)
{
+ this.getLogger().debug( "Setting tempRootDir to " +
dir.getAbsolutePath() );
+
Validate.notNull(dir,"tempRootDir is <null>");
Validate.isTrue(dir.exists(),"tempRootDir does not exist");
Validate.isTrue(dir.canWrite(),"tempRootDir is not writeable");
- this.getLogger().debug( "Setting tempRootDir to " +
dir.getAbsolutePath() );
+
this.tempRootDir = dir;
return this.tempRootDir;
}
@@ -1058,15 +1095,7 @@
{
return context;
}
-
- /**
- * @return Returns the parameters.
- */
- private Parameters getParameters()
- {
- return parameters;
- }
-
+
private void waitForReconfiguration()
{
try
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]