mcconnell 2002/08/08 03:00:50
Added: assembly/src/java/org/apache/excalibur/merlin/model/builder
XMLContainerCreator.java ContainerCreator.java
ContainerBuilder.java
Log:
support for automatic container profile generation
Revision Changes Path
1.8 +101 -117
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLContainerCreator.java
1.5 +21 -9
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerCreator.java
1.1
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerBuilder.java
Index: ContainerBuilder.java
===================================================================
/*
* 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.excalibur.merlin.model.builder;
import java.io.InputStream;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.excalibur.meta.info.Type;
import org.apache.excalibur.merlin.model.ContainerDescriptor;
/**
* A ProfileBuilder is responsible for building [EMAIL PROTECTED] Profile}
* objects from Configuration objects.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision: 1.1 $ $Date: 2002/08/08 10:00:50 $
*/
public final class ContainerBuilder
{
private static final Resources REZ =
ResourceManager.getPackageResources( ContainerBuilder.class );
private final ContainerCreator m_xmlContainerCreator =
createXMLContainerCreator();
/**
* Build ContainerDescriptor from the XML descriptor format.
*
* @param loader the ClassLoader to load info from
* @param type the Type on which the profile is based
* @return the created ContainerDescriptor
* @throws Exception if an error occurs
*/
public ContainerDescriptor[] build( ClassLoader loader, Type type )
throws Exception
{
final String xprofile =
type.getInfo().getImplementationKey().replace( '.', '/' ) +
".xprofile";
final InputStream inputStream =
loader.getResourceAsStream( xprofile );
final ContainerCreator creator = getXMLContainerCreator( xprofile );
return creator.createPackagedContainerDescriptors( loader, type,
inputStream );
}
/**
* Utility to get xml info builder, else throw
* an exception if missing descriptor.
*
* @return the ProfileCreator
*/
private ContainerCreator getXMLContainerCreator( final String classname )
throws Exception
{
if( null != m_xmlContainerCreator )
{
return m_xmlContainerCreator;
}
else
{
final String message =
REZ.getString( "builder.missing-xml-creator.error", classname
);
throw new Exception( message );
}
}
/**
* Utility to get XMLContainerCreator if XML files are on
* ClassPath.
*
* @return the XML [EMAIL PROTECTED] ContainerCreator}
*/
private static ContainerCreator createXMLContainerCreator()
{
ContainerCreator xmlContainerCreator = null;
try
{
xmlContainerCreator = new XMLContainerCreator();
}
catch( final Exception e )
{
//Ignore it if ClassNot found due to no
//XML Classes on classpath
}
return xmlContainerCreator;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>