if( m_installations.containsKey( name ) )
{
final String message =
REZ.format( "deploy.already-deployed.error",
name );
throw new LoomException( message );
}
/*
* Clear all the reosurces out of ResourceManager cache
* so that reloaded applications will have their i18n bundles
* reloaded.
*/
ResourceManager.clearResourceCache();
Map installation = null;
boolean success = false;
try
{
//m_baseWorkDirectory
installation = m_installer.install( name, location );
final Configuration config =
getConfigurationFor( installation,
ContainerConstants.INSTALL_CONFIG,
null );
final Configuration environment =
getConfigurationFor( installation,
ContainerConstants.INSTALL_ENVIRONMENT,
null );
final Configuration assembly =
getConfigurationFor( installation,
ContainerConstants.INSTALL_ASSEMBLY,
ConfigurationBuilder.ASSEMBLY_SCHEMA );
final File homeDirectory =
(File)installation.get( ContainerConstants.INSTALL_HOME );
final File workDirectory =
(File)installation.get( ContainerConstants.INSTALL_WORK );
final Map data = new HashMap();
data.put( BlockContext.APP_NAME, name );
data.put( BlockContext.APP_HOME_DIR, homeDirectory );
final Configuration logs = environment.getChild( "logs", false );
//Load hierarchy before classloader placed in context as
//that way the logFactory will not try to use the application
//specific classloader to load the targets which will cause
//CastClassExceptions
final LoggerStore store =
m_logManager.createHierarchy( logs,
homeDirectory,
workDirectory,
data );
final ClassLoaderSet classLoaderSet =
m_classLoaderManager.createClassLoaderSet( environment,
data,
homeDirectory,
workDirectory );
//TODO: Add classLoaderSet to application resources
final ClassLoader classLoader =
classLoaderSet.getDefaultClassLoader();
final Configuration newConfig =
processConfiguration( name, config );
final Map parameters = new HashMap();
parameters.put( ContainerConstants.ASSEMBLY_NAME, name );
parameters.put( ContainerConstants.ASSEMBLY_DESCRIPTOR, assembly );
parameters.put( ContainerConstants.CONFIG_DESCRIPTOR, newConfig );
parameters.put( ContainerConstants.ASSEMBLY_CLASSLOADER,
classLoader );
//assemble all the blocks for application
final PartitionProfile profile =
m_builder.buildProfile( parameters );
m_verifier.verifySar( profile, classLoader );
//Setup configuration for all the applications blocks
verifyConfiguration( profile, newConfig );
validateConfiguration( profile, classLoader );
//Finally add application to kernel
m_kernel.addApplication( profile,
homeDirectory,
workDirectory,
classLoader,
store );
m_installations.put( name, installation );
final String message =
REZ.format( "deploy.notice.sar.add",
name );
getLogger().debug( message );
success = true;
}
catch( final LoomException de )
{
throw de;
}
catch( final Exception e )
{
//From classloaderManager/kernel
throw new LoomException( e.getMessage(), e );
}
finally
{
if( !success && null != installation )
{