avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/installer DefaultInstaller.java
Date Sat, 21 Sep 2002 02:43:52 GMT
donaldp     2002/09/20 19:43:52

  Modified:    src/conf kernel.xml
               src/java/org/apache/avalon/phoenix/components/deployer
                        DefaultDeployer.java
               src/java/org/apache/avalon/phoenix/components/installer
                        DefaultInstaller.java
  Log:
  Move installer to being a fully fledged kernel component.
  
  Revision  Changes    Path
  1.25      +4 -0      jakarta-avalon-phoenix/src/conf/kernel.xml
  
  Index: kernel.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/conf/kernel.xml,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- kernel.xml	21 Sep 2002 01:09:30 -0000	1.24
  +++ kernel.xml	21 Sep 2002 02:43:51 -0000	1.25
  @@ -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.installer.DefaultInstaller"
  +            logger="installer"/>
  +
           <component role="org.apache.avalon.phoenix.interfaces.Deployer"
               class="org.apache.avalon.phoenix.components.deployer.DefaultDeployer"
               logger="deployer"/>
  
  
  
  1.58      +14 -106   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.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- DefaultDeployer.java	21 Sep 2002 02:36:03 -0000	1.57
  +++ DefaultDeployer.java	21 Sep 2002 02:43:51 -0000	1.58
  @@ -8,7 +8,6 @@
   package org.apache.avalon.phoenix.components.deployer;
   
   import java.io.File;
  -import java.io.IOException;
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.Arrays;
  @@ -23,15 +22,9 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.logger.Logger;
  -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.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.phoenix.interfaces.Installation;
  -import org.apache.avalon.phoenix.interfaces.InstallationException;
  -import org.apache.avalon.phoenix.components.installer.DefaultInstaller;
   import org.apache.avalon.phoenix.interfaces.Application;
   import org.apache.avalon.phoenix.interfaces.ClassLoaderManager;
   import org.apache.avalon.phoenix.interfaces.ConfigurationRepository;
  @@ -39,6 +32,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;
  @@ -58,73 +54,22 @@
    */
   public class DefaultDeployer
       extends AbstractLogEnabled
  -    implements Deployer, Parameterizable, Serviceable, Initializable, Disposable, DeployerMBean
  +    implements Deployer, Serviceable, Initializable, Disposable, DeployerMBean
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultDeployer.class );
   
       private final Assembler m_assembler = new Assembler();
       private final SarVerifier m_verifier = new SarVerifier();
  -    private final DefaultInstaller m_installer = new DefaultInstaller();
       private final Map m_installations = new Hashtable();
       private LogManager m_logManager;
       private Kernel m_kernel;
  +    private Installer m_installer;
       private ConfigurationRepository m_repository;
       private ClassLoaderManager m_classLoaderManager;
       private ConfigurationValidator m_validator;
   
       /**
  -     * The directory which is used as the base for
  -     * extracting all temporary files from archives. It is
  -     * expected that the temporary files will be deleted when
  -     * the .sar file is undeployed.
  -     */
  -    private File m_baseWorkDirectory;
  -
  -    /**
  -     * The base directory in which applications are deployed.
  -     */
  -    private File m_baseDirectory;
  -
  -    /**
  -     * Retrieve parameter that specifies work directory.
  -     *
  -     * @param parameters the parameters to read
  -     * @throws ParameterException if invlaid work directory
  -     */
  -    public void parameterize( final Parameters parameters )
  -        throws ParameterException
  -    {
  -        final String phoenixHome = parameters.getParameter( "phoenix.home" );
  -        final String defaultWorkDir = phoenixHome + File.separator + "work";
  -        final String defaultAppsDir = phoenixHome + File.separator + "apps";
  -        final String rawWorkDir =
  -            parameters.getParameter( "phoenix.work.dir", defaultWorkDir );
  -        final String rawAppsDir =
  -            parameters.getParameter( "phoenix.apps.dir", defaultAppsDir );
  -
  -        final File workDir = new File( rawWorkDir );
  -        try
  -        {
  -            m_baseWorkDirectory = workDir.getCanonicalFile();
  -        }
  -        catch( final IOException ioe )
  -        {
  -            m_baseWorkDirectory = workDir.getAbsoluteFile();
  -        }
  -
  -        final File appsDir = new File( rawAppsDir );
  -        try
  -        {
  -            m_baseDirectory = appsDir.getCanonicalFile();
  -        }
  -        catch( final IOException ioe )
  -        {
  -            m_baseDirectory = appsDir.getAbsoluteFile();
  -        }
  -    }
  -
  -    /**
        * Retrieve relevant services needed to deploy.
        *
        * @param serviceManager the ComponentManager
  @@ -133,25 +78,21 @@
       public void service( final ServiceManager serviceManager )
           throws ServiceException
       {
  -        m_kernel = (Kernel)serviceManager.lookup( Kernel.ROLE );
  -        m_repository = (ConfigurationRepository)serviceManager.
  +        m_kernel = (Kernel) serviceManager.lookup( Kernel.ROLE );
  +        m_repository = (ConfigurationRepository) serviceManager.
               lookup( ConfigurationRepository.ROLE );
  -        m_classLoaderManager = (ClassLoaderManager)serviceManager.
  +        m_classLoaderManager = (ClassLoaderManager) serviceManager.
               lookup( ClassLoaderManager.ROLE );
  -        m_logManager = (LogManager)serviceManager.lookup( LogManager.ROLE );
  -        m_validator = (ConfigurationValidator)serviceManager.lookup( ConfigurationValidator.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()
           throws Exception
       {
  -        initWorkDirectory();
  -
  -        setupLogger( m_installer );
           setupLogger( m_assembler );
           setupLogger( m_verifier );
  -        m_installer.setBaseDirectory( m_baseDirectory );
  -        m_installer.setBaseWorkDirectory( m_baseWorkDirectory );
       }
   
       /**
  @@ -162,7 +103,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 ];
  @@ -191,7 +132,7 @@
           throws DeploymentException
       {
           final Installation installation =
  -            (Installation)m_installations.get( name );
  +            (Installation) m_installations.get( name );
           if( null == installation )
           {
               final String message =
  @@ -220,7 +161,7 @@
           throws DeploymentException
       {
           final Installation installation =
  -            (Installation)m_installations.remove( name );
  +            (Installation) m_installations.remove( name );
           if( null == installation )
           {
               final String message =
  @@ -569,38 +510,5 @@
           }
   
           return false;
  -    }
  -
  -    /**
  -     * Make sure that the work directory is created and not a file.
  -     *
  -     * @throws Exception if work directory can not be created or is a file
  -     */
  -    private void initWorkDirectory()
  -        throws Exception
  -    {
  -        if( !m_baseWorkDirectory.exists() )
  -        {
  -            final String message =
  -                REZ.getString( "deploy.create-dir.notice",
  -                               m_baseWorkDirectory );
  -            getLogger().info( message );
  -
  -            if( !m_baseWorkDirectory.mkdirs() )
  -            {
  -                final String error =
  -                    REZ.getString( "deploy.workdir-nocreate.error",
  -                                   m_baseWorkDirectory );
  -                throw new Exception( error );
  -            }
  -        }
  -
  -        if( !m_baseWorkDirectory.isDirectory() )
  -        {
  -            final String message =
  -                REZ.getString( "deploy.workdir-notadir.error",
  -                               m_baseWorkDirectory );
  -            throw new Exception( message );
  -        }
       }
   }
  
  
  
  1.7       +83 -17    jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/installer/DefaultInstaller.java
  
  Index: DefaultInstaller.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/installer/DefaultInstaller.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultInstaller.java	21 Sep 2002 02:36:03 -0000	1.6
  +++ DefaultInstaller.java	21 Sep 2002 02:43:51 -0000	1.7
  @@ -23,6 +23,10 @@
   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.framework.activity.Initializable;
  +import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.avalon.framework.parameters.ParameterException;
  +import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.phoenix.interfaces.Installation;
   import org.apache.avalon.phoenix.interfaces.InstallationException;
   import org.apache.avalon.phoenix.interfaces.Installer;
  @@ -36,7 +40,7 @@
    */
   public class DefaultInstaller
       extends AbstractLogEnabled
  -    implements Installer
  +    implements Installer, Parameterizable, Initializable
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultInstaller.class );
  @@ -53,34 +57,62 @@
       private static final String FS_CLASSES =
           "SAR-INF" + File.separator + "classes" + File.separator;
   
  +
       /**
  -     * Base directory in which to install extracted application.
  +     * The directory which is used as the base for
  +     * extracting all temporary files from archives. It is
  +     * expected that the temporary files will be deleted when
  +     * the .sar file is undeployed.
        */
  -    private File m_baseDirectory;
  +    private File m_baseWorkDirectory;
   
       /**
  -     * Base directory in which to install temporary/work files.
  +     * The base directory in which applications are deployed.
        */
  -    private File m_baseWorkDirectory;
  +    private File m_baseDirectory;
   
       /**
  -     * Set the baseDirectory in which to install applications.
  +     * Retrieve parameter that specifies work directory.
        *
  -     * @param baseDirectory the baseDirectory in which to install applications.
  +     * @param parameters the parameters to read
  +     * @throws org.apache.avalon.framework.parameters.ParameterException if invlaid work
directory
        */
  -    public void setBaseDirectory( File baseDirectory )
  +    public void parameterize( final Parameters parameters )
  +        throws ParameterException
       {
  -        m_baseDirectory = baseDirectory;
  +        final String phoenixHome = parameters.getParameter( "phoenix.home" );
  +        final String defaultWorkDir = phoenixHome + File.separator + "work";
  +        final String defaultAppsDir = phoenixHome + File.separator + "apps";
  +        final String rawWorkDir =
  +            parameters.getParameter( "phoenix.work.dir", defaultWorkDir );
  +        final String rawAppsDir =
  +            parameters.getParameter( "phoenix.apps.dir", defaultAppsDir );
  +
  +        final File workDir = new File( rawWorkDir );
  +        try
  +        {
  +            m_baseWorkDirectory = workDir.getCanonicalFile();
  +        }
  +        catch( final IOException ioe )
  +        {
  +            m_baseWorkDirectory = workDir.getAbsoluteFile();
  +        }
  +
  +        final File appsDir = new File( rawAppsDir );
  +        try
  +        {
  +            m_baseDirectory = appsDir.getCanonicalFile();
  +        }
  +        catch( final IOException ioe )
  +        {
  +            m_baseDirectory = appsDir.getAbsoluteFile();
  +        }
       }
   
  -    /**
  -     * 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 )
  +    public void initialize()
  +        throws Exception
       {
  -        m_baseWorkDirectory = baseWorkDirectory;
  +        initWorkDirectory();
       }
   
       /**
  @@ -520,6 +552,40 @@
           {
               return null;
               //should never occur
  +        }
  +    }
  +
  +
  +    /**
  +     * Make sure that the work directory is created and not a file.
  +     *
  +     * @throws Exception if work directory can not be created or is a file
  +     */
  +    private void initWorkDirectory()
  +        throws Exception
  +    {
  +        if( !m_baseWorkDirectory.exists() )
  +        {
  +            final String message =
  +                REZ.getString( "deploy.create-dir.notice",
  +                               m_baseWorkDirectory );
  +            getLogger().info( message );
  +
  +            if( !m_baseWorkDirectory.mkdirs() )
  +            {
  +                final String error =
  +                    REZ.getString( "deploy.workdir-nocreate.error",
  +                                   m_baseWorkDirectory );
  +                throw new Exception( error );
  +            }
  +        }
  +
  +        if( !m_baseWorkDirectory.isDirectory() )
  +        {
  +            final String message =
  +                REZ.getString( "deploy.workdir-notadir.error",
  +                               m_baseWorkDirectory );
  +            throw new Exception( message );
           }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message