Hi, Attached is a patch that allows installation of applications from file structures other then packaged sar-file. Plus I've included _prototype_ of an installer that installs applications directly from Eclipse workspace. How to apply, install and test
1. Apply attached patch and rebuild phoenix
2. I assume that you are using eclipse 2.0 and your workspace is
location is c:\temp\eclipse.workspace
3. Start eclipse, goto Window->Preferences->Java->Classpath_variables
and add new variable PHONIX_HOME and point to your phoenix directory. It
is used to locate phoenix libraries.
4. In eclipse, create two java projects phoenix-demo-app and
phoenix-demo-blocks. Expand attached phoenix-demo.zip somewhere and
inport projects from corresponding directories (i.e. phoenix-demo-app
from zip:phoenix-demo-app and phoenix-demo-blocks from
zip:phoenix-demo-blocks). It is important that both project were located
inside eclipse workspace.
5. Copy attached eclipse-deployer.jar into $PHOENIX_HOME/bin/lib
6. Edit $PHOENIX_HOME/conf/kernel.xml, replace Installer with
<component role="org.apache.avalon.phoenix.interfaces.Installer"
class="com.thinkdynamics.phoenix.components.installer.EclipseInstaller"
logger="installer">
<eclipse-workspace>file:///c:/temp/eclipse.workspace/</eclipse-workspace>
</component>
7. Start phoenix with
run --application=c:\temp\eclipse.workspace\phoenix-demo-app
A word of disclaimer: eclipse-deployer.jar is a prototype so do not take
it too seriously. It is neither robust, feature complete implementation
nor an example of qaulity java code.
--
Igor Fedorenko
Think smart. Think automated. Think Dynamics.
www.thinkdynamics.com
Index: conf/kernel.xml
===================================================================
RCS file: /home/cvspublic/jakarta-avalon-phoenix/src/conf/kernel.xml,v
retrieving revision 1.20
diff -u -r1.20 kernel.xml
--- conf/kernel.xml 10 Aug 2002 20:12:07 -0000 1.20
+++ conf/kernel.xml 14 Aug 2002 21:59:33 -0000
@@ -4,6 +4,10 @@
<embeddor role="org.apache.avalon.phoenix.interfaces.Embeddor"
class="org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor">
+ <component role="org.apache.avalon.phoenix.interfaces.Installer"
+
+class="org.apache.avalon.phoenix.components.deployer.installer.DefaultInstaller"
+ logger="installer"/>
+
<component role="org.apache.avalon.phoenix.interfaces.Deployer"
class="org.apache.avalon.phoenix.components.deployer.DefaultDeployer"
logger="deployer"/>
Index: java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java
===================================================================
RCS file:
/home/cvspublic/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java,v
retrieving revision 1.50
diff -u -r1.50 DefaultDeployer.java
--- java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java 6 Aug
2002 11:57:40 -0000 1.50
+++ java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java 14 Aug
+2002 21:59:33 -0000
@@ -29,9 +29,6 @@
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.InstallationException;
-import org.apache.avalon.phoenix.components.deployer.installer.Installer;
import org.apache.avalon.phoenix.interfaces.Application;
import org.apache.avalon.phoenix.interfaces.ClassLoaderManager;
import org.apache.avalon.phoenix.interfaces.ConfigurationRepository;
@@ -39,6 +36,9 @@
import org.apache.avalon.phoenix.interfaces.Deployer;
import org.apache.avalon.phoenix.interfaces.DeployerMBean;
import org.apache.avalon.phoenix.interfaces.DeploymentException;
+import org.apache.avalon.phoenix.interfaces.Installation;
+import org.apache.avalon.phoenix.interfaces.InstallationException;
+import org.apache.avalon.phoenix.interfaces.Installer;
import org.apache.avalon.phoenix.interfaces.Kernel;
import org.apache.avalon.phoenix.interfaces.LogManager;
import org.apache.avalon.phoenix.metadata.BlockListenerMetaData;
@@ -67,13 +67,13 @@
private final Assembler m_assembler = new Assembler();
private final SarVerifier m_verifier = new SarVerifier();
- private final Installer m_installer = new Installer();
private final Map m_installations = new Hashtable();
private LogManager m_logManager;
private Kernel m_kernel;
private ConfigurationRepository m_repository;
private ClassLoaderManager m_classLoaderManager;
private ConfigurationValidator m_validator;
+ private Installer m_installer;
/**
* The directory which is used as the base for
@@ -142,6 +142,7 @@
lookup( ClassLoaderManager.ROLE );
m_logManager = (LogManager)serviceManager.lookup( LogManager.ROLE );
m_validator = (ConfigurationValidator)serviceManager.lookup(
ConfigurationValidator.ROLE );
+ m_installer = (Installer)serviceManager.lookup( Installer.ROLE );
}
public void initialize()
Index:
java/org/apache/avalon/phoenix/components/deployer/installer/DefaultInstaller.java
===================================================================
RCS file:
java/org/apache/avalon/phoenix/components/deployer/installer/DefaultInstaller.java
diff -N
java/org/apache/avalon/phoenix/components/deployer/installer/DefaultInstaller.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/org/apache/avalon/phoenix/components/deployer/installer/DefaultInstaller.java
+ 14 Aug 2002 21:59:33 -0000
@@ -0,0 +1,628 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.avalon.phoenix.components.deployer.installer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.zip.CRC32;
+import java.util.zip.CheckedInputStream;
+import java.util.zip.Checksum;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.avalon.excalibur.io.FileUtil;
+import org.apache.avalon.excalibur.io.IOUtil;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.phoenix.interfaces.*;
+import org.apache.avalon.phoenix.interfaces.Installer;
+
+/**
+ * An Installer is responsible for taking a URL for Sar
+ * and installing it as appropriate.
+ *
+ * @author <a href="mailto:peter at apache.org">Peter Donald</a>
+ * @version $Revision: 1.13 $ $Date: 2002/08/06 11:57:40 $
+ */
+public class DefaultInstaller
+ extends AbstractLogEnabled
+ implements Installer
+{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultInstaller.class );
+
+ private static final String META_INF = "META-INF";
+
+ private static final String SAR_INF = "SAR-INF";
+
+ private static final String LIB = "SAR-INF/lib";
+
+ private static final String CLASSES = "SAR-INF/classes/";
+
+ //The names on the native filesystem
+ private static final String FS_CONFIG_XML = "SAR-INF" + File.separator +
+"config.xml";
+
+ private static final String FS_ASSEMBLY_XML = "SAR-INF" + File.separator +
+"assembly.xml";
+
+ private static final String FS_ENV_XML = "SAR-INF" + File.separator +
+"environment.xml";
+
+ private static final String FS_CLASSES =
+ "SAR-INF" + File.separator + "classes" + File.separator;
+
+ /**
+ * Base directory in which to install extracted application.
+ */
+ private File m_baseDirectory;
+
+ /**
+ * Base directory in which to install temporary/work files.
+ */
+ private File m_baseWorkDirectory;
+
+ /**
+ * Set the baseDirectory in which to install applications.
+ *
+ * @param baseDirectory the baseDirectory in which to install applications.
+ */
+ public void setBaseDirectory( File baseDirectory )
+ {
+ m_baseDirectory = baseDirectory;
+ }
+
+ /**
+ * Set the baseDirectory in which to install applications temporary Data.
+ *
+ * @param baseWorkDirectory the baseDirectory in which to install applications
+temporary Data.
+ */
+ public void setBaseWorkDirectory( File baseWorkDirectory )
+ {
+ m_baseWorkDirectory = baseWorkDirectory;
+ }
+
+ /**
+ * Uninstall the Sar designated installation.
+ *
+ * @param installation the installation
+ * @throws InstallationException if an error occurs
+ */
+ public void uninstall( final Installation installation )
+ throws InstallationException
+ {
+ final FileDigest[] infos = installation.getFileDigests();
+ final Checksum checksum = new CRC32();
+
+ if( infos != null )
+ {
+ for( int i = 0; i < infos.length; i++ )
+ {
+ final File file = infos[ i ].getFile();
+ final File parent = file.getParentFile();
+
+ final String message = REZ.getString( "skip-removal", file );
+
+ if( file.exists() )
+ {
+ if( file.lastModified() <= installation.getTimestamp() )
+ {
+ getLogger().debug( message );
+ continue;
+ }
+
+ checksum( file, checksum );
+
+ if( checksum.getValue() != infos[ i ].getChecksum() )
+ {
+ getLogger().debug( message );
+ continue;
+ }
+
+ file.delete();
+ if( 0 == parent.list().length )
+ {
+ parent.delete();
+ }
+ }
+ }
+ }
+
+ deleteWorkDir( installation.getWorkDirectory() );
+ }
+
+ /**
+ * Utility method to delete the working directory.
+ *
+ * @param dir the working directory
+ */
+ private void deleteWorkDir( final File dir )
+ {
+ try
+ {
+ FileUtil.deleteDirectory( dir );
+ }
+ catch( final IOException ioe )
+ {
+ try
+ {
+ //If can't delete them now (damn windows locking!)
+ //then schedule them for deletion when JVM exits
+ FileUtil.forceDeleteOnExit( dir );
+ }
+ catch( final IOException ioe2 )
+ {
+ //ignore
+ }
+ final String message =
+ REZ.getString( "nodelete-workdir.error",
+ dir,
+ ioe.getMessage() );
+ getLogger().warn( message, ioe );
+ }
+ }
+
+ /**
+ * Install the Sar designated by url.
+ *
+ * @param url the url of instalation
+ * @throws InstallationException if an error occurs
+ */
+ public Installation install( final String name, final URL url )
+ throws InstallationException
+ {
+ lock();
+ try
+ {
+ final String notice = REZ.getString( "installing-sar", url );
+ getLogger().info( notice );
+
+ final File file = getFileFor( url );
+ if( file.isDirectory() )
+ {
+ final String message =
+ REZ.getString( "install.sar-isa-dir.error", name, url );
+ throw new InstallationException( message );
+ }
+
+ //Get Zipfile representing .sar file
+ final ZipFile zipFile = new ZipFile( file );
+ return install( name, url, file, zipFile );
+ }
+ catch( final IOException ioe )
+ {
+ final String message = REZ.getString( "bad-zip-file", url );
+ throw new InstallationException( message, ioe );
+ }
+ finally
+ {
+ unlock();
+ }
+ }
+
+ /**
+ * Utility method to compute the checksum for a given file.
+ * @param file the computed file.
+ * @param checksum the checksum algorithm.
+ */
+ private void checksum( final File file, final Checksum checksum )
+ {
+ checksum.reset();
+
+ InputStream input = null;
+ try
+ {
+ input = new CheckedInputStream( new FileInputStream( file ), checksum );
+ IOUtil.toByteArray( input );
+ }
+ catch( final IOException ioe )
+ {
+ final String message = REZ.getString( "checksum-failure", file );
+ getLogger().warn( message );
+ }
+ finally
+ {
+ IOUtil.shutdownStream( input );
+ }
+ }
+
+ /**
+ * Utility method to lock repository to disallow other installers to access it.
+ * Currently a no-op.
+ */
+ private void lock()
+ {
+ }
+
+ /**
+ * Utility method to unlock repository to allow other installers to access it.
+ * Currently a no-op.
+ */
+ private void unlock()
+ {
+ }
+
+ /**
+ * Install a new style sar.
+ *
+ * @param url the url designator of sar
+ * @param file the file of sar
+ * @param zipFile the ZipFile representing sar
+ * @return the Installation object
+ */
+ private Installation install( final String name,
+ final URL url,
+ final File file,
+ final ZipFile zipFile )
+ throws InstallationException
+ {
+ final File directory =
+ new File( m_baseDirectory, name ).getAbsoluteFile();
+
+ //Question: Should we be making sure that
+ //this directory is created?
+ directory.mkdirs();
+
+ final ArrayList digests = new ArrayList();
+ final ArrayList jars = new ArrayList();
+
+ final File workDir =
+ getRelativeWorkDir( m_baseWorkDirectory, name );
+ boolean success = false;
+ try
+ {
+ 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();
+
+ success = true;
+ return new Installation( file, directory, workDir,
+ config, assembly, environment,
+ classPath, fileDigests, timestamp );
+ }
+ finally
+ {
+ if( !success )
+ {
+ deleteWorkDir( workDir );
+ }
+ }
+ }
+
+ /**
+ * Expand the specified Zip file.
+ *
+ * @param zipFile the zip file
+ * @param directory the directory where to extract non-jar,
+ * non-classes files
+ * @param workDir the directory to extract classes/jar files
+ * @param classpath the list to add classpath entries to
+ * @param digests the list to add file digests to
+ * @param url the url of deployment (for error reporting purposes)
+ * @throws InstallationException if an error occurs extracting files
+ */
+ private void expandZipFile( final ZipFile zipFile,
+ final File directory,
+ final File workDir,
+ final ArrayList classpath,
+ final ArrayList digests,
+ final URL url )
+ throws InstallationException
+ {
+ final Enumeration entries = zipFile.entries();
+ while( entries.hasMoreElements() )
+ {
+ final ZipEntry entry = (ZipEntry)entries.nextElement();
+ final String name = fixName( entry.getName() );
+
+ if( name.startsWith( META_INF ) )
+ {
+ continue;
+ }
+
+ if( handleDirs( entry, name, directory ) )
+ {
+ continue;
+ }
+
+ if( handleClasses( zipFile,
+ entry,
+ name,
+ workDir,
+ classpath ) )
+ {
+ continue;
+ }
+
+ if( handleJars( zipFile, entry, name, workDir, classpath ) )
+ {
+ continue;
+ }
+
+ //Expand the file if necesasry and issue a warning
+ //if there is a file in the way
+ final File destination = new File( directory, name );
+ handleFile( zipFile, entry, destination, digests, url );
+ }
+ }
+
+ /**
+ * Handle the extraction of normal resources
+ * from zip file/
+ */
+ private void handleFile( final ZipFile zipFile,
+ final ZipEntry entry,
+ final File destination,
+ final ArrayList digests,
+ final URL url )
+ throws InstallationException
+ {
+ if( !destination.exists() )
+ {
+ expandFile( zipFile, entry, destination );
+ calculateDigest( entry, destination, digests );
+ }
+ else
+ {
+ final String message =
+ REZ.getString( "file-in-the-way",
+ url,
+ entry.getName(),
+ destination );
+ getLogger().warn( message );
+ }
+ }
+
+ /**
+ * Handle extraction of jars.
+ *
+ * @param zipFile the zipFIle to exrtact from
+ * @param entry the entry to extract
+ * @param name the normalized name of entry
+ * @param workDir the working directory to extract to
+ * @param jars the classpath list
+ * @return true if handled, false otherwise
+ */
+ private boolean handleJars( final ZipFile zipFile,
+ final ZipEntry entry,
+ final String name,
+ final File workDir,
+ final ArrayList jars )
+ throws InstallationException
+ {
+ if( name.startsWith( LIB )
+ && name.endsWith( ".jar" )
+ && LIB.length() == name.lastIndexOf( "/" ) )
+ {
+ final File jar = new File( workDir, name );
+ jars.add( getURLAsString( jar ) );
+
+ final File file = new File( workDir, name );
+ expandFile( zipFile, entry, file );
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Handle extraction of jars.
+ *
+ * @param zipFile the zipFIle to exrtact from
+ * @param entry the entry to extract
+ * @param name the normalized name of entry
+ * @param workDir the working directory to extract to
+ * @param jars the classpath list
+ * @return true if handled, false otherwise
+ */
+ private boolean handleClasses( final ZipFile zipFile,
+ final ZipEntry entry,
+ final String name,
+ final File workDir,
+ final ArrayList jars )
+ throws InstallationException
+ {
+ if( name.startsWith( CLASSES ) )
+ {
+ final File classDir = new File( workDir, FS_CLASSES );
+ if( !classDir.exists() )
+ {
+ jars.add( getURLAsString( classDir ) );
+ final File file = new File( workDir, name );
+ expandFile( zipFile, entry, file );
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Handle expansion of dirs in the zipfile.
+ *
+ * @param entry the current ZipEntry
+ * @param name the name of entry
+ * @param directory the base directory extraacting to
+ * @return true if handled, false otherwise
+ */
+ private boolean handleDirs( final ZipEntry entry,
+ final String name,
+ final File directory )
+ {
+ if( entry.isDirectory() )
+ {
+ if( !name.startsWith( SAR_INF ) )
+ {
+ final File newDir =
+ new File( directory, name );
+ newDir.mkdirs();
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Create working directory inside baseWorkDir
+ * for specified application.
+ *
+ * @param baseWorkDir the base workDir for all apps
+ * @param name the name of the application
+ * @return the working directory for app
+ */
+ private File getRelativeWorkDir( final File baseWorkDir,
+ final String name )
+ {
+ final String filename =
+ name + "-" + System.currentTimeMillis();
+ return new File( baseWorkDir, filename );
+ }
+
+ /**
+ * Fix the specified name so that it does not start
+ * with a "/" character.
+ *
+ * @param name the name to fix
+ * @return the name stripped of initial "/" if necessary
+ */
+ private String fixName( final String name )
+ {
+ if( name.startsWith( "/" ) )
+ {
+ return name.substring( 1 );
+ }
+ else
+ {
+ return name;
+ }
+ }
+
+ /**
+ * Get File object for URL.
+ * Currently it assumes that URL is a file URL but in the
+ * future it will allow downloading of remote URLs thus enabling
+ * a deploy from anywhere functionality.
+ *
+ * @param url the url of deployment
+ * @return the File for deployment
+ * @throws InstallationException if an error occurs
+ */
+ private File getFileFor( final URL url )
+ throws InstallationException
+ {
+ if( !url.getProtocol().equals( "file" ) )
+ {
+ final String message = REZ.getString( "install-nonlocal", url );
+ throw new InstallationException( message );
+ }
+
+ File file = new File( url.getFile() );
+ file = file.getAbsoluteFile();
+
+ if( !file.exists() )
+ {
+ final String message = REZ.getString( "install-nourl", file );
+ throw new InstallationException( message );
+ }
+
+ return file;
+ }
+
+ /**
+ * Calculate digest for specific entry.
+ *
+ * @param entry the entry
+ * @param file the extracted file
+ * @param digests the list of digests already
+ * calculated
+ */
+ private void calculateDigest( final ZipEntry entry,
+ final File file,
+ final ArrayList digests )
+ {
+ final long checksum = entry.getCrc();
+ digests.add( new FileDigest( file, checksum ) );
+ }
+
+ /**
+ * Expand a single zipEntry to a file.
+ */
+ private void expandFile( final ZipFile zipFile,
+ final ZipEntry entry,
+ final File file )
+ throws InstallationException
+ {
+ InputStream input = null;
+ OutputStream output = null;
+
+ try
+ {
+ file.getParentFile().mkdirs();
+ output = new FileOutputStream( file );
+ input = zipFile.getInputStream( entry );
+ IOUtil.copy( input, output );
+ }
+ catch( final IOException ioe )
+ {
+ final String message =
+ REZ.getString( "failed-to-expand",
+ entry.getName(),
+ file,
+ ioe.getMessage() );
+ throw new InstallationException( message, ioe );
+ }
+ finally
+ {
+ IOUtil.shutdownStream( input );
+ IOUtil.shutdownStream( output );
+ }
+ }
+
+ /**
+ * Utility method to extract URL from file in safe manner.
+ *
+ * @param file the file
+ * @return the URL representation of file
+ */
+ private String getURLAsString( final File file )
+ {
+ try
+ {
+ return file.toURL().toExternalForm();
+ }
+ catch( final MalformedURLException mue )
+ {
+ return null;
+ //should never occur
+ }
+ }
+}
Index: java/org/apache/avalon/phoenix/components/deployer/installer/FileDigest.java
===================================================================
RCS file: java/org/apache/avalon/phoenix/components/deployer/installer/FileDigest.java
diff -N java/org/apache/avalon/phoenix/components/deployer/installer/FileDigest.java
--- java/org/apache/avalon/phoenix/components/deployer/installer/FileDigest.java
26 Jul 2002 09:49:20 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-package org.apache.avalon.phoenix.components.deployer.installer;
-
-import java.io.File;
-
-/**
- * FileDigest holds file deployment information. Information
- * used to verify if file was modified since deployment.
- *
- * @version $Revision: 1.2 $ $Date: 2002/07/26 09:49:20 $
- */
-public class FileDigest
-{
- private final File m_file;
-
- private final long m_checksum;
-
- /** Create a new FileDigest object.
- *
- * @param file the file.
- * @param checksum the checksum value of the file.
- */
- public FileDigest( final File file, final long checksum )
- {
- m_file = file;
- m_checksum = checksum;
- }
-
- /** Retrieve the file.
- *
- * @return the file.
- */
- public File getFile()
- {
- return m_file;
- }
-
- /** Retrieve the checksum calculated at deployment time.
- *
- * @return the checksum value.
- */
- public long getChecksum()
- {
- return m_checksum;
- }
-}
-
Index: java/org/apache/avalon/phoenix/components/deployer/installer/Installation.java
===================================================================
RCS file:
java/org/apache/avalon/phoenix/components/deployer/installer/Installation.java
diff -N java/org/apache/avalon/phoenix/components/deployer/installer/Installation.java
--- java/org/apache/avalon/phoenix/components/deployer/installer/Installation.java
6 Aug 2002 11:57:40 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-package org.apache.avalon.phoenix.components.deployer.installer;
-
-import java.io.File;
-
-/**
- * Descriptor for installation.
- * This descriptor contains all the information relating to
- * installed application. In particular it locates all the
- * jars in Classpath, config files and installation directory.
- *
- * @author <a href="mailto:peter at apache.org">Peter Donald</a>
- * @version $Revision: 1.2 $ $Date: 2002/08/06 11:57:40 $
- */
-public final class Installation
-{
- ///The source of installation (usually a directory in .sar format or a .sar file)
- private final File m_source;
-
- ///Directory in which application is installed
- private final File m_directory;
-
- ///Directory in which application temporary/work data is stored
- private final File m_workDirectory;
-
- ///URL to block configuration data
- private final String m_config;
-
- ///URL to assembly data
- private final String m_assembly;
-
- ///URL to application configuration data
- private final String m_environment;
-
- ///ClassPath for application
- private final String[] m_classPath;
-
- ///Info for expanded files
- private final FileDigest[] m_digests;
-
- ///Installation timestamp
- private final long m_timestamp;
-
- public Installation( final File source,
- final File directory,
- final File workDirectory,
- final String config,
- final String assembly,
- final String environment,
- final String[] classPath,
- final FileDigest[] digests,
- final long timestamp )
- {
- m_source = source;
- m_directory = directory;
- m_workDirectory = workDirectory;
- m_config = config;
- m_assembly = assembly;
- m_environment = environment;
- m_classPath = classPath;
- m_digests = digests;
- m_timestamp = timestamp;
- }
-
- /**
- * Get the source of application. (Usually a
- * directory in .sar format or a .sar)
- *
- * @return the source of application
- */
- public File getSource()
- {
- return m_source;
- }
-
- /**
- * Get directory application is installed into.
- *
- * @return the applications base directory
- */
- public File getDirectory()
- {
- return m_directory;
- }
-
- /**
- * Get the directory in which temporary data for this application
- * is stored.
- *
- * @return the work directory for application.
- */
- public File getWorkDirectory()
- {
- return m_workDirectory;
- }
-
- /**
- * Retrieve location of applications config.xml file.
- *
- * @return url to config.xml file
- */
- public String getConfig()
- {
- return m_config;
- }
-
- /**
- * Retrieve location of applications assembly.xml file.
- *
- * @return url to assembly.xml file
- */
- public String getAssembly()
- {
- return m_assembly;
- }
-
- /**
- * Retrieve location of applications environment.xml file.
- *
- * @return url to environment.xml file
- */
- public String getEnvironment()
- {
- return m_environment;
- }
-
- /**
- * Retrieve ClassPath for application.
- *
- * @return the classpath
- */
- public String[] getClassPath()
- {
- return m_classPath;
- }
-
- /** Retrieve file digests.
- *
- * @return the file digest list.
- */
- public FileDigest[] getFileDigests()
- {
- return m_digests;
- }
-
- /** Retrieve the timestamp.
- *
- * @return the timestamp when installation occured.
- */
- public long getTimestamp()
- {
- return m_timestamp;
- }
-}
Index:
java/org/apache/avalon/phoenix/components/deployer/installer/InstallationException.java
===================================================================
RCS file:
java/org/apache/avalon/phoenix/components/deployer/installer/InstallationException.java
diff -N
java/org/apache/avalon/phoenix/components/deployer/installer/InstallationException.java
---
java/org/apache/avalon/phoenix/components/deployer/installer/InstallationException.java
6 Aug 2002 11:57:40 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-package org.apache.avalon.phoenix.components.deployer.installer;
-
-import org.apache.avalon.framework.CascadingException;
-
-/**
- * Exception to indicate error deploying.
- *
- * @author <a href="mailto:peter at apache.org">Peter Donald</a>
- * @version $Revision: 1.2 $ $Date: 2002/08/06 11:57:40 $
- */
-public final class InstallationException
- extends CascadingException
-{
- /**
- * Construct a new <code>InstallationException</code> instance.
- *
- * @param message The detail message for this exception.
- */
- public InstallationException( final String message )
- {
- this( message, null );
- }
-
- /**
- * Construct a new <code>InstallationException</code> instance.
- *
- * @param message The detail message for this exception.
- * @param throwable the root cause of the exception
- */
- public InstallationException( final String message, final Throwable throwable )
- {
- super( message, throwable );
- }
-}
Index: java/org/apache/avalon/phoenix/components/deployer/installer/Installer.java
===================================================================
RCS file: java/org/apache/avalon/phoenix/components/deployer/installer/Installer.java
diff -N java/org/apache/avalon/phoenix/components/deployer/installer/Installer.java
--- java/org/apache/avalon/phoenix/components/deployer/installer/Installer.java 6 Aug
2002 11:57:40 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,625 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-package org.apache.avalon.phoenix.components.deployer.installer;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.zip.CRC32;
-import java.util.zip.CheckedInputStream;
-import java.util.zip.Checksum;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.excalibur.io.FileUtil;
-import org.apache.avalon.excalibur.io.IOUtil;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-
-/**
- * An Installer is responsible for taking a URL for Sar
- * and installing it as appropriate.
- *
- * @author <a href="mailto:peter at apache.org">Peter Donald</a>
- * @version $Revision: 1.13 $ $Date: 2002/08/06 11:57:40 $
- */
-public class Installer
- extends AbstractLogEnabled
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( Installer.class );
-
- private static final String META_INF = "META-INF";
-
- private static final String SAR_INF = "SAR-INF";
-
- private static final String LIB = "SAR-INF/lib";
-
- private static final String CLASSES = "SAR-INF/classes/";
-
- //The names on the native filesystem
- private static final String FS_CONFIG_XML = "SAR-INF" + File.separator +
"config.xml";
-
- private static final String FS_ASSEMBLY_XML = "SAR-INF" + File.separator +
"assembly.xml";
-
- private static final String FS_ENV_XML = "SAR-INF" + File.separator +
"environment.xml";
-
- private static final String FS_CLASSES =
- "SAR-INF" + File.separator + "classes" + File.separator;
-
- /**
- * Base directory in which to install extracted application.
- */
- private File m_baseDirectory;
-
- /**
- * Base directory in which to install temporary/work files.
- */
- private File m_baseWorkDirectory;
-
- /**
- * Set the baseDirectory in which to install applications.
- *
- * @param baseDirectory the baseDirectory in which to install applications.
- */
- public void setBaseDirectory( File baseDirectory )
- {
- m_baseDirectory = baseDirectory;
- }
-
- /**
- * Set the baseDirectory in which to install applications temporary Data.
- *
- * @param baseWorkDirectory the baseDirectory in which to install applications
temporary Data.
- */
- public void setBaseWorkDirectory( File baseWorkDirectory )
- {
- m_baseWorkDirectory = baseWorkDirectory;
- }
-
- /**
- * Uninstall the Sar designated installation.
- *
- * @param installation the installation
- * @throws InstallationException if an error occurs
- */
- public void uninstall( final Installation installation )
- throws InstallationException
- {
- final FileDigest[] infos = installation.getFileDigests();
- final Checksum checksum = new CRC32();
-
- if( infos != null )
- {
- for( int i = 0; i < infos.length; i++ )
- {
- final File file = infos[ i ].getFile();
- final File parent = file.getParentFile();
-
- final String message = REZ.getString( "skip-removal", file );
-
- if( file.exists() )
- {
- if( file.lastModified() <= installation.getTimestamp() )
- {
- getLogger().debug( message );
- continue;
- }
-
- checksum( file, checksum );
-
- if( checksum.getValue() != infos[ i ].getChecksum() )
- {
- getLogger().debug( message );
- continue;
- }
-
- file.delete();
- if( 0 == parent.list().length )
- {
- parent.delete();
- }
- }
- }
- }
-
- deleteWorkDir( installation.getWorkDirectory() );
- }
-
- /**
- * Utility method to delete the working directory.
- *
- * @param dir the working directory
- */
- private void deleteWorkDir( final File dir )
- {
- try
- {
- FileUtil.deleteDirectory( dir );
- }
- catch( final IOException ioe )
- {
- try
- {
- //If can't delete them now (damn windows locking!)
- //then schedule them for deletion when JVM exits
- FileUtil.forceDeleteOnExit( dir );
- }
- catch( final IOException ioe2 )
- {
- //ignore
- }
- final String message =
- REZ.getString( "nodelete-workdir.error",
- dir,
- ioe.getMessage() );
- getLogger().warn( message, ioe );
- }
- }
-
- /**
- * Install the Sar designated by url.
- *
- * @param url the url of instalation
- * @throws InstallationException if an error occurs
- */
- public Installation install( final String name, final URL url )
- throws InstallationException
- {
- lock();
- try
- {
- final String notice = REZ.getString( "installing-sar", url );
- getLogger().info( notice );
-
- final File file = getFileFor( url );
- if( file.isDirectory() )
- {
- final String message =
- REZ.getString( "install.sar-isa-dir.error", name, url );
- throw new InstallationException( message );
- }
-
- //Get Zipfile representing .sar file
- final ZipFile zipFile = new ZipFile( file );
- return install( name, url, file, zipFile );
- }
- catch( final IOException ioe )
- {
- final String message = REZ.getString( "bad-zip-file", url );
- throw new InstallationException( message, ioe );
- }
- finally
- {
- unlock();
- }
- }
-
- /**
- * Utility method to compute the checksum for a given file.
- * @param file the computed file.
- * @param checksum the checksum algorithm.
- */
- private void checksum( final File file, final Checksum checksum )
- {
- checksum.reset();
-
- InputStream input = null;
- try
- {
- input = new CheckedInputStream( new FileInputStream( file ), checksum );
- IOUtil.toByteArray( input );
- }
- catch( final IOException ioe )
- {
- final String message = REZ.getString( "checksum-failure", file );
- getLogger().warn( message );
- }
- finally
- {
- IOUtil.shutdownStream( input );
- }
- }
-
- /**
- * Utility method to lock repository to disallow other installers to access it.
- * Currently a no-op.
- */
- private void lock()
- {
- }
-
- /**
- * Utility method to unlock repository to allow other installers to access it.
- * Currently a no-op.
- */
- private void unlock()
- {
- }
-
- /**
- * Install a new style sar.
- *
- * @param url the url designator of sar
- * @param file the file of sar
- * @param zipFile the ZipFile representing sar
- * @return the Installation object
- */
- private Installation install( final String name,
- final URL url,
- final File file,
- final ZipFile zipFile )
- throws InstallationException
- {
- final File directory =
- new File( m_baseDirectory, name ).getAbsoluteFile();
-
- //Question: Should we be making sure that
- //this directory is created?
- directory.mkdirs();
-
- final ArrayList digests = new ArrayList();
- final ArrayList jars = new ArrayList();
-
- final File workDir =
- getRelativeWorkDir( m_baseWorkDirectory, name );
- boolean success = false;
- try
- {
- 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();
-
- success = true;
- return new Installation( file, directory, workDir,
- config, assembly, environment,
- classPath, fileDigests, timestamp );
- }
- finally
- {
- if( !success )
- {
- deleteWorkDir( workDir );
- }
- }
- }
-
- /**
- * Expand the specified Zip file.
- *
- * @param zipFile the zip file
- * @param directory the directory where to extract non-jar,
- * non-classes files
- * @param workDir the directory to extract classes/jar files
- * @param classpath the list to add classpath entries to
- * @param digests the list to add file digests to
- * @param url the url of deployment (for error reporting purposes)
- * @throws InstallationException if an error occurs extracting files
- */
- private void expandZipFile( final ZipFile zipFile,
- final File directory,
- final File workDir,
- final ArrayList classpath,
- final ArrayList digests,
- final URL url )
- throws InstallationException
- {
- final Enumeration entries = zipFile.entries();
- while( entries.hasMoreElements() )
- {
- final ZipEntry entry = (ZipEntry)entries.nextElement();
- final String name = fixName( entry.getName() );
-
- if( name.startsWith( META_INF ) )
- {
- continue;
- }
-
- if( handleDirs( entry, name, directory ) )
- {
- continue;
- }
-
- if( handleClasses( zipFile,
- entry,
- name,
- workDir,
- classpath ) )
- {
- continue;
- }
-
- if( handleJars( zipFile, entry, name, workDir, classpath ) )
- {
- continue;
- }
-
- //Expand the file if necesasry and issue a warning
- //if there is a file in the way
- final File destination = new File( directory, name );
- handleFile( zipFile, entry, destination, digests, url );
- }
- }
-
- /**
- * Handle the extraction of normal resources
- * from zip file/
- */
- private void handleFile( final ZipFile zipFile,
- final ZipEntry entry,
- final File destination,
- final ArrayList digests,
- final URL url )
- throws InstallationException
- {
- if( !destination.exists() )
- {
- expandFile( zipFile, entry, destination );
- calculateDigest( entry, destination, digests );
- }
- else
- {
- final String message =
- REZ.getString( "file-in-the-way",
- url,
- entry.getName(),
- destination );
- getLogger().warn( message );
- }
- }
-
- /**
- * Handle extraction of jars.
- *
- * @param zipFile the zipFIle to exrtact from
- * @param entry the entry to extract
- * @param name the normalized name of entry
- * @param workDir the working directory to extract to
- * @param jars the classpath list
- * @return true if handled, false otherwise
- */
- private boolean handleJars( final ZipFile zipFile,
- final ZipEntry entry,
- final String name,
- final File workDir,
- final ArrayList jars )
- throws InstallationException
- {
- if( name.startsWith( LIB )
- && name.endsWith( ".jar" )
- && LIB.length() == name.lastIndexOf( "/" ) )
- {
- final File jar = new File( workDir, name );
- jars.add( getURLAsString( jar ) );
-
- final File file = new File( workDir, name );
- expandFile( zipFile, entry, file );
- return true;
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Handle extraction of jars.
- *
- * @param zipFile the zipFIle to exrtact from
- * @param entry the entry to extract
- * @param name the normalized name of entry
- * @param workDir the working directory to extract to
- * @param jars the classpath list
- * @return true if handled, false otherwise
- */
- private boolean handleClasses( final ZipFile zipFile,
- final ZipEntry entry,
- final String name,
- final File workDir,
- final ArrayList jars )
- throws InstallationException
- {
- if( name.startsWith( CLASSES ) )
- {
- final File classDir = new File( workDir, FS_CLASSES );
- if( !classDir.exists() )
- {
- jars.add( getURLAsString( classDir ) );
- final File file = new File( workDir, name );
- expandFile( zipFile, entry, file );
- }
- return true;
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Handle expansion of dirs in the zipfile.
- *
- * @param entry the current ZipEntry
- * @param name the name of entry
- * @param directory the base directory extraacting to
- * @return true if handled, false otherwise
- */
- private boolean handleDirs( final ZipEntry entry,
- final String name,
- final File directory )
- {
- if( entry.isDirectory() )
- {
- if( !name.startsWith( SAR_INF ) )
- {
- final File newDir =
- new File( directory, name );
- newDir.mkdirs();
- }
- return true;
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Create working directory inside baseWorkDir
- * for specified application.
- *
- * @param baseWorkDir the base workDir for all apps
- * @param name the name of the application
- * @return the working directory for app
- */
- private File getRelativeWorkDir( final File baseWorkDir,
- final String name )
- {
- final String filename =
- name + "-" + System.currentTimeMillis();
- return new File( baseWorkDir, filename );
- }
-
- /**
- * Fix the specified name so that it does not start
- * with a "/" character.
- *
- * @param name the name to fix
- * @return the name stripped of initial "/" if necessary
- */
- private String fixName( final String name )
- {
- if( name.startsWith( "/" ) )
- {
- return name.substring( 1 );
- }
- else
- {
- return name;
- }
- }
-
- /**
- * Get File object for URL.
- * Currently it assumes that URL is a file URL but in the
- * future it will allow downloading of remote URLs thus enabling
- * a deploy from anywhere functionality.
- *
- * @param url the url of deployment
- * @return the File for deployment
- * @throws InstallationException if an error occurs
- */
- private File getFileFor( final URL url )
- throws InstallationException
- {
- if( !url.getProtocol().equals( "file" ) )
- {
- final String message = REZ.getString( "install-nonlocal", url );
- throw new InstallationException( message );
- }
-
- File file = new File( url.getFile() );
- file = file.getAbsoluteFile();
-
- if( !file.exists() )
- {
- final String message = REZ.getString( "install-nourl", file );
- throw new InstallationException( message );
- }
-
- return file;
- }
-
- /**
- * Calculate digest for specific entry.
- *
- * @param entry the entry
- * @param file the extracted file
- * @param digests the list of digests already
- * calculated
- */
- private void calculateDigest( final ZipEntry entry,
- final File file,
- final ArrayList digests )
- {
- final long checksum = entry.getCrc();
- digests.add( new FileDigest( file, checksum ) );
- }
-
- /**
- * Expand a single zipEntry to a file.
- */
- private void expandFile( final ZipFile zipFile,
- final ZipEntry entry,
- final File file )
- throws InstallationException
- {
- InputStream input = null;
- OutputStream output = null;
-
- try
- {
- file.getParentFile().mkdirs();
- output = new FileOutputStream( file );
- input = zipFile.getInputStream( entry );
- IOUtil.copy( input, output );
- }
- catch( final IOException ioe )
- {
- final String message =
- REZ.getString( "failed-to-expand",
- entry.getName(),
- file,
- ioe.getMessage() );
- throw new InstallationException( message, ioe );
- }
- finally
- {
- IOUtil.shutdownStream( input );
- IOUtil.shutdownStream( output );
- }
- }
-
- /**
- * Utility method to extract URL from file in safe manner.
- *
- * @param file the file
- * @return the URL representation of file
- */
- private String getURLAsString( final File file )
- {
- try
- {
- return file.toURL().toExternalForm();
- }
- catch( final MalformedURLException mue )
- {
- return null;
- //should never occur
- }
- }
-}
Index: java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java
===================================================================
RCS file:
/home/cvspublic/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java,v
retrieving revision 1.77
diff -u -r1.77 DefaultEmbeddor.java
--- java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java 6 Aug
2002 11:57:40 -0000 1.77
+++ java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java 14 Aug
+2002 21:59:33 -0000
@@ -686,7 +686,7 @@
return m_parameters;
}
- private Object getEmbeddorComponent( final String role )
+ protected Object getEmbeddorComponent( final String role )
{
for( int i = 0; i < m_entries.length; i++ )
{
Index: java/org/apache/avalon/phoenix/interfaces/FileDigest.java
===================================================================
RCS file: java/org/apache/avalon/phoenix/interfaces/FileDigest.java
diff -N java/org/apache/avalon/phoenix/interfaces/FileDigest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/org/apache/avalon/phoenix/interfaces/FileDigest.java 14 Aug 2002 21:59:32
+-0000
@@ -0,0 +1,46 @@
+package org.apache.avalon.phoenix.interfaces;
+
+import java.io.File;
+
+/**
+ * FileDigest holds file deployment information. Information
+ * used to verify if file was modified since deployment.
+ *
+ * @version $Revision: 1.2 $ $Date: 2002/07/26 09:49:20 $
+ */
+public class FileDigest
+{
+ private final File m_file;
+
+ private final long m_checksum;
+
+ /** Create a new FileDigest object.
+ *
+ * @param file the file.
+ * @param checksum the checksum value of the file.
+ */
+ public FileDigest( final File file, final long checksum )
+ {
+ m_file = file;
+ m_checksum = checksum;
+ }
+
+ /** Retrieve the file.
+ *
+ * @return the file.
+ */
+ public File getFile()
+ {
+ return m_file;
+ }
+
+ /** Retrieve the checksum calculated at deployment time.
+ *
+ * @return the checksum value.
+ */
+ public long getChecksum()
+ {
+ return m_checksum;
+ }
+}
+
Index: java/org/apache/avalon/phoenix/interfaces/Installation.java
===================================================================
RCS file: java/org/apache/avalon/phoenix/interfaces/Installation.java
diff -N java/org/apache/avalon/phoenix/interfaces/Installation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/org/apache/avalon/phoenix/interfaces/Installation.java 14 Aug 2002 21:59:32
+-0000
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.avalon.phoenix.interfaces;
+
+import java.io.File;
+
+/**
+ * Descriptor for installation.
+ * This descriptor contains all the information relating to
+ * installed application. In particular it locates all the
+ * jars in Classpath, config files and installation directory.
+ *
+ * @author <a href="mailto:peter at apache.org">Peter Donald</a>
+ * @version $Revision: 1.2 $ $Date: 2002/08/06 11:57:40 $
+ */
+public final class Installation
+{
+ ///The source of installation (usually a directory in .sar format or a .sar file)
+ private final File m_source;
+
+ ///Directory in which application is installed
+ private final File m_directory;
+
+ ///Directory in which application temporary/work data is stored
+ private final File m_workDirectory;
+
+ ///URL to block configuration data
+ private final String m_config;
+
+ ///URL to assembly data
+ private final String m_assembly;
+
+ ///URL to application configuration data
+ private final String m_environment;
+
+ ///ClassPath for application
+ private final String[] m_classPath;
+
+ ///Info for expanded files
+ private final FileDigest[] m_digests;
+
+ ///Installation timestamp
+ private final long m_timestamp;
+
+ public Installation( final File source,
+ final File directory,
+ final File workDirectory,
+ final String config,
+ final String assembly,
+ final String environment,
+ final String[] classPath,
+ final FileDigest[] digests,
+ final long timestamp )
+ {
+ m_source = source;
+ m_directory = directory;
+ m_workDirectory = workDirectory;
+ m_config = config;
+ m_assembly = assembly;
+ m_environment = environment;
+ m_classPath = classPath;
+ m_digests = digests;
+ m_timestamp = timestamp;
+ }
+
+ /**
+ * Get the source of application. (Usually a
+ * directory in .sar format or a .sar)
+ *
+ * @return the source of application
+ */
+ public File getSource()
+ {
+ return m_source;
+ }
+
+ /**
+ * Get directory application is installed into.
+ *
+ * @return the applications base directory
+ */
+ public File getDirectory()
+ {
+ return m_directory;
+ }
+
+ /**
+ * Get the directory in which temporary data for this application
+ * is stored.
+ *
+ * @return the work directory for application.
+ */
+ public File getWorkDirectory()
+ {
+ return m_workDirectory;
+ }
+
+ /**
+ * Retrieve location of applications config.xml file.
+ *
+ * @return url to config.xml file
+ */
+ public String getConfig()
+ {
+ return m_config;
+ }
+
+ /**
+ * Retrieve location of applications assembly.xml file.
+ *
+ * @return url to assembly.xml file
+ */
+ public String getAssembly()
+ {
+ return m_assembly;
+ }
+
+ /**
+ * Retrieve location of applications environment.xml file.
+ *
+ * @return url to environment.xml file
+ */
+ public String getEnvironment()
+ {
+ return m_environment;
+ }
+
+ /**
+ * Retrieve ClassPath for application.
+ *
+ * @return the classpath
+ */
+ public String[] getClassPath()
+ {
+ return m_classPath;
+ }
+
+ /** Retrieve file digests.
+ *
+ * @return the file digest list.
+ */
+ public FileDigest[] getFileDigests()
+ {
+ return m_digests;
+ }
+
+ /** Retrieve the timestamp.
+ *
+ * @return the timestamp when installation occured.
+ */
+ public long getTimestamp()
+ {
+ return m_timestamp;
+ }
+}
Index: java/org/apache/avalon/phoenix/interfaces/InstallationException.java
===================================================================
RCS file: java/org/apache/avalon/phoenix/interfaces/InstallationException.java
diff -N java/org/apache/avalon/phoenix/interfaces/InstallationException.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/org/apache/avalon/phoenix/interfaces/InstallationException.java 14 Aug
+2002 21:59:32 -0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.avalon.phoenix.interfaces;
+
+import org.apache.avalon.framework.CascadingException;
+
+/**
+ * Exception to indicate error deploying.
+ *
+ * @author <a href="mailto:peter at apache.org">Peter Donald</a>
+ * @version $Revision: 1.2 $ $Date: 2002/08/06 11:57:40 $
+ */
+public final class InstallationException
+ extends CascadingException
+{
+ /**
+ * Construct a new <code>InstallationException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ */
+ public InstallationException( final String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Construct a new <code>InstallationException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param throwable the root cause of the exception
+ */
+ public InstallationException( final String message, final Throwable throwable )
+ {
+ super( message, throwable );
+ }
+}
Index: java/org/apache/avalon/phoenix/interfaces/Installer.java
===================================================================
RCS file: java/org/apache/avalon/phoenix/interfaces/Installer.java
diff -N java/org/apache/avalon/phoenix/interfaces/Installer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/org/apache/avalon/phoenix/interfaces/Installer.java 14 Aug 2002 21:59:32
+-0000
@@ -0,0 +1,51 @@
+package org.apache.avalon.phoenix.interfaces;
+
+import java.io.File;
+import java.net.URL;
+
+
+/**
+ * An Installer is responsible for taking a URL for Sar
+ * and installing it as appropriate.
+ *
+ * @todo move <code>Installation</code> and <code>InstallationException</code>
+ * to a more appropriate package
+ *
+ * @author ifedorenko
+ */
+public interface Installer
+{
+ String ROLE = Installer.class.getName();
+
+ /**
+ * Install the Sar designated by url.
+ *
+ * @param url the url of instalation
+ * @throws InstallationException if an error occurs
+ */
+ public Installation install( String name, URL url )
+ throws InstallationException;
+
+ /**
+ * Uninstall the Sar designated installation.
+ *
+ * @param installation the installation
+ * @throws InstallationException if an error occurs
+ */
+ public void uninstall( Installation installation )
+ throws InstallationException;
+
+ /**
+ * Set the baseDirectory in which to install applications.
+ *
+ * @param baseDirectory the baseDirectory in which to install applications.
+ */
+ public void setBaseDirectory( File baseDirectory );
+
+ /**
+ * Set the baseDirectory in which to install applications temporary Data.
+ *
+ * @param baseWorkDirectory the baseDirectory in which to install applications
+temporary Data.
+ */
+ public void setBaseWorkDirectory( File baseWorkDirectory );
+}
eclipse-deployer.jar
Description: Binary data
phoenix-demo.zip
Description: Zip compressed data
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
