donaldp 02/05/29 02:55:37
Modified: src/java/org/apache/avalon/phoenix/components/deployer
DefaultDeployer.java
src/java/org/apache/avalon/phoenix/components/deployer/installer
Installer.java
Log:
Caught some more cases where work directory was left around even if
application did not deploy correctly.
Revision Changes Path
1.34 +26 -8
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java
Index: DefaultDeployer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- DefaultDeployer.java 20 May 2002 11:46:33 -0000 1.33
+++ DefaultDeployer.java 29 May 2002 09:55:37 -0000 1.34
@@ -16,8 +16,8 @@
import java.util.Set;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
@@ -27,6 +27,9 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.phoenix.components.deployer.installer.Installation;
+import org.apache.avalon.phoenix.components.deployer.installer.Installer;
+import
org.apache.avalon.phoenix.components.deployer.installer.InstallationException;
import org.apache.avalon.phoenix.interfaces.Application;
import org.apache.avalon.phoenix.interfaces.ClassLoaderManager;
import org.apache.avalon.phoenix.interfaces.ConfigurationRepository;
@@ -41,8 +44,6 @@
import org.apache.avalon.phoenix.tools.assembler.Assembler;
import org.apache.avalon.phoenix.tools.assembler.AssemblyException;
import org.apache.avalon.phoenix.tools.configuration.ConfigurationBuilder;
-import org.apache.avalon.phoenix.components.deployer.installer.Installation;
-import org.apache.avalon.phoenix.components.deployer.installer.Installer;
import org.apache.avalon.phoenix.tools.verifier.SarVerifier;
import org.apache.log.Hierarchy;
@@ -156,7 +157,7 @@
{
final Set set = m_installations.keySet();
final String[] applications =
- (String[])set.toArray( new String[set.size() ] );
+ (String[])set.toArray( new String[ set.size() ] );
for( int i = 0; i < applications.length; i++ )
{
final String name = applications[ i ];
@@ -168,8 +169,8 @@
{
final String message =
REZ.getString( "deploy.undeploy-indispose.error",
- name,
- de.getMessage() );
+ name,
+ de.getMessage() );
getLogger().error( message, de );
}
}
@@ -258,11 +259,13 @@
name );
throw new DeploymentException( message );
}
+
+ Installation installation = null;
+ boolean success = false;
try
{
//m_baseWorkDirectory
- final Installation installation =
- m_installer.install( name, location );
+ installation = m_installer.install( name, location );
final Configuration config = getConfigurationFor(
installation.getConfig() );
final Configuration environment = getConfigurationFor(
installation.getEnvironment() );
@@ -299,6 +302,7 @@
metaData.getName(),
installation.getClassPath() );
getLogger().debug( message );
+ success = true;
}
catch( final DeploymentException de )
{
@@ -312,6 +316,20 @@
{
//From classloaderManager/kernel
throw new DeploymentException( e.getMessage(), e );
+ }
+ finally
+ {
+ if( !success && null != installation )
+ {
+ try
+ {
+ m_installer.uninstall( installation );
+ }
+ catch( final InstallationException ie )
+ {
+ getLogger().error( ie.getMessage(), ie );
+ }
+ }
}
}
1.9 +43 -22
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/installer/Installer.java
Index: Installer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/installer/Installer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Installer.java 15 May 2002 13:00:57 -0000 1.8
+++ Installer.java 29 May 2002 09:55:37 -0000 1.9
@@ -33,7 +33,7 @@
* and installing it as appropriate.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.8 $ $Date: 2002/05/15 13:00:57 $
+ * @version $Revision: 1.9 $ $Date: 2002/05/29 09:55:37 $
*/
public class Installer
extends AbstractLogEnabled
@@ -129,15 +129,25 @@
}
}
+ deleteWorkDir( installation.getWorkDirectory() );
+ }
+
+ /**
+ * Utility method to delete the working directory.
+ *
+ * @param dir the working directory
+ */
+ private void deleteWorkDir( final File dir )
+ {
try
{
- FileUtil.deleteDirectory( installation.getWorkDirectory() );
+ FileUtil.deleteDirectory( dir );
}
catch( final IOException ioe )
{
final String message =
REZ.getString( "nodelete-workdir.error",
- installation.getWorkDirectory(),
+ dir,
ioe.getMessage() );
getLogger().warn( message, ioe );
}
@@ -249,26 +259,37 @@
final File workDir =
getRelativeWorkDir( m_baseWorkDirectory, name );
+ boolean success = false;
+ try
+ {
+ expandZipFile( zipFile, directory, workDir, jars, digests, url );
- expandZipFile( zipFile, directory, workDir, jars, digests, url );
-
- //Retrieve name of environment file
- //need to check existence to support backwards compatability
- final File envFile = new File( directory, FS_ENV_XML );
-
- //Prepare and create Installation
- final String[] classPath =
- (String[])jars.toArray( new String[ jars.size() ] );
-
- final String assembly = getURLAsString( new File( directory,
FS_ASSEMBLY_XML ) );
- final String config = getURLAsString( new File( directory,
FS_CONFIG_XML ) );
- final String environment = getURLAsString( envFile );
- final FileDigest[] fileDigests = (FileDigest[])digests.toArray( new
FileDigest[ 0 ] );
- final long timestamp = System.currentTimeMillis();
-
- return new Installation( file, directory, workDir,
- config, assembly, environment,
- classPath, fileDigests, timestamp );
+ //Retrieve name of environment file
+ //need to check existence to support backwards compatability
+ final File envFile = new File( directory, FS_ENV_XML );
+
+ //Prepare and create Installation
+ final String[] classPath =
+ (String[])jars.toArray( new String[ jars.size() ] );
+
+ final String assembly = getURLAsString( new File( directory,
FS_ASSEMBLY_XML ) );
+ final String config = getURLAsString( new File( directory,
FS_CONFIG_XML ) );
+ final String environment = getURLAsString( envFile );
+ final FileDigest[] fileDigests = (FileDigest[])digests.toArray(
new FileDigest[ 0 ] );
+ final long timestamp = System.currentTimeMillis();
+
+ success = true;
+ return new Installation( file, directory, workDir,
+ config, assembly, environment,
+ classPath, fileDigests, timestamp );
+ }
+ finally
+ {
+ if( !success )
+ {
+ deleteWorkDir( workDir );
+ }
+ }
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>