Refactored the codebase to use Avalons ServiceManager rather than ComponentManager. The reason for this is that the ComponentManager required that contained objects implement the Component interface while the ServiceManager constructs do not have this requirement. This makes it much easier to extract parts of Myrmidon without any dependency on Ant/Avalon git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271495 13f79535-47bb-0310-9956-ffa450edef68master
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.aut.vfs; | |||
import org.apache.avalon.framework.component.Component; | |||
import java.io.File; | |||
/** | |||
@@ -53,7 +52,6 @@ import java.io.File; | |||
* @author Adam Murdoch | |||
*/ | |||
public interface FileSystemManager | |||
extends Component | |||
{ | |||
String ROLE = FileSystemManager.class.getName(); | |||
@@ -107,5 +105,5 @@ public interface FileSystemManager | |||
* On error parsing the file name. | |||
* | |||
*/ | |||
FileObject resolveFile ( File baseFile, String name ) throws FileSystemException; | |||
FileObject resolveFile( File baseFile, String name ) throws FileSystemException; | |||
} |
@@ -12,15 +12,15 @@ import java.lang.reflect.Method; | |||
import java.util.ArrayList; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.configuration.Configurable; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||
import org.apache.avalon.framework.context.Context; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.avalon.framework.logger.LogEnabled; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.aut.converter.ConverterException; | |||
import org.apache.myrmidon.interfaces.configurer.Configurer; | |||
import org.apache.myrmidon.interfaces.converter.MasterConverter; | |||
@@ -32,7 +32,7 @@ import org.apache.myrmidon.interfaces.converter.MasterConverter; | |||
*/ | |||
public class ClassicConfigurer | |||
extends AbstractLogEnabled | |||
implements Configurer, Composable, LogEnabled | |||
implements Configurer, Serviceable, LogEnabled | |||
{ | |||
private static final Resources REZ = | |||
ResourceManager.getPackageResources( DefaultConfigurer.class ); | |||
@@ -43,10 +43,10 @@ public class ClassicConfigurer | |||
///Converter to use for converting between values | |||
private MasterConverter m_converter; | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentException | |||
public void service( final ServiceManager serviceManager ) | |||
throws ServiceException | |||
{ | |||
m_converter = (MasterConverter)componentManager.lookup( MasterConverter.ROLE ); | |||
m_converter = (MasterConverter)serviceManager.lookup( MasterConverter.ROLE ); | |||
} | |||
/** | |||
@@ -81,7 +81,8 @@ public class ClassicConfigurer | |||
getLogger().debug( message ); | |||
} | |||
( (Configurable)object ).configure( configuration ); | |||
final Configurable configurable = (Configurable)object; | |||
configurable.configure( configuration ); | |||
} | |||
else | |||
{ | |||
@@ -11,17 +11,17 @@ import java.util.HashMap; | |||
import java.util.Map; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.CascadingException; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.configuration.Configurable; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||
import org.apache.avalon.framework.context.Context; | |||
import org.apache.avalon.framework.context.ContextException; | |||
import org.apache.avalon.framework.context.Resolvable; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.avalon.framework.logger.LogEnabled; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.myrmidon.framework.DataType; | |||
import org.apache.myrmidon.interfaces.configurer.Configurer; | |||
import org.apache.myrmidon.interfaces.converter.MasterConverter; | |||
@@ -38,7 +38,7 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
*/ | |||
public class DefaultConfigurer | |||
extends AbstractLogEnabled | |||
implements Configurer, Composable, LogEnabled | |||
implements Configurer, Serviceable, LogEnabled | |||
{ | |||
private final static Resources REZ = | |||
ResourceManager.getPackageResources( DefaultConfigurer.class ); | |||
@@ -56,12 +56,12 @@ public class DefaultConfigurer | |||
///ObjectConfigurer for that class. | |||
private Map m_configurerCache = new HashMap(); | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentException | |||
public void service( final ServiceManager serviceManager ) | |||
throws ServiceException | |||
{ | |||
m_converter = (MasterConverter)componentManager.lookup( MasterConverter.ROLE ); | |||
m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | |||
m_roleManager = (RoleManager)componentManager.lookup( RoleManager.ROLE ); | |||
m_converter = (MasterConverter)serviceManager.lookup( MasterConverter.ROLE ); | |||
m_typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE ); | |||
m_roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE ); | |||
} | |||
/** | |||
@@ -391,8 +391,14 @@ public class DefaultConfigurer | |||
Object objValue = PropertyUtil.resolveProperty( value, context, false ); | |||
// Convert the value to the appropriate type | |||
Object converterContext = context; | |||
if( context instanceof Resolvable ) | |||
{ | |||
converterContext = ( (Resolvable)context ).resolve( context ); | |||
} | |||
final Class clazz = setter.getType(); | |||
objValue = m_converter.convert( clazz, objValue, context ); | |||
objValue = m_converter.convert( clazz, objValue, converterContext ); | |||
// Set the value | |||
setter.addValue( state, objValue ); | |||
@@ -7,15 +7,14 @@ | |||
*/ | |||
package org.apache.myrmidon.components.converter; | |||
import org.apache.aut.converter.Converter; | |||
import org.apache.aut.converter.ConverterException; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.context.Context; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.aut.converter.Converter; | |||
import org.apache.aut.converter.ConverterException; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.myrmidon.interfaces.converter.ConverterRegistry; | |||
import org.apache.myrmidon.interfaces.converter.MasterConverter; | |||
import org.apache.myrmidon.interfaces.type.TypeException; | |||
@@ -30,7 +29,7 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
*/ | |||
public class DefaultMasterConverter | |||
extends AbstractLogEnabled | |||
implements MasterConverter, Composable | |||
implements MasterConverter, Serviceable | |||
{ | |||
private final static Resources REZ = | |||
ResourceManager.getPackageResources( DefaultMasterConverter.class ); | |||
@@ -43,15 +42,15 @@ public class DefaultMasterConverter | |||
/** | |||
* Retrieve relevent services needed to deploy. | |||
* | |||
* @param componentManager the ComponentManager | |||
* @exception ComponentException if an error occurs | |||
* @param serviceManager the ServiceManager | |||
* @exception ServiceException if an error occurs | |||
*/ | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentException | |||
public void service( final ServiceManager serviceManager ) | |||
throws ServiceException | |||
{ | |||
m_registry = (ConverterRegistry)componentManager.lookup( ConverterRegistry.ROLE ); | |||
m_registry = (ConverterRegistry)serviceManager.lookup( ConverterRegistry.ROLE ); | |||
final TypeManager typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | |||
final TypeManager typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE ); | |||
try | |||
{ | |||
m_factory = typeManager.getFactory( Converter.class ); | |||
@@ -59,7 +58,7 @@ public class DefaultMasterConverter | |||
catch( final TypeException te ) | |||
{ | |||
final String message = REZ.getString( "no-converter-factory.error" ); | |||
throw new ComponentException( message, te ); | |||
throw new ServiceException( message, te ); | |||
} | |||
} | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.myrmidon.components.deployer; | |||
import java.io.File; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.myrmidon.interfaces.deployer.DeploymentException; | |||
/** | |||
@@ -17,7 +16,6 @@ import org.apache.myrmidon.interfaces.deployer.DeploymentException; | |||
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||
*/ | |||
public interface ClassLoaderManager | |||
extends Component | |||
{ | |||
String ROLE = ClassLoaderManager.class.getName(); | |||
@@ -23,10 +23,10 @@ import org.apache.avalon.excalibur.extension.PackageManager; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.activity.Initializable; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.myrmidon.interfaces.deployer.DeploymentException; | |||
import org.apache.myrmidon.interfaces.extensions.ExtensionManager; | |||
@@ -37,7 +37,7 @@ import org.apache.myrmidon.interfaces.extensions.ExtensionManager; | |||
*/ | |||
public class DefaultClassLoaderManager | |||
extends AbstractLogEnabled | |||
implements ClassLoaderManager, Composable, Initializable | |||
implements ClassLoaderManager, Serviceable, Initializable | |||
{ | |||
private final static Resources REZ = | |||
ResourceManager.getPackageResources( DefaultClassLoaderManager.class ); | |||
@@ -52,7 +52,7 @@ public class DefaultClassLoaderManager | |||
public void initialize() throws Exception | |||
{ | |||
if( m_baseClassLoader == null ) | |||
if( null == m_baseClassLoader ) | |||
{ | |||
m_baseClassLoader = Thread.currentThread().getContextClassLoader(); | |||
} | |||
@@ -70,11 +70,11 @@ public class DefaultClassLoaderManager | |||
/** | |||
* Retrieve relevent services needed to deploy. | |||
*/ | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentException | |||
public void service( final ServiceManager serviceManager ) | |||
throws ServiceException | |||
{ | |||
final ExtensionManager extensionManager = | |||
(ExtensionManager)componentManager.lookup( ExtensionManager.ROLE ); | |||
(ExtensionManager)serviceManager.lookup( ExtensionManager.ROLE ); | |||
m_packageManager = new PackageManager( extensionManager ); | |||
} | |||
@@ -11,13 +11,13 @@ import java.io.File; | |||
import java.net.URL; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import org.apache.aut.converter.Converter; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.aut.converter.Converter; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.myrmidon.interfaces.converter.ConverterRegistry; | |||
import org.apache.myrmidon.interfaces.deployer.ConverterDefinition; | |||
import org.apache.myrmidon.interfaces.deployer.Deployer; | |||
@@ -25,8 +25,8 @@ import org.apache.myrmidon.interfaces.deployer.DeploymentException; | |||
import org.apache.myrmidon.interfaces.deployer.TypeDefinition; | |||
import org.apache.myrmidon.interfaces.deployer.TypeDeployer; | |||
import org.apache.myrmidon.interfaces.role.RoleManager; | |||
import org.apache.myrmidon.interfaces.service.AntServiceManager; | |||
import org.apache.myrmidon.interfaces.service.ServiceFactory; | |||
import org.apache.myrmidon.interfaces.service.ServiceManager; | |||
import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; | |||
import org.apache.myrmidon.interfaces.type.TypeManager; | |||
@@ -39,7 +39,7 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
*/ | |||
public class DefaultDeployer | |||
extends AbstractLogEnabled | |||
implements Deployer, Composable | |||
implements Deployer, Serviceable | |||
{ | |||
private final static Resources REZ = | |||
ResourceManager.getPackageResources( DefaultDeployer.class ); | |||
@@ -52,33 +52,33 @@ public class DefaultDeployer | |||
/** Map from ClassLoader to the deployer for that class loader. */ | |||
private final Map m_classLoaderDeployers = new HashMap(); | |||
private ServiceManager m_ServiceManager; | |||
private AntServiceManager m_serviceManager; | |||
/** | |||
* Retrieve relevent services needed to deploy. | |||
* | |||
* @param componentManager the ComponentManager | |||
* @exception ComponentException if an error occurs | |||
* @param serviceManager the ServiceManager | |||
* @exception ServiceException if an error occurs | |||
*/ | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentException | |||
public void service( final ServiceManager serviceManager ) | |||
throws ServiceException | |||
{ | |||
m_converterRegistry = (ConverterRegistry)componentManager.lookup( ConverterRegistry.ROLE ); | |||
m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | |||
m_roleManager = (RoleManager)componentManager.lookup( RoleManager.ROLE ); | |||
m_classLoaderManager = (ClassLoaderManager)componentManager.lookup( ClassLoaderManager.ROLE ); | |||
m_ServiceManager = (ServiceManager)componentManager.lookup( ServiceManager.ROLE ); | |||
m_converterRegistry = (ConverterRegistry)serviceManager.lookup( ConverterRegistry.ROLE ); | |||
m_typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE ); | |||
m_roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE ); | |||
m_classLoaderManager = (ClassLoaderManager)serviceManager.lookup( ClassLoaderManager.ROLE ); | |||
m_serviceManager = (AntServiceManager)serviceManager.lookup( AntServiceManager.ROLE ); | |||
} | |||
/** | |||
* Creates a child deployer. | |||
*/ | |||
public Deployer createChildDeployer( ComponentManager componentManager ) | |||
throws ComponentException | |||
public Deployer createChildDeployer( final ServiceManager componentManager ) | |||
throws ServiceException | |||
{ | |||
final DefaultDeployer child = new DefaultDeployer(); | |||
setupLogger( child ); | |||
child.compose( componentManager ); | |||
child.service( componentManager ); | |||
return child; | |||
} | |||
@@ -18,12 +18,11 @@ import org.apache.avalon.excalibur.io.ExtensionFileFilter; | |||
import org.apache.avalon.excalibur.io.FileUtil; | |||
import org.apache.avalon.framework.activity.Disposable; | |||
import org.apache.avalon.framework.activity.Initializable; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.component.DefaultComponentManager; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.avalon.framework.parameters.Parameterizable; | |||
import org.apache.avalon.framework.parameters.Parameters; | |||
import org.apache.avalon.framework.service.DefaultServiceManager; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.myrmidon.components.deployer.ClassLoaderManager; | |||
import org.apache.myrmidon.interfaces.aspect.AspectManager; | |||
import org.apache.myrmidon.interfaces.builder.ProjectBuilder; | |||
@@ -38,7 +37,7 @@ import org.apache.myrmidon.interfaces.executor.Executor; | |||
import org.apache.myrmidon.interfaces.extensions.ExtensionManager; | |||
import org.apache.myrmidon.interfaces.model.Project; | |||
import org.apache.myrmidon.interfaces.role.RoleManager; | |||
import org.apache.myrmidon.interfaces.service.ServiceManager; | |||
import org.apache.myrmidon.interfaces.service.AntServiceManager; | |||
import org.apache.myrmidon.interfaces.type.TypeFactory; | |||
import org.apache.myrmidon.interfaces.type.TypeManager; | |||
import org.apache.myrmidon.interfaces.workspace.Workspace; | |||
@@ -65,7 +64,7 @@ public class DefaultEmbeddor | |||
private TypeManager m_typeManager; | |||
private List m_components = new ArrayList(); | |||
private DefaultComponentManager m_componentManager = new DefaultComponentManager(); | |||
private DefaultServiceManager m_serviceManager = new DefaultServiceManager(); | |||
private Parameters m_parameters; | |||
private Parameters m_defaults; | |||
@@ -123,7 +122,7 @@ public class DefaultEmbeddor | |||
{ | |||
final String component = getParameter( Workspace.ROLE ); | |||
final Workspace workspace = | |||
(Workspace)createComponent( component, Workspace.class ); | |||
(Workspace)createService( component, Workspace.class ); | |||
setupObject( workspace, parameters ); | |||
return workspace; | |||
} | |||
@@ -158,8 +157,8 @@ public class DefaultEmbeddor | |||
//setup the components | |||
setupComponents(); | |||
m_deployer = (Deployer)m_componentManager.lookup( Deployer.ROLE ); | |||
m_typeManager = (TypeManager)m_componentManager.lookup( TypeManager.ROLE ); | |||
m_deployer = (Deployer)m_serviceManager.lookup( Deployer.ROLE ); | |||
m_typeManager = (TypeManager)m_serviceManager.lookup( TypeManager.ROLE ); | |||
setupFiles(); | |||
} | |||
@@ -193,17 +192,18 @@ public class DefaultEmbeddor | |||
// Dispose any disposable components | |||
for( Iterator iterator = m_components.iterator(); iterator.hasNext(); ) | |||
{ | |||
Component component = (Component)iterator.next(); | |||
Object component = iterator.next(); | |||
if( component instanceof Disposable ) | |||
{ | |||
( (Disposable)component ).dispose(); | |||
final Disposable disposable = (Disposable)component; | |||
disposable.dispose(); | |||
} | |||
} | |||
// Ditch everything | |||
m_components = null; | |||
m_deployer = null; | |||
m_componentManager = null; | |||
m_serviceManager = null; | |||
m_parameters = null; | |||
m_defaults = null; | |||
m_homeDir = null; | |||
@@ -246,7 +246,7 @@ public class DefaultEmbeddor | |||
createComponent( Deployer.class, PREFIX + "deployer.DefaultDeployer" ); | |||
createComponent( ClassLoaderManager.class, PREFIX + "deployer.DefaultClassLoaderManager" ); | |||
createComponent( Executor.class, PREFIX + "executor.AspectAwareExecutor" ); | |||
createComponent( ServiceManager.class, PREFIX + "service.DefaultServiceManager" ); | |||
createComponent( AntServiceManager.class, PREFIX + "service.DefaultAntServiceManager" ); | |||
} | |||
/** | |||
@@ -257,8 +257,8 @@ public class DefaultEmbeddor | |||
{ | |||
final String role = roleType.getName(); | |||
final String className = m_parameters.getParameter( role, defaultImpl ); | |||
final Component component = createComponent( className, roleType ); | |||
m_componentManager.put( role, component ); | |||
final Object component = createService( className, roleType ); | |||
m_serviceManager.put( role, component ); | |||
m_components.add( component ); | |||
} | |||
@@ -272,7 +272,7 @@ public class DefaultEmbeddor | |||
{ | |||
for( Iterator iterator = m_components.iterator(); iterator.hasNext(); ) | |||
{ | |||
final Component component = (Component)iterator.next(); | |||
final Object component = iterator.next(); | |||
setupObject( component, m_parameters ); | |||
} | |||
} | |||
@@ -359,7 +359,7 @@ public class DefaultEmbeddor | |||
* @return the created object | |||
* @exception Exception if an error occurs | |||
*/ | |||
private Component createComponent( final String component, final Class clazz ) | |||
private Object createService( final String component, final Class clazz ) | |||
throws Exception | |||
{ | |||
try | |||
@@ -371,13 +371,8 @@ public class DefaultEmbeddor | |||
final String message = REZ.getString( "bad-type.error", component, clazz.getName() ); | |||
throw new Exception( message ); | |||
} | |||
if( !( object instanceof Component ) ) | |||
{ | |||
final String message = REZ.getString( "bad-type.error", component, Component.class.getName() ); | |||
throw new Exception( message ); | |||
} | |||
return (Component)object; | |||
return object; | |||
} | |||
catch( final IllegalAccessException iae ) | |||
{ | |||
@@ -408,9 +403,9 @@ public class DefaultEmbeddor | |||
{ | |||
setupLogger( object ); | |||
if( object instanceof Composable ) | |||
if( object instanceof Serviceable ) | |||
{ | |||
( (Composable)object ).compose( m_componentManager ); | |||
( (Serviceable)object ).service( m_serviceManager ); | |||
} | |||
if( object instanceof Parameterizable ) | |||
@@ -11,13 +11,13 @@ import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||
import org.apache.avalon.framework.configuration.DefaultConfiguration; | |||
import org.apache.avalon.framework.logger.Logger; | |||
import org.apache.avalon.framework.parameters.Parameters; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.myrmidon.api.Task; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.myrmidon.interfaces.aspect.AspectManager; | |||
@@ -43,15 +43,15 @@ public class AspectAwareExecutor | |||
/** | |||
* Retrieve relevent services. | |||
* | |||
* @param componentManager the ComponentManager | |||
* @exception ComponentException if an error occurs | |||
* @param serviceManager the ServiceManager | |||
* @exception ServiceException if an error occurs | |||
*/ | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentException | |||
public void service( final ServiceManager serviceManager ) | |||
throws ServiceException | |||
{ | |||
super.compose( componentManager ); | |||
super.service( serviceManager ); | |||
m_aspectManager = (AspectManager)componentManager.lookup( AspectManager.ROLE ); | |||
m_aspectManager = (AspectManager)serviceManager.lookup( AspectManager.ROLE ); | |||
} | |||
public void execute( final Configuration taskModel, final ExecutionFrame frame ) | |||
@@ -9,13 +9,13 @@ package org.apache.myrmidon.components.executor; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.avalon.framework.logger.LogEnabled; | |||
import org.apache.avalon.framework.logger.Logger; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.myrmidon.api.Task; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.myrmidon.api.TaskException; | |||
@@ -34,7 +34,7 @@ import org.apache.myrmidon.interfaces.configurer.TaskContextAdapter; | |||
*/ | |||
public class DefaultExecutor | |||
extends AbstractLogEnabled | |||
implements Executor, Composable | |||
implements Executor, Serviceable | |||
{ | |||
private final static Resources REZ = | |||
ResourceManager.getPackageResources( DefaultExecutor.class ); | |||
@@ -44,13 +44,13 @@ public class DefaultExecutor | |||
/** | |||
* Retrieve relevent services needed to deploy. | |||
* | |||
* @param componentManager the ComponentManager | |||
* @exception ComponentException if an error occurs | |||
* @param serviceManager the ServiceManager | |||
* @exception ServiceException if an error occurs | |||
*/ | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentException | |||
public void service( final ServiceManager serviceManager ) | |||
throws ServiceException | |||
{ | |||
m_configurer = (Configurer)componentManager.lookup( Configurer.ROLE ); | |||
m_configurer = (Configurer)serviceManager.lookup( Configurer.ROLE ); | |||
} | |||
public void execute( final Configuration taskModel, final ExecutionFrame frame ) | |||
@@ -13,12 +13,12 @@ import java.util.Map; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.activity.Disposable; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.myrmidon.interfaces.service.ServiceException; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.myrmidon.interfaces.service.AntServiceException; | |||
import org.apache.myrmidon.interfaces.service.AntServiceManager; | |||
import org.apache.myrmidon.interfaces.service.ServiceFactory; | |||
import org.apache.myrmidon.interfaces.service.ServiceManager; | |||
import org.apache.myrmidon.interfaces.type.TypeException; | |||
import org.apache.myrmidon.interfaces.type.TypeFactory; | |||
import org.apache.myrmidon.interfaces.type.TypeManager; | |||
@@ -34,11 +34,11 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public class DefaultServiceManager | |||
implements ServiceManager, Composable, Disposable | |||
public class DefaultAntServiceManager | |||
implements AntServiceManager, Serviceable, Disposable | |||
{ | |||
private final static Resources REZ | |||
= ResourceManager.getPackageResources( DefaultServiceManager.class ); | |||
private final static Resources REZ = | |||
ResourceManager.getPackageResources( DefaultAntServiceManager.class ); | |||
/** Map from service class -> service object. */ | |||
private Map m_services = new HashMap(); | |||
@@ -46,18 +46,25 @@ public class DefaultServiceManager | |||
private TypeFactory m_typeFactory; | |||
/** | |||
* Locate the components used by this service manager. | |||
* Pass the <code>ServiceManager</code> to the <code>servicable</code>. | |||
* The <code>Servicable</code> implementation should use the specified | |||
* <code>ServiceManager</code> to acquire the components it needs for | |||
* execution. | |||
* | |||
* @param manager The <code>ServiceManager</code> which this | |||
* <code>Servicable</code> uses. | |||
*/ | |||
public void compose( final ComponentManager componentManager ) throws ComponentException | |||
public void service( ServiceManager manager ) | |||
throws ServiceException | |||
{ | |||
final TypeManager typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | |||
final TypeManager typeManager = (TypeManager)manager.lookup( TypeManager.ROLE ); | |||
try | |||
{ | |||
m_typeFactory = typeManager.getFactory( ServiceFactory.class ); | |||
} | |||
catch( final TypeException e ) | |||
{ | |||
throw new ComponentException( e.getMessage(), e ); | |||
throw new ServiceException( e.getMessage(), e ); | |||
} | |||
} | |||
@@ -104,7 +111,7 @@ public class DefaultServiceManager | |||
* Locates a service instance. | |||
*/ | |||
public Object getService( Class serviceType ) | |||
throws ServiceException | |||
throws AntServiceException | |||
{ | |||
Object service = m_services.get( serviceType ); | |||
if( service == null ) | |||
@@ -120,7 +127,7 @@ public class DefaultServiceManager | |||
/** | |||
* Creates the service object for a service class. | |||
*/ | |||
private Object createService( Class serviceType ) throws ServiceException | |||
private Object createService( Class serviceType ) throws AntServiceException | |||
{ | |||
try | |||
{ | |||
@@ -131,14 +138,14 @@ public class DefaultServiceManager | |||
if( !serviceType.isInstance( service ) ) | |||
{ | |||
final String message = REZ.getString( "mismatched-service-type.error", serviceType.getName(), service.getClass().getName() ); | |||
throw new ServiceException( message ); | |||
throw new AntServiceException( message ); | |||
} | |||
return service; | |||
} | |||
catch( Exception e ) | |||
catch( final Exception e ) | |||
{ | |||
final String message = REZ.getString( "create-service.error", serviceType.getName() ); | |||
throw new ServiceException( message, e ); | |||
throw new AntServiceException( message, e ); | |||
} | |||
} | |||
} |
@@ -1,54 +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.myrmidon.components.workspace; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.myrmidon.interfaces.service.ServiceException; | |||
import org.apache.myrmidon.interfaces.service.ServiceManager; | |||
/** | |||
* An adaptor from {@link ComponentManager} to {@link ServiceManager}. | |||
* | |||
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||
* @version $Revision$ $Date$ | |||
*/ | |||
class ComponentManagerAdaptor | |||
implements ServiceManager | |||
{ | |||
private final ComponentManager m_componentManager; | |||
public ComponentManagerAdaptor( final ComponentManager componentManager ) | |||
{ | |||
m_componentManager = componentManager; | |||
} | |||
/** | |||
* Determines if this service manager contains a particular service. | |||
*/ | |||
public boolean hasService( Class serviceType ) | |||
{ | |||
return m_componentManager.hasComponent( serviceType.getName() ); | |||
} | |||
/** | |||
* Locates a service instance. | |||
*/ | |||
public Object getService( Class serviceType ) | |||
throws ServiceException | |||
{ | |||
try | |||
{ | |||
return m_componentManager.lookup( serviceType.getName() ); | |||
} | |||
catch( ComponentException e ) | |||
{ | |||
throw new ServiceException( e.getMessage(), e ); | |||
} | |||
} | |||
} |
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.components.workspace; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.logger.Logger; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.myrmidon.interfaces.executor.ExecutionFrame; | |||
@@ -20,7 +19,7 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
class DefaultExecutionFrame | |||
implements ExecutionFrame, Component | |||
implements ExecutionFrame | |||
{ | |||
private final Logger m_logger; | |||
private final TaskContext m_context; | |||
@@ -19,8 +19,8 @@ import org.apache.myrmidon.api.TaskException; | |||
import org.apache.myrmidon.components.configurer.PropertyUtil; | |||
import org.apache.myrmidon.components.configurer.PropertyException; | |||
import org.apache.myrmidon.interfaces.configurer.TaskContextAdapter; | |||
import org.apache.myrmidon.interfaces.service.ServiceException; | |||
import org.apache.myrmidon.interfaces.service.ServiceManager; | |||
import org.apache.myrmidon.interfaces.service.AntServiceException; | |||
import org.apache.myrmidon.interfaces.service.AntServiceManager; | |||
/** | |||
* Default implementation of TaskContext. | |||
@@ -36,7 +36,7 @@ public class DefaultTaskContext | |||
private final Map m_contextData = new Hashtable(); | |||
private final TaskContext m_parent; | |||
private ServiceManager m_serviceManager; | |||
private AntServiceManager m_serviceManager; | |||
/** | |||
* Constructor for Context with no parent contexts. | |||
@@ -57,7 +57,7 @@ public class DefaultTaskContext | |||
/** | |||
* Constructor that specifies the service directory for context. | |||
*/ | |||
public DefaultTaskContext( final ServiceManager serviceManager ) | |||
public DefaultTaskContext( final AntServiceManager serviceManager ) | |||
{ | |||
this( null, serviceManager ); | |||
} | |||
@@ -66,7 +66,7 @@ public class DefaultTaskContext | |||
* Constructor that takes both parent context and a service directory. | |||
*/ | |||
public DefaultTaskContext( final TaskContext parent, | |||
final ServiceManager serviceManager ) | |||
final AntServiceManager serviceManager ) | |||
{ | |||
m_parent = parent; | |||
m_serviceManager = serviceManager; | |||
@@ -159,7 +159,7 @@ public class DefaultTaskContext | |||
{ | |||
return m_serviceManager.getService( serviceClass ); | |||
} | |||
catch( final ServiceException se ) | |||
catch( final AntServiceException se ) | |||
{ | |||
throw new TaskException( se.getMessage(), se ); | |||
} | |||
@@ -14,10 +14,6 @@ import java.util.Map; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.avalon.framework.activity.Initializable; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.component.DefaultComponentManager; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.avalon.framework.logger.LogKitLogger; | |||
@@ -25,6 +21,10 @@ 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.ServiceManager; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.DefaultServiceManager; | |||
import org.apache.log.Hierarchy; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.myrmidon.api.TaskException; | |||
@@ -38,7 +38,7 @@ import org.apache.myrmidon.interfaces.model.Project; | |||
import org.apache.myrmidon.interfaces.model.Target; | |||
import org.apache.myrmidon.interfaces.model.TypeLib; | |||
import org.apache.myrmidon.interfaces.service.MultiSourceServiceManager; | |||
import org.apache.myrmidon.interfaces.service.ServiceManager; | |||
import org.apache.myrmidon.interfaces.service.AntServiceManager; | |||
import org.apache.myrmidon.interfaces.type.TypeManager; | |||
import org.apache.myrmidon.interfaces.workspace.Workspace; | |||
import org.apache.myrmidon.listeners.ProjectListener; | |||
@@ -51,14 +51,14 @@ import org.apache.myrmidon.listeners.ProjectListener; | |||
*/ | |||
public class DefaultWorkspace | |||
extends AbstractLogEnabled | |||
implements Workspace, Composable, Parameterizable, Initializable | |||
implements Workspace, Serviceable, Parameterizable, Initializable | |||
{ | |||
private final static Resources REZ = | |||
ResourceManager.getPackageResources( DefaultWorkspace.class ); | |||
private Executor m_executor; | |||
private ProjectListenerSupport m_listenerSupport = new ProjectListenerSupport(); | |||
private ComponentManager m_componentManager; | |||
private ServiceManager m_serviceManager; | |||
private Parameters m_parameters; | |||
private TaskContext m_baseContext; | |||
private HashMap m_entrys = new HashMap(); | |||
@@ -90,16 +90,16 @@ public class DefaultWorkspace | |||
/** | |||
* Retrieve relevent services needed for engine. | |||
* | |||
* @param componentManager the ComponentManager | |||
* @exception ComponentException if an error occurs | |||
* @param serviceManager the ServiceManager | |||
* @exception ServiceException if an error occurs | |||
*/ | |||
public void compose( final ComponentManager componentManager ) | |||
throws ComponentException | |||
public void service( final ServiceManager serviceManager ) | |||
throws ServiceException | |||
{ | |||
m_componentManager = componentManager; | |||
m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); | |||
m_executor = (Executor)componentManager.lookup( Executor.ROLE ); | |||
m_deployer = (Deployer)componentManager.lookup( Deployer.ROLE ); | |||
m_serviceManager = serviceManager; | |||
m_typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE ); | |||
m_executor = (Executor)serviceManager.lookup( Executor.ROLE ); | |||
m_deployer = (Deployer)serviceManager.lookup( Deployer.ROLE ); | |||
} | |||
public void parameterize( final Parameters parameters ) | |||
@@ -226,48 +226,47 @@ public class DefaultWorkspace | |||
* Creates an execution frame for a project. | |||
*/ | |||
private ExecutionFrame createExecutionFrame( final Project project ) | |||
throws TaskException, ComponentException | |||
throws TaskException, ServiceException | |||
{ | |||
//Create per frame ComponentManager | |||
final DefaultComponentManager componentManager = | |||
new DefaultComponentManager( m_componentManager ); | |||
final DefaultServiceManager serviceManager = | |||
new DefaultServiceManager( m_serviceManager ); | |||
//Add in child type manager so each frame can register different | |||
//sets of tasks etc | |||
final TypeManager typeManager = m_typeManager.createChildTypeManager(); | |||
componentManager.put( TypeManager.ROLE, typeManager ); | |||
serviceManager.put( TypeManager.ROLE, typeManager ); | |||
//We need to create a new deployer so that it deploys | |||
//to project specific TypeManager | |||
final Deployer deployer; | |||
deployer = m_deployer.createChildDeployer( componentManager ); | |||
componentManager.put( Deployer.ROLE, deployer ); | |||
final Deployer deployer = m_deployer.createChildDeployer( serviceManager ); | |||
serviceManager.put( Deployer.ROLE, deployer ); | |||
// Deploy the imported typelibs | |||
deployTypeLib( deployer, project ); | |||
//We need to place projects and ProjectManager | |||
//in ComponentManager so as to support project-local call() | |||
componentManager.put( Workspace.ROLE, this ); | |||
componentManager.put( Project.ROLE, project ); | |||
serviceManager.put( Workspace.ROLE, this ); | |||
serviceManager.put( Project.ROLE, project ); | |||
final String[] names = project.getProjectNames(); | |||
for( int i = 0; i < names.length; i++ ) | |||
{ | |||
final String name = names[ i ]; | |||
final Project other = project.getProject( name ); | |||
componentManager.put( Project.ROLE + "/" + name, other ); | |||
serviceManager.put( Project.ROLE + "/" + name, other ); | |||
} | |||
// Create a service manager that aggregates the contents of the context's | |||
// component manager, and service manager | |||
final MultiSourceServiceManager serviceManager = new MultiSourceServiceManager(); | |||
serviceManager.add( (ServiceManager)componentManager.lookup( ServiceManager.ROLE ) ); | |||
serviceManager.add( new ComponentManagerAdaptor( componentManager ) ); | |||
final MultiSourceServiceManager msServiceManager = new MultiSourceServiceManager(); | |||
msServiceManager.add( (AntServiceManager)serviceManager.lookup( AntServiceManager.ROLE ) ); | |||
msServiceManager.add( new ServiceManagerAdaptor( serviceManager ) ); | |||
// Create and configure the context | |||
final DefaultTaskContext context = | |||
new DefaultTaskContext( m_baseContext, serviceManager ); | |||
new DefaultTaskContext( m_baseContext, msServiceManager ); | |||
context.setProperty( TaskContext.BASE_DIRECTORY, project.getBaseDirectory() ); | |||
// Create a logger | |||
@@ -280,7 +279,7 @@ public class DefaultWorkspace | |||
/** | |||
* @todo Should no occur but done for the time being to simplify evolution. | |||
*/ | |||
componentManager.put( ExecutionFrame.ROLE, frame ); | |||
serviceManager.put( ExecutionFrame.ROLE, frame ); | |||
return frame; | |||
} | |||
@@ -0,0 +1,54 @@ | |||
/* | |||
* 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.myrmidon.components.workspace; | |||
import org.apache.myrmidon.interfaces.service.AntServiceException; | |||
import org.apache.myrmidon.interfaces.service.AntServiceManager; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
/** | |||
* An adaptor from {@link ServiceManager} to {@link AntServiceManager}. | |||
* | |||
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||
* @version $Revision$ $Date$ | |||
*/ | |||
class ServiceManagerAdaptor | |||
implements AntServiceManager | |||
{ | |||
private final ServiceManager m_serviceManager; | |||
public ServiceManagerAdaptor( final ServiceManager componentManager ) | |||
{ | |||
m_serviceManager = componentManager; | |||
} | |||
/** | |||
* Determines if this service manager contains a particular service. | |||
*/ | |||
public boolean hasService( Class serviceType ) | |||
{ | |||
return m_serviceManager.hasService( serviceType.getName() ); | |||
} | |||
/** | |||
* Locates a service instance. | |||
*/ | |||
public Object getService( Class serviceType ) | |||
throws AntServiceException | |||
{ | |||
try | |||
{ | |||
return m_serviceManager.lookup( serviceType.getName() ); | |||
} | |||
catch( final ServiceException se ) | |||
{ | |||
throw new AntServiceException( se.getMessage(), se ); | |||
} | |||
} | |||
} |
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.framework; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.myrmidon.api.TaskContext; | |||
import org.apache.myrmidon.api.TaskException; | |||
@@ -18,7 +17,6 @@ import org.apache.myrmidon.api.TaskException; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public class Condition | |||
implements Component | |||
{ | |||
private String m_condition; | |||
private boolean m_isIfCondition; | |||
@@ -12,7 +12,7 @@ import org.apache.aut.nativelib.ExecException; | |||
import org.apache.aut.nativelib.impl.DefaultExecManager; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.myrmidon.interfaces.service.ServiceException; | |||
import org.apache.myrmidon.interfaces.service.AntServiceException; | |||
import org.apache.myrmidon.interfaces.service.ServiceFactory; | |||
/** | |||
@@ -31,7 +31,7 @@ public class ExecManagerFactory | |||
* Create the ExecManager Service. | |||
*/ | |||
public Object createService() | |||
throws ServiceException | |||
throws AntServiceException | |||
{ | |||
final File home = getHomeDirectory(); | |||
try | |||
@@ -40,7 +40,7 @@ public class ExecManagerFactory | |||
} | |||
catch( final ExecException ee ) | |||
{ | |||
throw new ServiceException( ee.getMessage(), ee ); | |||
throw new AntServiceException( ee.getMessage(), ee ); | |||
} | |||
} | |||
@@ -48,13 +48,13 @@ public class ExecManagerFactory | |||
* Utility method to retrieve home directory. | |||
*/ | |||
private static File getHomeDirectory() | |||
throws ServiceException | |||
throws AntServiceException | |||
{ | |||
final String home = System.getProperty( "myrmidon.home" ); | |||
if( null == home ) | |||
{ | |||
final String message = REZ.getString( "missing-home-dir.error" ); | |||
throw new ServiceException( message ); | |||
throw new AntServiceException( message ); | |||
} | |||
return new File( home ); | |||
@@ -11,7 +11,7 @@ import org.apache.aut.vfs.FileSystemManager; | |||
import org.apache.aut.vfs.impl.DefaultFileSystemManager; | |||
import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
import org.apache.avalon.excalibur.i18n.Resources; | |||
import org.apache.myrmidon.interfaces.service.ServiceException; | |||
import org.apache.myrmidon.interfaces.service.AntServiceException; | |||
import org.apache.myrmidon.interfaces.service.ServiceFactory; | |||
/** | |||
@@ -30,7 +30,7 @@ public class VfsManagerFactory | |||
* Create a service that coresponds to this factory. | |||
*/ | |||
public Object createService() | |||
throws ServiceException | |||
throws AntServiceException | |||
{ | |||
try | |||
{ | |||
@@ -39,7 +39,7 @@ public class VfsManagerFactory | |||
catch( Exception e ) | |||
{ | |||
final String message = REZ.getString( "create-vfs-manager.error" ); | |||
throw new ServiceException( message ); | |||
throw new AntServiceException( message ); | |||
} | |||
} | |||
} |
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.aspect; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.parameters.Parameters; | |||
import org.apache.myrmidon.api.TaskException; | |||
@@ -20,7 +19,7 @@ import org.apache.myrmidon.aspects.AspectHandler; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface AspectManager | |||
extends Component, AspectHandler | |||
extends AspectHandler | |||
{ | |||
String ROLE = AspectManager.class.getName(); | |||
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.builder; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.myrmidon.interfaces.model.Project; | |||
/** | |||
@@ -18,7 +17,6 @@ import org.apache.myrmidon.interfaces.model.Project; | |||
* @ant:role shorthand="project-builder" | |||
*/ | |||
public interface ProjectBuilder | |||
extends Component | |||
{ | |||
String ROLE = ProjectBuilder.class.getName(); | |||
@@ -27,8 +25,7 @@ public interface ProjectBuilder | |||
* | |||
* @param source the source | |||
* @return the constructed Project | |||
* @exception IOException if an error occurs | |||
* @exception AntException if an error occurs | |||
* @exception Exception if an error occurs | |||
*/ | |||
Project build( String source ) | |||
throws Exception; | |||
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.configurer; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||
import org.apache.avalon.framework.context.Context; | |||
@@ -19,7 +18,6 @@ import org.apache.avalon.framework.context.Context; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface Configurer | |||
extends Component | |||
{ | |||
String ROLE = Configurer.class.getName(); | |||
@@ -7,8 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.converter; | |||
import org.apache.avalon.framework.component.Component; | |||
/** | |||
* Interface for registry for ConverterInfos. | |||
* | |||
@@ -16,7 +14,6 @@ import org.apache.avalon.framework.component.Component; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface ConverterRegistry | |||
extends Component | |||
{ | |||
String ROLE = ConverterRegistry.class.getName(); | |||
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.converter; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.aut.converter.Converter; | |||
/** | |||
@@ -17,7 +16,7 @@ import org.apache.aut.converter.Converter; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface MasterConverter | |||
extends Component, Converter | |||
extends Converter | |||
{ | |||
String ROLE = MasterConverter.class.getName(); | |||
} |
@@ -8,9 +8,8 @@ | |||
package org.apache.myrmidon.interfaces.deployer; | |||
import java.io.File; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
/** | |||
* This class deploys type libraries into a registry. | |||
@@ -19,7 +18,6 @@ import org.apache.avalon.framework.component.ComponentManager; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface Deployer | |||
extends Component | |||
{ | |||
String ROLE = Deployer.class.getName(); | |||
@@ -46,6 +44,6 @@ public interface Deployer | |||
/** | |||
* Creates a child deployer. | |||
*/ | |||
Deployer createChildDeployer( ComponentManager componentManager ) | |||
throws ComponentException; | |||
Deployer createChildDeployer( ServiceManager componentManager ) | |||
throws ServiceException; | |||
} |
@@ -10,7 +10,6 @@ package org.apache.myrmidon.interfaces.embeddor; | |||
import org.apache.avalon.framework.activity.Disposable; | |||
import org.apache.avalon.framework.activity.Initializable; | |||
import org.apache.avalon.framework.activity.Startable; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.parameters.Parameterizable; | |||
import org.apache.avalon.framework.parameters.Parameters; | |||
import org.apache.myrmidon.interfaces.model.Project; | |||
@@ -24,7 +23,7 @@ import org.apache.myrmidon.listeners.ProjectListener; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface Embeddor | |||
extends Component, Parameterizable, Initializable, Startable, Disposable | |||
extends Parameterizable, Initializable, Startable, Disposable | |||
{ | |||
String ROLE = Embeddor.class.getName(); | |||
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.executor; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.myrmidon.api.TaskException; | |||
@@ -18,7 +17,6 @@ import org.apache.myrmidon.api.TaskException; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface Executor | |||
extends Component | |||
{ | |||
String ROLE = Executor.class.getName(); | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.myrmidon.interfaces.extensions; | |||
import org.apache.avalon.excalibur.extension.PackageRepository; | |||
import org.apache.avalon.framework.component.Component; | |||
/** | |||
* PackageRepository | |||
@@ -17,7 +16,7 @@ import org.apache.avalon.framework.component.Component; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface ExtensionManager | |||
extends PackageRepository, Component | |||
extends PackageRepository | |||
{ | |||
String ROLE = ExtensionManager.class.getName(); | |||
} |
@@ -8,7 +8,6 @@ | |||
package org.apache.myrmidon.interfaces.model; | |||
import java.io.File; | |||
import org.apache.avalon.framework.component.Component; | |||
/** | |||
* Abstraction used to interact with projects. | |||
@@ -18,7 +17,6 @@ import org.apache.avalon.framework.component.Component; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface Project | |||
extends Component | |||
{ | |||
String ROLE = Project.class.getName(); | |||
@@ -7,8 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.role; | |||
import org.apache.avalon.framework.component.Component; | |||
/** | |||
* Interface to manage roles and mapping to shorthand names. | |||
* | |||
@@ -19,7 +17,6 @@ import org.apache.avalon.framework.component.Component; | |||
* @version CVS $Revision$ $Date$ | |||
*/ | |||
public interface RoleManager | |||
extends Component | |||
{ | |||
String ROLE = RoleManager.class.getName(); | |||
@@ -16,13 +16,13 @@ import org.apache.avalon.framework.CascadingException; | |||
* @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public class ServiceException | |||
public class AntServiceException | |||
extends CascadingException | |||
{ | |||
/** | |||
* Basic constructor for exception that does not specify a message | |||
*/ | |||
public ServiceException() | |||
public AntServiceException() | |||
{ | |||
this( "", null ); | |||
} | |||
@@ -32,7 +32,7 @@ public class ServiceException | |||
* | |||
* @param message the message | |||
*/ | |||
public ServiceException( final String message ) | |||
public AntServiceException( final String message ) | |||
{ | |||
this( message, null ); | |||
} | |||
@@ -43,7 +43,7 @@ public class ServiceException | |||
* @param message the message | |||
* @param throwable the throwable | |||
*/ | |||
public ServiceException( final String message, final Throwable throwable ) | |||
public AntServiceException( final String message, final Throwable throwable ) | |||
{ | |||
super( message, throwable ); | |||
} |
@@ -7,18 +7,15 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.service; | |||
import org.apache.avalon.framework.component.Component; | |||
/** | |||
* Manages a set of services. | |||
* | |||
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface ServiceManager | |||
extends Component | |||
public interface AntServiceManager | |||
{ | |||
String ROLE = ServiceManager.class.getName(); | |||
String ROLE = AntServiceManager.class.getName(); | |||
/** | |||
* Determines if this service manager contains a particular service. | |||
@@ -33,8 +30,8 @@ public interface ServiceManager | |||
* @param serviceType The service interface. | |||
* @return The service instance. The returned object is guaranteed to | |||
* implement the service interface. | |||
* @throws ServiceException If the service does not exist. | |||
* @throws AntServiceException If the service does not exist. | |||
*/ | |||
Object getService( Class serviceType ) | |||
throws ServiceException; | |||
throws AntServiceException; | |||
} |
@@ -13,13 +13,13 @@ import org.apache.avalon.excalibur.i18n.Resources; | |||
/** | |||
* A service manager that aggregates services from several | |||
* {@link ServiceManager} objects. | |||
* {@link AntServiceManager} objects. | |||
* | |||
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public class MultiSourceServiceManager | |||
implements ServiceManager | |||
implements AntServiceManager | |||
{ | |||
private final static Resources REZ | |||
= ResourceManager.getPackageResources( MultiSourceServiceManager.class ); | |||
@@ -30,7 +30,7 @@ public class MultiSourceServiceManager | |||
/** | |||
* Adds a service manager to the end of the source list. | |||
*/ | |||
public void add( final ServiceManager mgr ) | |||
public void add( final AntServiceManager mgr ) | |||
{ | |||
m_sources.add( mgr ); | |||
} | |||
@@ -45,7 +45,7 @@ public class MultiSourceServiceManager | |||
final int size = m_sources.size(); | |||
for( int i = 0; i < size; i++ ) | |||
{ | |||
final ServiceManager serviceManager = (ServiceManager)m_sources.get( i ); | |||
final AntServiceManager serviceManager = (AntServiceManager)m_sources.get( i ); | |||
if( serviceManager.hasService( serviceType ) ) | |||
{ | |||
return true; | |||
@@ -60,15 +60,15 @@ public class MultiSourceServiceManager | |||
* @param serviceType The service interface. | |||
* @return The service instance. The returned object is guaranteed to | |||
* implement the service interface. | |||
* @throws ServiceException If the service does not exist. | |||
* @throws AntServiceException If the service does not exist. | |||
*/ | |||
public Object getService( final Class serviceType ) | |||
throws ServiceException | |||
throws AntServiceException | |||
{ | |||
final int size = m_sources.size(); | |||
for( int i = 0; i < size; i++ ) | |||
{ | |||
final ServiceManager serviceManager = (ServiceManager)m_sources.get( i ); | |||
final AntServiceManager serviceManager = (AntServiceManager)m_sources.get( i ); | |||
if( serviceManager.hasService( serviceType ) ) | |||
{ | |||
return serviceManager.getService( serviceType ); | |||
@@ -76,6 +76,6 @@ public class MultiSourceServiceManager | |||
} | |||
final String message = REZ.getString( "unknown-service.error", serviceType.getName() ); | |||
throw new ServiceException( message ); | |||
throw new AntServiceException( message ); | |||
} | |||
} |
@@ -25,5 +25,5 @@ public interface ServiceFactory | |||
* prepared and configured as appropriate. | |||
*/ | |||
Object createService() | |||
throws ServiceException; | |||
throws AntServiceException; | |||
} |
@@ -7,8 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.type; | |||
import org.apache.avalon.framework.component.Component; | |||
/** | |||
* The interface that is used to manage types. | |||
* | |||
@@ -16,7 +14,6 @@ import org.apache.avalon.framework.component.Component; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface TypeManager | |||
extends Component | |||
{ | |||
String ROLE = TypeManager.class.getName(); | |||
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.myrmidon.interfaces.workspace; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.myrmidon.interfaces.model.Project; | |||
import org.apache.myrmidon.listeners.ProjectListener; | |||
@@ -19,7 +18,6 @@ import org.apache.myrmidon.listeners.ProjectListener; | |||
* @version $Revision$ $Date$ | |||
*/ | |||
public interface Workspace | |||
extends Component | |||
{ | |||
String ROLE = Workspace.class.getName(); | |||
@@ -10,13 +10,12 @@ package org.apache.myrmidon.components; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.component.DefaultComponentManager; | |||
import org.apache.avalon.framework.logger.LogEnabled; | |||
import org.apache.avalon.framework.logger.Logger; | |||
import org.apache.avalon.framework.service.DefaultServiceManager; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.myrmidon.AbstractMyrmidonTest; | |||
import org.apache.myrmidon.components.configurer.DefaultConfigurer; | |||
import org.apache.myrmidon.components.converter.DefaultConverterRegistry; | |||
@@ -26,7 +25,6 @@ import org.apache.myrmidon.components.deployer.DefaultClassLoaderManager; | |||
import org.apache.myrmidon.components.deployer.DefaultDeployer; | |||
import org.apache.myrmidon.components.extensions.DefaultExtensionManager; | |||
import org.apache.myrmidon.components.role.DefaultRoleManager; | |||
import org.apache.myrmidon.components.service.DefaultServiceManager; | |||
import org.apache.myrmidon.components.type.DefaultTypeManager; | |||
import org.apache.aut.converter.Converter; | |||
import org.apache.myrmidon.interfaces.configurer.Configurer; | |||
@@ -35,7 +33,6 @@ import org.apache.myrmidon.interfaces.converter.MasterConverter; | |||
import org.apache.myrmidon.interfaces.deployer.Deployer; | |||
import org.apache.myrmidon.interfaces.extensions.ExtensionManager; | |||
import org.apache.myrmidon.interfaces.role.RoleManager; | |||
import org.apache.myrmidon.interfaces.service.ServiceManager; | |||
import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; | |||
import org.apache.myrmidon.interfaces.type.TypeException; | |||
import org.apache.myrmidon.interfaces.type.TypeManager; | |||
@@ -48,7 +45,7 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
public abstract class AbstractComponentTest | |||
extends AbstractMyrmidonTest | |||
{ | |||
private DefaultComponentManager m_componentManager; | |||
private DefaultServiceManager m_serviceManager; | |||
private Logger m_logger; | |||
public AbstractComponentTest( final String name ) | |||
@@ -59,17 +56,18 @@ public abstract class AbstractComponentTest | |||
/** | |||
* Returns the component manager containing the components to test. | |||
*/ | |||
protected ComponentManager getComponentManager() | |||
protected ServiceManager getServiceManager() | |||
{ | |||
return m_componentManager; | |||
return m_serviceManager; | |||
} | |||
/** | |||
* Returns the type manager. | |||
*/ | |||
protected TypeManager getTypeManager() throws ComponentException | |||
protected TypeManager getTypeManager() | |||
throws ServiceException | |||
{ | |||
return (TypeManager)getComponentManager().lookup( TypeManager.ROLE ); | |||
return (TypeManager)getServiceManager().lookup( TypeManager.ROLE ); | |||
} | |||
/** | |||
@@ -81,44 +79,44 @@ public abstract class AbstractComponentTest | |||
m_logger = createLogger(); | |||
// Create the components | |||
m_componentManager = new DefaultComponentManager(); | |||
m_serviceManager = new DefaultServiceManager(); | |||
List components = new ArrayList(); | |||
Component component = new DefaultMasterConverter(); | |||
m_componentManager.put( MasterConverter.ROLE, component ); | |||
Object component = new DefaultMasterConverter(); | |||
m_serviceManager.put( MasterConverter.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultConverterRegistry(); | |||
m_componentManager.put( ConverterRegistry.ROLE, component ); | |||
m_serviceManager.put( ConverterRegistry.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultTypeManager(); | |||
m_componentManager.put( TypeManager.ROLE, component ); | |||
m_serviceManager.put( TypeManager.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultConfigurer(); | |||
m_componentManager.put( Configurer.ROLE, component ); | |||
m_serviceManager.put( Configurer.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultDeployer(); | |||
m_componentManager.put( Deployer.ROLE, component ); | |||
m_serviceManager.put( Deployer.ROLE, component ); | |||
components.add( component ); | |||
final DefaultClassLoaderManager classLoaderMgr = new DefaultClassLoaderManager(); | |||
classLoaderMgr.setBaseClassLoader( getClass().getClassLoader() ); | |||
m_componentManager.put( ClassLoaderManager.ROLE, classLoaderMgr ); | |||
m_serviceManager.put( ClassLoaderManager.ROLE, classLoaderMgr ); | |||
components.add( classLoaderMgr ); | |||
component = new DefaultExtensionManager(); | |||
m_componentManager.put( ExtensionManager.ROLE, component ); | |||
m_serviceManager.put( ExtensionManager.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultRoleManager(); | |||
m_componentManager.put( RoleManager.ROLE, component ); | |||
m_serviceManager.put( RoleManager.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultServiceManager(); | |||
m_componentManager.put( ServiceManager.ROLE, component ); | |||
m_serviceManager.put( ServiceManager.ROLE, component ); | |||
components.add( component ); | |||
// Log enable the components | |||
@@ -136,10 +134,10 @@ public abstract class AbstractComponentTest | |||
for( Iterator iterator = components.iterator(); iterator.hasNext(); ) | |||
{ | |||
Object obj = iterator.next(); | |||
if( obj instanceof Composable ) | |||
if( obj instanceof Serviceable ) | |||
{ | |||
final Composable composable = (Composable)obj; | |||
composable.compose( m_componentManager ); | |||
final Serviceable serviceable = (Serviceable)obj; | |||
serviceable.service( m_serviceManager ); | |||
} | |||
} | |||
} | |||
@@ -151,9 +149,9 @@ public abstract class AbstractComponentTest | |||
protected void registerConverter( final Class converterClass, | |||
final Class sourceClass, | |||
final Class destClass ) | |||
throws ComponentException, TypeException | |||
throws ServiceException, TypeException | |||
{ | |||
ConverterRegistry converterRegistry = (ConverterRegistry)getComponentManager().lookup( ConverterRegistry.ROLE ); | |||
ConverterRegistry converterRegistry = (ConverterRegistry)getServiceManager().lookup( ConverterRegistry.ROLE ); | |||
converterRegistry.registerConverter( converterClass.getName(), sourceClass.getName(), destClass.getName() ); | |||
DefaultTypeFactory factory = new DefaultTypeFactory( getClass().getClassLoader() ); | |||
factory.addNameClassMapping( converterClass.getName(), converterClass.getName() ); | |||
@@ -49,7 +49,7 @@ public class DefaultConfigurerTest | |||
super.setUp(); | |||
// Find the configurer | |||
m_configurer = (Configurer)getComponentManager().lookup( Configurer.ROLE ); | |||
m_configurer = (Configurer)getServiceManager().lookup( Configurer.ROLE ); | |||
// Setup a context | |||
m_context = new DefaultTaskContext(); | |||
@@ -434,7 +434,7 @@ public class DefaultConfigurerTest | |||
config.setAttribute( "my-role1", "some value" ); | |||
// Set up the converter and role | |||
RoleManager roleMgr = (RoleManager)getComponentManager().lookup( RoleManager.ROLE ); | |||
RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); | |||
roleMgr.addNameRoleMapping( "my-role1", MyRole1.ROLE ); | |||
registerConverter( StringToMyRole1Converter.class, String.class, MyRole1.class ); | |||
@@ -611,7 +611,7 @@ public class DefaultConfigurerTest | |||
config.addChild( child ); | |||
// Add role mapping, and add to reference to context | |||
final RoleManager roleMgr = (RoleManager)getComponentManager().lookup( RoleManager.ROLE ); | |||
final RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); | |||
roleMgr.addNameRoleMapping( "my-role1", MyRole1.class.getName() ); | |||
m_context.setProperty( "id", new MyType1() ); | |||
m_context.setProperty( "id2", new MyType2() ); | |||
@@ -49,11 +49,11 @@ public class DefaultDeployerTest | |||
protected void setUp() throws Exception | |||
{ | |||
super.setUp(); | |||
m_deployer = (Deployer)getComponentManager().lookup( Deployer.ROLE ); | |||
m_converter = (MasterConverter)getComponentManager().lookup( MasterConverter.ROLE ); | |||
m_deployer = (Deployer)getServiceManager().lookup( Deployer.ROLE ); | |||
m_converter = (MasterConverter)getServiceManager().lookup( MasterConverter.ROLE ); | |||
// Add some core roles | |||
m_roleManager = (RoleManager)getComponentManager().lookup( RoleManager.ROLE ); | |||
m_roleManager = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); | |||
m_roleManager.addNameRoleMapping( DATA_TYPE_ROLE, DataType.ROLE ); | |||
m_roleManager.addNameRoleMapping( "converter", Converter.ROLE ); | |||
} | |||
@@ -10,13 +10,12 @@ package org.apache.myrmidon.components; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import org.apache.avalon.framework.component.Component; | |||
import org.apache.avalon.framework.component.ComponentException; | |||
import org.apache.avalon.framework.component.ComponentManager; | |||
import org.apache.avalon.framework.component.Composable; | |||
import org.apache.avalon.framework.component.DefaultComponentManager; | |||
import org.apache.avalon.framework.logger.LogEnabled; | |||
import org.apache.avalon.framework.logger.Logger; | |||
import org.apache.avalon.framework.service.DefaultServiceManager; | |||
import org.apache.avalon.framework.service.ServiceManager; | |||
import org.apache.avalon.framework.service.ServiceException; | |||
import org.apache.avalon.framework.service.Serviceable; | |||
import org.apache.myrmidon.AbstractMyrmidonTest; | |||
import org.apache.myrmidon.components.configurer.DefaultConfigurer; | |||
import org.apache.myrmidon.components.converter.DefaultConverterRegistry; | |||
@@ -26,7 +25,6 @@ import org.apache.myrmidon.components.deployer.DefaultClassLoaderManager; | |||
import org.apache.myrmidon.components.deployer.DefaultDeployer; | |||
import org.apache.myrmidon.components.extensions.DefaultExtensionManager; | |||
import org.apache.myrmidon.components.role.DefaultRoleManager; | |||
import org.apache.myrmidon.components.service.DefaultServiceManager; | |||
import org.apache.myrmidon.components.type.DefaultTypeManager; | |||
import org.apache.aut.converter.Converter; | |||
import org.apache.myrmidon.interfaces.configurer.Configurer; | |||
@@ -35,7 +33,6 @@ import org.apache.myrmidon.interfaces.converter.MasterConverter; | |||
import org.apache.myrmidon.interfaces.deployer.Deployer; | |||
import org.apache.myrmidon.interfaces.extensions.ExtensionManager; | |||
import org.apache.myrmidon.interfaces.role.RoleManager; | |||
import org.apache.myrmidon.interfaces.service.ServiceManager; | |||
import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; | |||
import org.apache.myrmidon.interfaces.type.TypeException; | |||
import org.apache.myrmidon.interfaces.type.TypeManager; | |||
@@ -48,7 +45,7 @@ import org.apache.myrmidon.interfaces.type.TypeManager; | |||
public abstract class AbstractComponentTest | |||
extends AbstractMyrmidonTest | |||
{ | |||
private DefaultComponentManager m_componentManager; | |||
private DefaultServiceManager m_serviceManager; | |||
private Logger m_logger; | |||
public AbstractComponentTest( final String name ) | |||
@@ -59,17 +56,18 @@ public abstract class AbstractComponentTest | |||
/** | |||
* Returns the component manager containing the components to test. | |||
*/ | |||
protected ComponentManager getComponentManager() | |||
protected ServiceManager getServiceManager() | |||
{ | |||
return m_componentManager; | |||
return m_serviceManager; | |||
} | |||
/** | |||
* Returns the type manager. | |||
*/ | |||
protected TypeManager getTypeManager() throws ComponentException | |||
protected TypeManager getTypeManager() | |||
throws ServiceException | |||
{ | |||
return (TypeManager)getComponentManager().lookup( TypeManager.ROLE ); | |||
return (TypeManager)getServiceManager().lookup( TypeManager.ROLE ); | |||
} | |||
/** | |||
@@ -81,44 +79,44 @@ public abstract class AbstractComponentTest | |||
m_logger = createLogger(); | |||
// Create the components | |||
m_componentManager = new DefaultComponentManager(); | |||
m_serviceManager = new DefaultServiceManager(); | |||
List components = new ArrayList(); | |||
Component component = new DefaultMasterConverter(); | |||
m_componentManager.put( MasterConverter.ROLE, component ); | |||
Object component = new DefaultMasterConverter(); | |||
m_serviceManager.put( MasterConverter.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultConverterRegistry(); | |||
m_componentManager.put( ConverterRegistry.ROLE, component ); | |||
m_serviceManager.put( ConverterRegistry.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultTypeManager(); | |||
m_componentManager.put( TypeManager.ROLE, component ); | |||
m_serviceManager.put( TypeManager.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultConfigurer(); | |||
m_componentManager.put( Configurer.ROLE, component ); | |||
m_serviceManager.put( Configurer.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultDeployer(); | |||
m_componentManager.put( Deployer.ROLE, component ); | |||
m_serviceManager.put( Deployer.ROLE, component ); | |||
components.add( component ); | |||
final DefaultClassLoaderManager classLoaderMgr = new DefaultClassLoaderManager(); | |||
classLoaderMgr.setBaseClassLoader( getClass().getClassLoader() ); | |||
m_componentManager.put( ClassLoaderManager.ROLE, classLoaderMgr ); | |||
m_serviceManager.put( ClassLoaderManager.ROLE, classLoaderMgr ); | |||
components.add( classLoaderMgr ); | |||
component = new DefaultExtensionManager(); | |||
m_componentManager.put( ExtensionManager.ROLE, component ); | |||
m_serviceManager.put( ExtensionManager.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultRoleManager(); | |||
m_componentManager.put( RoleManager.ROLE, component ); | |||
m_serviceManager.put( RoleManager.ROLE, component ); | |||
components.add( component ); | |||
component = new DefaultServiceManager(); | |||
m_componentManager.put( ServiceManager.ROLE, component ); | |||
m_serviceManager.put( ServiceManager.ROLE, component ); | |||
components.add( component ); | |||
// Log enable the components | |||
@@ -136,10 +134,10 @@ public abstract class AbstractComponentTest | |||
for( Iterator iterator = components.iterator(); iterator.hasNext(); ) | |||
{ | |||
Object obj = iterator.next(); | |||
if( obj instanceof Composable ) | |||
if( obj instanceof Serviceable ) | |||
{ | |||
final Composable composable = (Composable)obj; | |||
composable.compose( m_componentManager ); | |||
final Serviceable serviceable = (Serviceable)obj; | |||
serviceable.service( m_serviceManager ); | |||
} | |||
} | |||
} | |||
@@ -151,9 +149,9 @@ public abstract class AbstractComponentTest | |||
protected void registerConverter( final Class converterClass, | |||
final Class sourceClass, | |||
final Class destClass ) | |||
throws ComponentException, TypeException | |||
throws ServiceException, TypeException | |||
{ | |||
ConverterRegistry converterRegistry = (ConverterRegistry)getComponentManager().lookup( ConverterRegistry.ROLE ); | |||
ConverterRegistry converterRegistry = (ConverterRegistry)getServiceManager().lookup( ConverterRegistry.ROLE ); | |||
converterRegistry.registerConverter( converterClass.getName(), sourceClass.getName(), destClass.getName() ); | |||
DefaultTypeFactory factory = new DefaultTypeFactory( getClass().getClassLoader() ); | |||
factory.addNameClassMapping( converterClass.getName(), converterClass.getName() ); | |||
@@ -49,7 +49,7 @@ public class DefaultConfigurerTest | |||
super.setUp(); | |||
// Find the configurer | |||
m_configurer = (Configurer)getComponentManager().lookup( Configurer.ROLE ); | |||
m_configurer = (Configurer)getServiceManager().lookup( Configurer.ROLE ); | |||
// Setup a context | |||
m_context = new DefaultTaskContext(); | |||
@@ -434,7 +434,7 @@ public class DefaultConfigurerTest | |||
config.setAttribute( "my-role1", "some value" ); | |||
// Set up the converter and role | |||
RoleManager roleMgr = (RoleManager)getComponentManager().lookup( RoleManager.ROLE ); | |||
RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); | |||
roleMgr.addNameRoleMapping( "my-role1", MyRole1.ROLE ); | |||
registerConverter( StringToMyRole1Converter.class, String.class, MyRole1.class ); | |||
@@ -611,7 +611,7 @@ public class DefaultConfigurerTest | |||
config.addChild( child ); | |||
// Add role mapping, and add to reference to context | |||
final RoleManager roleMgr = (RoleManager)getComponentManager().lookup( RoleManager.ROLE ); | |||
final RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); | |||
roleMgr.addNameRoleMapping( "my-role1", MyRole1.class.getName() ); | |||
m_context.setProperty( "id", new MyType1() ); | |||
m_context.setProperty( "id2", new MyType2() ); | |||
@@ -49,11 +49,11 @@ public class DefaultDeployerTest | |||
protected void setUp() throws Exception | |||
{ | |||
super.setUp(); | |||
m_deployer = (Deployer)getComponentManager().lookup( Deployer.ROLE ); | |||
m_converter = (MasterConverter)getComponentManager().lookup( MasterConverter.ROLE ); | |||
m_deployer = (Deployer)getServiceManager().lookup( Deployer.ROLE ); | |||
m_converter = (MasterConverter)getServiceManager().lookup( MasterConverter.ROLE ); | |||
// Add some core roles | |||
m_roleManager = (RoleManager)getComponentManager().lookup( RoleManager.ROLE ); | |||
m_roleManager = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); | |||
m_roleManager.addNameRoleMapping( DATA_TYPE_ROLE, DataType.ROLE ); | |||
m_roleManager.addNameRoleMapping( "converter", Converter.ROLE ); | |||
} | |||