donaldp 2003/03/22 16:37:25
Modified: src/java/org/apache/avalon/phoenix/components/deployer
DefaultDeployer.java
src/java/org/apache/avalon/phoenix/components/installer
DefaultInstaller.java
src/java/org/apache/avalon/phoenix/interfaces
ContainerConstants.java Installer.java
Log:
Removed the need for a specialized Installation object and instead used a vanilla
map. This allows us to extend the deployment archive format with ease and without
having to do anything but add new keys.
Revision Changes Path
1.75 +25 -20
avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java
Index: DefaultDeployer.java
===================================================================
RCS file:
/home/cvs/avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- DefaultDeployer.java 23 Mar 2003 00:19:48 -0000 1.74
+++ DefaultDeployer.java 23 Mar 2003 00:37:25 -0000 1.75
@@ -70,7 +70,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.phoenix.BlockContext;
-import org.apache.avalon.phoenix.interfaces.ContainerConstants;
import org.apache.avalon.phoenix.containerkit.metadata.PartitionMetaData;
import org.apache.avalon.phoenix.containerkit.profile.ComponentProfile;
import org.apache.avalon.phoenix.containerkit.profile.PartitionProfile;
@@ -81,10 +80,10 @@
import org.apache.avalon.phoenix.interfaces.ClassLoaderSet;
import org.apache.avalon.phoenix.interfaces.ConfigurationRepository;
import org.apache.avalon.phoenix.interfaces.ConfigurationValidator;
+import org.apache.avalon.phoenix.interfaces.ContainerConstants;
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;
@@ -178,8 +177,8 @@
public void redeploy( final String name )
throws DeploymentException
{
- final Installation installation =
- (Installation)m_installations.get( name );
+ final Map installation =
+ (Map)m_installations.get( name );
if( null == installation )
{
final String message =
@@ -188,7 +187,8 @@
}
try
{
- final URL location = installation.getSource().toURL();
+ final File source = (File)installation.get(
ContainerConstants.INSTALL_SOURCE );
+ final URL location = source.toURL();
undeploy( name );
deploy( name, location );
}
@@ -207,8 +207,8 @@
public void undeploy( final String name )
throws DeploymentException
{
- final Installation installation =
- (Installation)m_installations.remove( name );
+ final Map installation =
+ (Map)m_installations.remove( name );
if( null == installation )
{
final String message =
@@ -282,22 +282,25 @@
*/
ResourceManager.clearResourceCache();
- Installation installation = null;
+ Map installation = null;
boolean success = false;
try
{
//m_baseWorkDirectory
installation = m_installer.install( name, location );
- final Configuration config = getConfigurationFor(
installation.getConfig() );
- final Configuration environment = getConfigurationFor(
installation.getEnvironment() );
- final Configuration assembly = getConfigurationFor(
installation.getAssembly() );
-
- final File directory = installation.getHomeDirectory();
+ final Configuration config = getConfigurationFor( installation,
ContainerConstants.INSTALL_CONFIG );
+ final Configuration environment = getConfigurationFor( installation,
ContainerConstants.INSTALL_ENVIRONMENT );
+ final Configuration assembly = getConfigurationFor( installation,
ContainerConstants.INSTALL_ASSEMBLY );
+
+ final File homeDirectory =
+ (File)installation.get( ContainerConstants.INSTALL_HOME );
+ final File workDirectory =
+ (File)installation.get( ContainerConstants.INSTALL_WORK );
final DefaultContext context = new DefaultContext();
context.put( BlockContext.APP_NAME, name );
- context.put( BlockContext.APP_HOME_DIR, directory );
+ context.put( BlockContext.APP_HOME_DIR, homeDirectory );
final Configuration logs = environment.getChild( "logs" );
//Load hierarchy before classloader placed in context as
@@ -309,8 +312,8 @@
final ClassLoaderSet classLoaderSet =
m_classLoaderManager.createClassLoaderSet( environment,
-
installation.getHomeDirectory(),
-
installation.getWorkDirectory() );
+ homeDirectory,
+ workDirectory );
final ClassLoader classLoader = classLoaderSet.getDefaultClassLoader();
context.put( "classloader", classLoader );
@@ -331,8 +334,8 @@
//Finally add application to kernel
m_kernel.addApplication( profile,
- installation.getHomeDirectory(),
- installation.getWorkDirectory(),
+ homeDirectory,
+ workDirectory,
classLoader,
logger,
classLoaderSet.getClassLoaders() );
@@ -473,13 +476,15 @@
/**
* Helper method to load configuration data.
*
- * @param location the location of configuration data as a url
+ * @param install the install data
+ * @param key the key under which config data is stored in install data
* @return the Configuration
* @throws DeploymentException if an error occurs
*/
- private Configuration getConfigurationFor( final String location )
+ private Configuration getConfigurationFor( final Map install, final String key )
throws DeploymentException
{
+ final String location = (String)install.get(key );
try
{
return ConfigurationBuilder.build( location );
1.15 +21 -11
avalon-phoenix/src/java/org/apache/avalon/phoenix/components/installer/DefaultInstaller.java
Index: DefaultInstaller.java
===================================================================
RCS file:
/home/cvs/avalon-phoenix/src/java/org/apache/avalon/phoenix/components/installer/DefaultInstaller.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DefaultInstaller.java 22 Mar 2003 12:07:09 -0000 1.14
+++ DefaultInstaller.java 23 Mar 2003 00:37:25 -0000 1.15
@@ -58,6 +58,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.avalon.excalibur.i18n.ResourceManager;
@@ -69,7 +71,7 @@
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.phoenix.interfaces.Installation;
+import org.apache.avalon.phoenix.interfaces.ContainerConstants;
import org.apache.avalon.phoenix.interfaces.InstallationException;
import org.apache.avalon.phoenix.interfaces.Installer;
@@ -174,10 +176,12 @@
* @param installation the installation
* @throws InstallationException if an error occurs
*/
- public void uninstall( final Installation installation )
+ public void uninstall( final Map installation )
throws InstallationException
{
- deleteWorkDir( installation.getWorkDirectory() );
+ final File work =
+ (File)installation.get( ContainerConstants.INSTALL_WORK );
+ deleteWorkDir( work );
}
/**
@@ -217,7 +221,7 @@
* @param url the url of instalation
* @throws InstallationException if an error occurs
*/
- public Installation install( final String name, final URL url )
+ public Map install( final String name, final URL url )
throws InstallationException
{
lock();
@@ -273,10 +277,10 @@
* @param zipFile the ZipFile representing sar
* @return the Installation object
*/
- private Installation installArchive( final String name,
- final URL url,
- final File file,
- final ZipFile zipFile )
+ private Map installArchive( final String name,
+ final URL url,
+ final File file,
+ final ZipFile zipFile )
throws InstallationException
{
final File directory =
@@ -298,8 +302,14 @@
final String environment = getURLAsString( new File( directory,
FS_ENV_XML ) );
success = true;
- return new Installation( file, directory, workDir,
- config, assembly, environment );
+ final Map install = new HashMap();
+ install.put( ContainerConstants.INSTALL_SOURCE, file );
+ install.put( ContainerConstants.INSTALL_HOME, directory );
+ install.put( ContainerConstants.INSTALL_WORK, workDir );
+ install.put( ContainerConstants.INSTALL_CONFIG, config );
+ install.put( ContainerConstants.INSTALL_ASSEMBLY, assembly );
+ install.put( ContainerConstants.INSTALL_ENVIRONMENT, environment );
+ return install;
}
finally
{
1.3 +84 -6
avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/ContainerConstants.java
Index: ContainerConstants.java
===================================================================
RCS file:
/home/cvs/avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/ContainerConstants.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContainerConstants.java 23 Mar 2003 00:22:12 -0000 1.2
+++ ContainerConstants.java 23 Mar 2003 00:37:25 -0000 1.3
@@ -1,10 +1,52 @@
/*
- * 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.
- */
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+ include the following acknowledgment: "This product includes software
+ developed by the Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowledgment may appear in the software itself, if
+ and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Avalon", "Phoenix" and "Apache Software Foundation"
+ must not be used to endorse or promote products derived from this
+ software without prior written permission. For written permission, please
+ contact [EMAIL PROTECTED]
+
+ 5. Products derived from this software may not be called "Apache", nor may
+ "Apache" appear in their name, without prior written permission of the
+ Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many individuals
+ on behalf of the Apache Software Foundation. For more information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
package org.apache.avalon.phoenix.interfaces;
/**
@@ -68,4 +110,40 @@
* The root instrumentation category for all applications.
*/
String ROOT_INSTRUMENT_CATEGORY = "applications";
+
+ /**
+ * The source of installation (usually a directory in .sar format or a .sar
file).
+ * Type: [EMAIL PROTECTED] java.io.File}
+ */
+ String INSTALL_SOURCE = "install:source";
+
+ /**
+ * The Directory in which application is installed.
+ * Type: [EMAIL PROTECTED] java.io.File}
+ */
+ String INSTALL_HOME = "install:home";
+
+ /**
+ * The Directory in which application temporary/work data is stored.
+ * Type: [EMAIL PROTECTED] java.io.File}
+ */
+ String INSTALL_WORK = "install:work";
+
+ /**
+ * The URL to block configuration data.
+ * Type: [EMAIL PROTECTED] java.lang.String}
+ */
+ String INSTALL_CONFIG = "install:config";
+
+ /**
+ * The URL to assembly data.
+ * Type: [EMAIL PROTECTED] java.lang.String}
+ */
+ String INSTALL_ASSEMBLY = "install:assembly";
+
+ /**
+ * The URL to application configuration data.
+ * Type: [EMAIL PROTECTED] java.lang.String}
+ */
+ String INSTALL_ENVIRONMENT = "install:environment";
}
1.4 +3 -3
avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/Installer.java
Index: Installer.java
===================================================================
RCS file:
/home/cvs/avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/Installer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Installer.java 22 Mar 2003 12:07:14 -0000 1.3
+++ Installer.java 23 Mar 2003 00:37:25 -0000 1.4
@@ -47,10 +47,10 @@
Apache Software Foundation, please see <http://www.apache.org/>.
*/
-
package org.apache.avalon.phoenix.interfaces;
import java.net.URL;
+import java.util.Map;
/**
* A basic service to Install an application.
@@ -67,7 +67,7 @@
* @param url the url of instalation
* @throws InstallationException if an error occurs
*/
- Installation install( String name, URL url )
+ Map install( String name, URL url )
throws InstallationException;
/**
@@ -76,6 +76,6 @@
* @param installation the installation
* @throws InstallationException if an error occurs
*/
- void uninstall( Installation installation )
+ void uninstall( Map installation )
throws InstallationException;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]