You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2003/04/11 21:26:01 UTC
cvs commit: avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance MappedServiceManager.java DefaultApplianceFactory.java ApplianceHolder.java DefaultApplianceContext.java BlockURLHandler.java DefaultAppliance.java ContextBuilder.java BlockURLConnection.java DefaultApplianceRepository.java
leosimons 2003/04/11 12:26:01
Modified: merlin/assembly/src/java/org/apache/avalon/assembly/appliance
MappedServiceManager.java
DefaultApplianceFactory.java ApplianceHolder.java
DefaultApplianceContext.java BlockURLHandler.java
DefaultAppliance.java ContextBuilder.java
BlockURLConnection.java
DefaultApplianceRepository.java
Log:
formatting. No other changes.
Revision Changes Path
1.3 +8 -12 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/MappedServiceManager.java
Index: MappedServiceManager.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/MappedServiceManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MappedServiceManager.java 11 Apr 2003 19:23:56 -0000 1.2
+++ MappedServiceManager.java 11 Apr 2003 19:26:01 -0000 1.3
@@ -66,7 +66,7 @@
* @version 1.0
*/
public class MappedServiceManager
- implements ServiceManager
+ implements ServiceManager
{
private final Map m_objects;
private final ServiceManager m_parent;
@@ -113,8 +113,7 @@
if( map != null )
{
m_objects = map;
- }
- else
+ } else
{
m_objects = new HashMap();
}
@@ -128,18 +127,16 @@
* @throws ServiceException if an error occurs
*/
public Object lookup( final String key )
- throws ServiceException
+ throws ServiceException
{
final Object object = m_objects.get( key );
if( null != object )
{
return object;
- }
- else if( null != m_parent )
+ } else if( null != m_parent )
{
return m_parent.lookup( key );
- }
- else
+ } else
{
final String message = "Unable to provide implementation for " + key;
throw new ServiceException( key, message, null );
@@ -158,8 +155,7 @@
{
lookup( key );
return true;
- }
- catch( final Throwable t )
+ } catch( final Throwable t )
{
return false;
}
@@ -235,12 +231,12 @@
* read-only
*/
protected final void checkWriteable()
- throws IllegalStateException
+ throws IllegalStateException
{
if( m_readOnly )
{
final String message =
- "ServiceManager is read only and can not be modified";
+ "ServiceManager is read only and can not be modified";
throw new IllegalStateException( message );
}
}
1.5 +84 -94 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java
Index: DefaultApplianceFactory.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultApplianceFactory.java 11 Apr 2003 19:23:56 -0000 1.4
+++ DefaultApplianceFactory.java 11 Apr 2003 19:26:01 -0000 1.5
@@ -83,41 +83,41 @@
*/
public class DefaultApplianceFactory extends AbstractLogEnabled
- implements ApplianceFactory, Contextualizable, Initializable
+ implements ApplianceFactory, Contextualizable, Initializable
{
- /**
- * Utility method to create a new default appliance factory.
- * @param loader the engine classloader
- * @param logger the logging channel to apply to the created factory
- * @param repository the appliance repository
- * @param system the context to apply to the appliance factory
- * @return the new appliance factory
- * @exception ApplianceException if a creation error occurs
- */
+ /**
+ * Utility method to create a new default appliance factory.
+ * @param loader the engine classloader
+ * @param logger the logging channel to apply to the created factory
+ * @param repository the appliance repository
+ * @param system the context to apply to the appliance factory
+ * @return the new appliance factory
+ * @exception ApplianceException if a creation error occurs
+ */
public static ApplianceFactory createApplianceFactory(
- EngineClassLoader loader, Logger logger, ApplianceRepository repository,
- Locator system )
- throws ApplianceException
+ EngineClassLoader loader, Logger logger, ApplianceRepository repository,
+ Locator system )
+ throws ApplianceException
{
return createApplianceFactory(
- loader, DefaultApplianceFactory.class.getName(), logger, repository, system );
+ loader, DefaultApplianceFactory.class.getName(), logger, repository, system );
}
- /**
- * Utility method to create a new appliance factory.
- * @param loader the engine classloader
- * @param classname the classname of the appliance factory
- * @param logger the logging channel to apply to the created factory
- * @param repository the appliance repository
- * @param system the context to apply to the appliance factory
- * @return the new appliance factory
- * @exception ApplianceException if a creation error occurs
- */
+ /**
+ * Utility method to create a new appliance factory.
+ * @param loader the engine classloader
+ * @param classname the classname of the appliance factory
+ * @param logger the logging channel to apply to the created factory
+ * @param repository the appliance repository
+ * @param system the context to apply to the appliance factory
+ * @return the new appliance factory
+ * @exception ApplianceException if a creation error occurs
+ */
public static ApplianceFactory createApplianceFactory(
- Engine loader, String classname, Logger logger,
- ApplianceRepository repository, Locator system )
- throws ApplianceException
+ Engine loader, String classname, Logger logger,
+ ApplianceRepository repository, Locator system )
+ throws ApplianceException
{
if( classname == null )
{
@@ -156,11 +156,11 @@
try
{
Type type = loader.getRepository().getTypeManager()
- .getType( classname );
+ .getType( classname );
Profile profile = loader.getRepository().getProfileManager()
- .getProfile( type );
+ .getProfile( type );
DefaultApplianceContext context =
- new DefaultApplianceContext( profile );
+ new DefaultApplianceContext( profile );
context.put( "urn:assembly:appliance.repository", repository );
context.put( "urn:assembly:logging", system.get( "urn:assembly:logging" ) );
context.makeReadOnly();
@@ -170,34 +170,32 @@
if( factory instanceof ApplianceFactory )
{
return (ApplianceFactory) factory;
- }
- else
+ } else
{
final String error =
- "Supplied classname '" + classname
- + "' does not implement the ApplianceFactory interface.";
+ "Supplied classname '" + classname
+ + "' does not implement the ApplianceFactory interface.";
throw new ApplianceException( error );
}
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Could not create appliance factory using : " + classname;
+ "Could not create appliance factory using : " + classname;
throw new ApplianceException( error, e );
}
}
- /**
- * Create of a new instance of the default appliance factory.
- * @param logger the logging channel to apply to the factory
- * @param context the factory context
- * @param repository the appliance repository
- * @return the new factory
- * @exception ApplianceException if a creation error occurs
- */
+ /**
+ * Create of a new instance of the default appliance factory.
+ * @param logger the logging channel to apply to the factory
+ * @param context the factory context
+ * @param repository the appliance repository
+ * @return the new factory
+ * @exception ApplianceException if a creation error occurs
+ */
private static ApplianceFactory createDefaultApplianceFactory(
- final Logger logger, final Locator context, final ApplianceRepository repository )
- throws ApplianceException
+ final Logger logger, final Locator context, final ApplianceRepository repository )
+ throws ApplianceException
{
DefaultApplianceFactory factory = new DefaultApplianceFactory();
factory.enableLogging( logger );
@@ -207,11 +205,10 @@
locator.put( "urn:assembly:appliance.repository", repository );
factory.contextualize( locator );
factory.initialize();
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unexpected error while attempting to create default appliance factory.";
+ "Unexpected error while attempting to create default appliance factory.";
throw new ApplianceException( error, e );
}
return factory;
@@ -254,15 +251,15 @@
// implementation
//---------------------------------------------------------------------------
- /**
- * Create a new appliance.
- * @param context the appliance creation context
- * @param shared TRUE if this appliance can be shared
- * @return the appliance
- */
+ /**
+ * Create a new appliance.
+ * @param context the appliance creation context
+ * @param shared TRUE if this appliance can be shared
+ * @return the appliance
+ */
public Appliance createAppliance(
- Locator system, Engine engine, ApplianceContext context, Logger logger )
- throws ApplianceException
+ Locator system, Engine engine, ApplianceContext context, Logger logger )
+ throws ApplianceException
{
if( engine == null )
{
@@ -294,17 +291,16 @@
locator.put( "urn:assembly:appliance.repository", m_repository );
locator.put( "urn:assembly:threads.manager", m_pool );
locator.makeReadOnly();
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unexpected error while building appliance context.";
+ "Unexpected error while building appliance context.";
throw new ApplianceException( error, e );
}
String classname = context.getApplianceClassname();
- if(( classname == null )
- || ( classname.equals( DefaultAppliance.class.getName() ) ) )
+ if( (classname == null)
+ || (classname.equals( DefaultAppliance.class.getName() )) )
{
//
// bootstrap the appliance using DefaultAppliance
@@ -317,15 +313,13 @@
appliance.contextualize( locator );
appliance.initialize();
return appliance;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unable to create appliance from context: " + context.getName();
+ "Unable to create appliance from context: " + context.getName();
throw new ApplianceException( error, e );
}
- }
- else
+ } else
{
//
// its a custom appliance so in this case we use an apppliance to
@@ -336,12 +330,12 @@
{
Map map = context.getDeploymentContext();
Type type = engine.getRepository()
- .getTypeManager().getType( classname );
+ .getTypeManager().getType( classname );
Profile profile =
- engine.getRepository().getProfileManager()
- .getProfile( type );
+ engine.getRepository().getProfileManager()
+ .getProfile( type );
DefaultApplianceContext cntx =
- new DefaultApplianceContext( profile, map );
+ new DefaultApplianceContext( profile, map );
cntx.put( "urn:assembly:engine", engine );
cntx.put( "urn:assembly:lifestyle.service", lifestyle );
cntx.put( "urn:assembly:appliance.context", context );
@@ -356,32 +350,30 @@
if( object instanceof Appliance )
{
return (Appliance) object;
- }
- else
+ } else
{
final String error =
- "Supplied classname '" + classname
- + "' does not implement the Appliance interface.";
+ "Supplied classname '" + classname
+ + "' does not implement the Appliance interface.";
throw new ApplianceException( error );
}
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Could not create appliance using : " + classname;
+ "Could not create appliance using : " + classname;
throw new ApplianceException( error, e );
}
}
}
- /**
- * Utility to create the default lifestyle service.
- * @param engine the engine classloader
- * @param pool the pool manager
- * @return the lifestyle service
- */
+ /**
+ * Utility to create the default lifestyle service.
+ * @param engine the engine classloader
+ * @param pool the pool manager
+ * @return the lifestyle service
+ */
private LifestyleService createLifestyleService(
- Engine engine, PoolManager pool ) throws ApplianceException
+ Engine engine, PoolManager pool ) throws ApplianceException
{
try
{
@@ -396,17 +388,16 @@
lifestyle.contextualize( context );
lifestyle.initialize();
return lifestyle;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unexpected error during bootstrap lifecycle service creation.";
+ "Unexpected error during bootstrap lifecycle service creation.";
throw new ApplianceException( error, e );
}
}
private DeploymentService createDeploymentService()
- throws ApplianceException
+ throws ApplianceException
{
try
{
@@ -418,11 +409,10 @@
deployment.contextualize( locator );
deployment.initialize();
return deployment;
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Internal error while attempting to create bootstrap deployment service.";
+ "Internal error while attempting to create bootstrap deployment service.";
throw new ApplianceException( error, e );
}
}
1.3 +3 -3 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceHolder.java
Index: ApplianceHolder.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceHolder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ApplianceHolder.java 10 Apr 2003 04:36:13 -0000 1.2
+++ ApplianceHolder.java 11 Apr 2003 19:26:01 -0000 1.3
@@ -53,8 +53,8 @@
import org.apache.avalon.assembly.locator.Resolvable;
/**
- * Utility class used dereference resolution of a reolvable object.
- *
+ * Utility class used dereference resolution of a reolvable object.
+ *
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
* @version $Revision$ $Date$
1.3 +106 -114 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceContext.java
Index: DefaultApplianceContext.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultApplianceContext.java 11 Apr 2003 19:23:56 -0000 1.2
+++ DefaultApplianceContext.java 11 Apr 2003 19:26:01 -0000 1.3
@@ -81,7 +81,7 @@
/**
* The underlying profile that this appliance is managing.
*/
- private Profile m_profile;
+ private Profile m_profile;
/**
@@ -89,9 +89,9 @@
*/
private boolean m_activation = false;
- /**
- * The base path for the appliance.
- */
+ /**
+ * The base path for the appliance.
+ */
private String m_partition;
/**
@@ -133,20 +133,20 @@
// constructor
//==============================================================
- /**
- * Creation of a new appliance context.
- * @param profile the profile
- */
+ /**
+ * Creation of a new appliance context.
+ * @param profile the profile
+ */
public DefaultApplianceContext( Profile profile )
{
this( profile, null );
}
- /**
- * Creation of a new appliance context.
- * @param profile the profile
- * @param map a set of supplimentary context entries
- */
+ /**
+ * Creation of a new appliance context.
+ * @param profile the profile
+ * @param map a set of supplimentary context entries
+ */
public DefaultApplianceContext( Profile profile, Map map )
{
super( map );
@@ -163,12 +163,12 @@
// parameters
//==============================================================
- /**
- * Get the appliance base classname.
- * @return the classname of the appliance implementaiton.
- * @exception NullPointerException if the supplied classname is null
- * @exception IllegalStateException if the context is write protected
- */
+ /**
+ * Get the appliance base classname.
+ * @return the classname of the appliance implementaiton.
+ * @exception NullPointerException if the supplied classname is null
+ * @exception IllegalStateException if the context is write protected
+ */
public void setApplianceClassname( String classname )
{
checkWriteable();
@@ -179,28 +179,27 @@
m_classname = classname;
}
- /**
- * Get the appliance base classname.
- * @return the classname of the appliance implementaiton.
- */
+ /**
+ * Get the appliance base classname.
+ * @return the classname of the appliance implementaiton.
+ */
public String getApplianceClassname()
{
if( m_classname == null )
{
return getType().getInfo().getAttribute( Appliance.APPLIANCE_CLASS_KEY );
- }
- else
+ } else
{
return m_classname;
}
}
/**
- * Get the appliance factory classname.
- * @param classname of the appliance factory implementation.
- * @exception NullPointerException if the supplied classname is null
- * @exception IllegalStateException if the context is write protected
- */
+ * Get the appliance factory classname.
+ * @param classname of the appliance factory implementation.
+ * @exception NullPointerException if the supplied classname is null
+ * @exception IllegalStateException if the context is write protected
+ */
public void setApplianceFactoryClassname( String classname )
{
checkWriteable();
@@ -211,28 +210,27 @@
m_factory = classname;
}
- /**
- * Get the appliance base classname.
- * @return the classname of the appliance factory (null if undefined)
- */
+ /**
+ * Get the appliance base classname.
+ * @return the classname of the appliance factory (null if undefined)
+ */
public String getApplianceFactoryClassname()
{
if( m_factory == null )
{
return getType().getInfo().getAttribute( Appliance.APPLIANCE_FACTORY_KEY );
- }
- else
+ } else
{
return m_factory;
}
}
- /**
- * Set the appliance name.
- * @param the name
- * @exception NullPointerException if the supplied name is null
- * @exception IllegalStateException if the context is write protected
- */
+ /**
+ * Set the appliance name.
+ * @param the name
+ * @exception NullPointerException if the supplied name is null
+ * @exception IllegalStateException if the context is write protected
+ */
public void setName( String name ) throws NullPointerException, IllegalStateException
{
checkWriteable();
@@ -243,35 +241,34 @@
m_name = name;
}
- /**
- * Get the appliance name.
- * @return the name
- */
+ /**
+ * Get the appliance name.
+ * @return the name
+ */
public String getName()
{
if( m_name == null )
{
return getProfile().getName();
- }
- else
+ } else
{
return m_name;
}
}
- /**
- * Get the appliance profile.
- * @return the profile
- */
+ /**
+ * Get the appliance profile.
+ * @return the profile
+ */
public Profile getProfile()
{
return m_profile;
}
- /**
- * Get the appliance type.
- * @return the type
- */
+ /**
+ * Get the appliance type.
+ * @return the type
+ */
public Type getType()
{
return m_profile.getType();
@@ -285,7 +282,7 @@
* @exception NullPointerException if the supplied directive is nulls
*/
public void setLoggingDirective( LoggingDirective directives )
- throws IllegalStateException, NullPointerException
+ throws IllegalStateException, NullPointerException
{
checkWriteable();
if( directives == null )
@@ -322,35 +319,33 @@
return m_profile.getContext();
}
- /**
- * Set the appliance partition name.
- * @param name the partition name
- * @exception IllegalStateException if the partition name is already set
- */
+ /**
+ * Set the appliance partition name.
+ * @param name the partition name
+ * @exception IllegalStateException if the partition name is already set
+ */
public void setPartitionName( final String name ) throws IllegalStateException
{
checkWriteable();
if( name == null )
{
m_partition = PARTITION_DELIMITER;
- }
- else
+ } else
{
if( !name.endsWith( PARTITION_DELIMITER ) )
{
m_partition = name + PARTITION_DELIMITER;
- }
- else
+ } else
{
m_partition = name;
}
}
}
- /**
- * Get the partition name
- * @return the name (possibly null)
- */
+ /**
+ * Get the partition name
+ * @return the name (possibly null)
+ */
public String getPartitionName()
{
if( m_partition == null )
@@ -360,14 +355,14 @@
return m_partition;
}
- /**
- * Set the activation policy for the component. If TRUE, activation
- * will occur at startup. If false, activation will be deferred to
- * the first lookup invocation if any (i.e. lazy activation).
- *
- * @param policy the activation policy
- * @exception IllegalStateException if the context is write protected
- */
+ /**
+ * Set the activation policy for the component. If TRUE, activation
+ * will occur at startup. If false, activation will be deferred to
+ * the first lookup invocation if any (i.e. lazy activation).
+ *
+ * @param policy the activation policy
+ * @exception IllegalStateException if the context is write protected
+ */
public void setActivationPolicy( final boolean policy )
{
checkWriteable();
@@ -386,10 +381,10 @@
return m_activation;
}
- /**
- * Get the deployment context.
- * @return the deployment context
- */
+ /**
+ * Get the deployment context.
+ * @return the deployment context
+ */
public Map getDeploymentContext()
{
return super.getData();
@@ -410,7 +405,7 @@
checkWriteable();
if( parameters == null )
{
- throw new NullPointerException("parameters");
+ throw new NullPointerException( "parameters" );
}
m_parameters = new Parameters();
m_parameters.merge( m_profile.getParameters() );
@@ -428,8 +423,7 @@
if( m_parameters == null )
{
return m_profile.getParameters();
- }
- else
+ } else
{
return m_parameters;
}
@@ -447,7 +441,7 @@
checkWriteable();
if( config == null )
{
- throw new NullPointerException("configuration");
+ throw new NullPointerException( "configuration" );
}
m_config = new CascadingConfiguration( config, m_profile.getConfiguration() );
}
@@ -463,8 +457,7 @@
if( m_config == null )
{
return m_profile.getConfiguration();
- }
- else
+ } else
{
return m_config;
}
@@ -515,43 +508,42 @@
ArrayList list = new ArrayList();
for( int i = 0; i < loggers.length; i++ )
{
- String name = loggers[ i ].getName();
+ String name = loggers[i].getName();
Category category = getCategory( name, directive, categories );
if( category != null )
{
list.add( category );
- }
- else
+ } else
{
list.add( new Category( name ) );
}
}
return new LoggingDirective(
- categories.getName(),
- categories.getPriority(),
- categories.getTarget(),
- (Category[])list.toArray( new Category[ 0 ] ) );
- }
-
- /**
- * Return a category based on preferential seletion for the primary
- * argument (client supplied), followed by the seocondary (the profile template)
- * or null if neither declare the category.
- *
- * @param name the category name to lookup
- * @primary the client supplied category defintion
- * @secondary the profile template defintion
- * @return the category or null if not defintions found
- */
+ categories.getName(),
+ categories.getPriority(),
+ categories.getTarget(),
+ (Category[]) list.toArray( new Category[0] ) );
+ }
+
+ /**
+ * Return a category based on preferential seletion for the primary
+ * argument (client supplied), followed by the seocondary (the profile template)
+ * or null if neither declare the category.
+ *
+ * @param name the category name to lookup
+ * @primary the client supplied category defintion
+ * @secondary the profile template defintion
+ * @return the category or null if not defintions found
+ */
private Category getCategory( String name, LoggingDirective primary, LoggingDirective secondary )
{
- Category category = primary.getCategory( name );
- if( category == null )
- {
- category = secondary.getCategory( name );
- }
- return category;
+ Category category = primary.getCategory( name );
+ if( category == null )
+ {
+ category = secondary.getCategory( name );
+ }
+ return category;
}
public String toString()
1.3 +7 -12 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/BlockURLHandler.java
Index: BlockURLHandler.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/BlockURLHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BlockURLHandler.java 11 Apr 2003 19:23:56 -0000 1.2
+++ BlockURLHandler.java 11 Apr 2003 19:26:01 -0000 1.3
@@ -99,7 +99,7 @@
* @throws IOException If a connection failure occurs.
*/
protected URLConnection openConnection( final URL url )
- throws IOException
+ throws IOException
{
return new BlockURLConnection( url, m_repository );
}
@@ -170,12 +170,10 @@
{
// its an absolute spec
path = remainder;
- }
- else if( remainder.startsWith( "./" ) )
+ } else if( remainder.startsWith( "./" ) )
{
path = path + remainder.substring( 2 );
- }
- else
+ } else
{
path = path + remainder;
}
@@ -208,8 +206,7 @@
if( port == getDefaultPort() )
{
authority = host;
- }
- else
+ } else
{
authority = host + ":" + port;
}
@@ -237,7 +234,7 @@
return path;
}
final String head = path.substring( 0, flag );
- final String tail = path.substring( flag+2 );
+ final String tail = path.substring( flag + 2 );
return clean( head + tail );
}
@@ -251,19 +248,17 @@
final String header = path.substring( 0, p );
int n = header.lastIndexOf( "/" );
- final String stub = header.substring( 0, n +1 );
+ final String stub = header.substring( 0, n + 1 );
if( stub.length() > 0 )
{
final String result = stub + path.substring( p + 4 );
return compactPath( result );
- }
- else
+ } else
{
throw new IllegalArgumentException( "Invalid path: " + path );
}
}
-
/**
1.9 +144 -159 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java
Index: DefaultAppliance.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DefaultAppliance.java 11 Apr 2003 19:23:56 -0000 1.8
+++ DefaultAppliance.java 11 Apr 2003 19:26:01 -0000 1.9
@@ -193,29 +193,29 @@
*/
private final Hashtable m_managers = new Hashtable();
- /**
- * The base path for the appliance.
- */
+ /**
+ * The base path for the appliance.
+ */
private String m_path;
- /**
- * The appliance URL.
- */
+ /**
+ * The appliance URL.
+ */
private URL m_url;
- /**
- * The appliance name.
- */
+ /**
+ * The appliance name.
+ */
private String m_name;
- /**
- * The assembled state of the appliance.
- */
+ /**
+ * The assembled state of the appliance.
+ */
private boolean m_assembled;
- /**
- * The appliance target component class.
- */
+ /**
+ * The appliance target component class.
+ */
private Class m_class;
private LifestyleService m_lifestyle;
@@ -224,25 +224,25 @@
private ArrayList m_visited = new ArrayList();
- /**
- * Flag holding the dissasembled state of the block.
- */
+ /**
+ * Flag holding the dissasembled state of the block.
+ */
private boolean m_disassembled = false;
- /**
- * The appliance manager.
- */
+ /**
+ * The appliance manager.
+ */
private ApplianceRepository m_repository;
//=====================================================================
// Contextualizable
//=====================================================================
- /**
- * Supply a object locator to the instance.
- * @param locator the object locator
- * @exception LocatorException if a object location error occurs
- */
+ /**
+ * Supply a object locator to the instance.
+ * @param locator the object locator
+ * @exception LocatorException if a object location error occurs
+ */
public void contextualize( Locator context ) throws ContextException
{
m_applianceContext = (ApplianceContext) context.get( "urn:assembly:appliance.context" );
@@ -267,12 +267,11 @@
try
{
m_class = m_engine.loadClass( classname );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Cannot load class for appliance " + this
- + " from classname: " + classname;
+ "Cannot load class for appliance " + this
+ + " from classname: " + classname;
throw new ApplianceException( error, e );
}
@@ -286,18 +285,17 @@
try
{
m_handler = m_lifestyle.createHandler( this, m_engine, m_system );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unexpected lifestyle handler establishment failure in appliance: " + this;
+ "Unexpected lifestyle handler establishment failure in appliance: " + this;
throw new ApplianceException( error, e );
}
if( getLogger().isDebugEnabled() )
{
final String message =
- "created appliance: " + getURL();
+ "created appliance: " + getURL();
getLogger().debug( message );
}
}
@@ -316,7 +314,7 @@
* @throws LocatorException if an error occurs
*/
public Object resolve( Object partition )
- throws LocatorException
+ throws LocatorException
{
return resolve( partition, null );
}
@@ -330,22 +328,21 @@
* @throws ContextException if an error occurs
*/
public Object resolve( Object partition, String ref )
- throws LocatorException
+ throws LocatorException
{
if( !m_assembled )
{
final String message =
- "invoking self assembly in appliance: " + this;
+ "invoking self assembly in appliance: " + this;
getLogger().debug( message );
try
{
assemble();
- }
- catch( ApplianceException ae )
+ } catch( ApplianceException ae )
{
final String error =
- "Unable to resolve service due to a self assembly failure in appliance: "
- + this;
+ "Unable to resolve service due to a self assembly failure in appliance: "
+ + this;
throw new LocatorException( error, ref, ae );
}
}
@@ -355,8 +352,8 @@
if( !validReference( ref ) )
{
final String error =
- "Requested service ref: " + ref
- + " is unknown within appliance: " + this;
+ "Requested service ref: " + ref
+ + " is unknown within appliance: " + this;
throw new LocatorException( ref, error );
}
}
@@ -364,12 +361,11 @@
try
{
return m_handler.resolve( partition, ref );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Internal lifestyle handler error during qualified resolution "
- + " relative to reference: " + ref;
+ "Internal lifestyle handler error during qualified resolution "
+ + " relative to reference: " + ref;
throw new LocatorException( ref, error, e );
}
}
@@ -385,11 +381,10 @@
try
{
m_handler.release( object, partition );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Lifestyle handler raised a release error in appliance: " + this;
+ "Lifestyle handler raised a release error in appliance: " + this;
throw new ApplianceRuntimeException( error, e );
}
}
@@ -398,9 +393,9 @@
// implementation
//=====================================================================
- /**
- * Get the appliance name.
- */
+ /**
+ * Get the appliance name.
+ */
public String getName()
{
return m_name;
@@ -425,10 +420,10 @@
return m_applianceContext.getType().getDependencies();
}
- /**
- * Get the appliance URL.
- * @return the appliance URL
- */
+ /**
+ * Get the appliance URL.
+ * @return the appliance URL
+ */
public URL getURL()
{
if( m_url == null )
@@ -437,31 +432,30 @@
{
URL base = m_repository.getURL();
m_url = new URL( base, base.getPath() + m_name );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unexpected url creation error in appliance: " + this;
+ "Unexpected url creation error in appliance: " + this;
throw new ApplianceRuntimeException( error, e );
}
}
return m_url;
}
- /**
- * Get the URL for the supplied service type
- * @param type the service type ref
- * @return the service URL
- * @exception UnknownServiceException if the supplied reference is unknown
- * to the appliance.
- */
+ /**
+ * Get the URL for the supplied service type
+ * @param type the service type ref
+ * @return the service URL
+ * @exception UnknownServiceException if the supplied reference is unknown
+ * to the appliance.
+ */
public URL getURL( String type ) throws UnknownServiceException
{
if( !validReference( type ) )
{
final String error =
- "Requested service ref: " + type
- + " is unknown within appliance: " + this;
+ "Requested service ref: " + type
+ + " is unknown within appliance: " + this;
throw new UnknownServiceException( error );
}
@@ -469,26 +463,25 @@
{
final URL url = getURL();
return new URL( url, url.getPath() + "#" + type );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unexpected error while creating a URL for service: " + type;
+ "Unexpected error while creating a URL for service: " + type;
throw new ApplianceRuntimeException( error, e );
}
}
- /**
- * Get the appliance partition name.
- */
+ /**
+ * Get the appliance partition name.
+ */
public String getPartitionName()
{
return getURL().getPath();
}
- /**
- * Release the appliance path.
- */
+ /**
+ * Release the appliance path.
+ */
public String getPath()
{
return m_path;
@@ -504,11 +497,11 @@
return m_applianceContext.getProfile().getContext();
}
- /**
- * Get the component context.
- *
- * @return the component context
- */
+ /**
+ * Get the component context.
+ *
+ * @return the component context
+ */
public Map getContextMap()
{
return m_context;
@@ -591,21 +584,21 @@
return m_applianceContext.getLoggingDirective();
}
- /**
- * Assemble the appliance.
- * @exception ApplianceException if an error occurs during appliance assembly
- */
+ /**
+ * Assemble the appliance.
+ * @exception ApplianceException if an error occurs during appliance assembly
+ */
public void assemble() throws ApplianceException
{
assemble( new DependencyGraph() );
}
- /**
- * Assemble the appliance.
- * @param graph the dependency graph
- * @exception ApplianceException if an error occurs during appliance assembly
- * @exception NullPointerException if the supplied graph is null
- */
+ /**
+ * Assemble the appliance.
+ * @param graph the dependency graph
+ * @exception ApplianceException if an error occurs during appliance assembly
+ * @exception NullPointerException if the supplied graph is null
+ */
public void assemble( DependencyGraph graph ) throws ApplianceException
{
if( m_assembled )
@@ -636,17 +629,16 @@
{
Appliance[] providers = m_graph.getProviderGraph( this );
StringBuffer buffer =
- new StringBuffer(
- "assembled: " + this.toString()
- + " providers: (" + providers.length + ") " );
+ new StringBuffer(
+ "assembled: " + this.toString()
+ + " providers: (" + providers.length + ") " );
- for( int k=0; k<providers.length; k++ )
+ for( int k = 0; k < providers.length; k++ )
{
if( k > 0 )
{
buffer.append( ", " + providers[k] );
- }
- else
+ } else
{
buffer.append( providers[k].toString() );
}
@@ -655,9 +647,9 @@
}
}
- /**
- * Disassemble the appliance.
- */
+ /**
+ * Disassemble the appliance.
+ */
public void disassemble()
{
if( m_disassembled )
@@ -671,7 +663,7 @@
}
Appliance[] consumers = getDependencyGraph().getConsumerGraph( this );
- for( int i=0; i<consumers.length; i++ )
+ for( int i = 0; i < consumers.length; i++ )
{
Appliance consumer = consumers[i];
m_graph.remove( consumer );
@@ -688,17 +680,16 @@
if( getContextProvider() != null )
{
return true;
- }
- else
+ } else
{
return org.apache.avalon.framework.context.Contextualizable.class.isAssignableFrom( m_class );
}
}
- /**
- * Build the context map.
- * @exception AssemblyException if an error occurs during context creation
- */
+ /**
+ * Build the context map.
+ * @exception AssemblyException if an error occurs during context creation
+ */
private Map buildContextMap() throws ApplianceException
{
ContextDescriptor descriptor = getType().getContext();
@@ -744,12 +735,11 @@
map.put( "block.name", m_name );
map.put( "app.home", new File( home, m_path ) );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unexpected exception while preparing deployment context in appliance: "
- + this;
+ "Unexpected exception while preparing deployment context in appliance: "
+ + this;
throw new ApplianceException( error, e );
}
@@ -765,12 +755,11 @@
ContextDirective directive = m_applianceContext.getContextDirective();
RepositoryManager repository = m_engine.getRepository();
return ContextBuilder.buildContextMap(
- m_engine, repository, descriptor, directive, source );
- }
- catch( Throwable e )
+ m_engine, repository, descriptor, directive, source );
+ } catch( Throwable e )
{
final String error =
- "Unable to create context map in appliance: " + this;
+ "Unable to create context map in appliance: " + this;
throw new ApplianceException( error, e );
}
}
@@ -807,7 +796,7 @@
*/
public Appliance[] getServiceProviders()
{
- return (Appliance[])m_providers.values().toArray( new Appliance[ 0 ] );
+ return (Appliance[]) m_providers.values().toArray( new Appliance[0] );
}
/**
@@ -818,7 +807,7 @@
*/
public Appliance getServiceProvider( final String role )
{
- return (Appliance)m_providers.get( role );
+ return (Appliance) m_providers.get( role );
}
/**
@@ -848,7 +837,7 @@
*/
public Appliance[] getExtensionProviders()
{
- return (Appliance[])m_managers.values().toArray( new Appliance[ 0 ] );
+ return (Appliance[]) m_managers.values().toArray( new Appliance[0] );
}
/**
@@ -859,7 +848,7 @@
*/
public Appliance getExtensionProvider( StageDescriptor stage )
{
- return (Appliance)m_managers.get( stage );
+ return (Appliance) m_managers.get( stage );
}
public String toString()
@@ -867,9 +856,9 @@
return "[" + getName() + "/" + System.identityHashCode( this ) + "]";
}
- /**
- * Terminate the appliance.
- */
+ /**
+ * Terminate the appliance.
+ */
public void terminate()
{
if( getLogger().isDebugEnabled() )
@@ -891,10 +880,10 @@
ContextDescriptor context = getType().getContext();
String ext = context.getAttribute(
- "urn:assembly:lifecycle.context.strategy" );
- if(( ext != null ) && ( getContextProvider() == null ) )
+ "urn:assembly:lifecycle.context.strategy" );
+ if( (ext != null) && (getContextProvider() == null) )
{
- final String message = "resolving context handler for: " + this ;
+ final String message = "resolving context handler for: " + this;
getLogger().debug( message );
Appliance supplier;
ReferenceDescriptor ref = ReferenceDescriptor.newInstance( ext );
@@ -903,24 +892,22 @@
try
{
supplier =
- m_engine.resolve( graph, stage, getURL().getPath() );
- }
- catch( Throwable e )
+ m_engine.resolve( graph, stage, getURL().getPath() );
+ } catch( Throwable e )
{
setEnabled( false );
final String error =
- "Unable to resolve a supplier for a context stage: " + ext
- + " in appliance: " + this;
+ "Unable to resolve a supplier for a context stage: " + ext
+ + " in appliance: " + this;
throw new ApplianceException( error, e );
}
if( supplier == null )
{
final String error =
- "Unresolved context strategy handler: " + ext;
+ "Unresolved context strategy handler: " + ext;
setEnabled( false );
throw new ApplianceException( error );
- }
- else
+ } else
{
setContextProvider( supplier );
graph.add( supplier );
@@ -936,7 +923,7 @@
DependencyDescriptor[] dependencies = getDependencies();
for( int i = 0; i < dependencies.length; i++ )
{
- DependencyDescriptor dependency = dependencies[ i ];
+ DependencyDescriptor dependency = dependencies[i];
String role = dependency.getKey();
if( getServiceProvider( role ) == null )
{
@@ -953,23 +940,22 @@
try
{
supplier = m_engine.resolve( graph, dependency, getURL().getPath() );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
setEnabled( false );
final String error =
- "Unable to deploy a supplier for a service dependency."
- + "\n appliance: " + this
- + "\n dependency: " + dependency;
+ "Unable to deploy a supplier for a service dependency."
+ + "\n appliance: " + this
+ + "\n dependency: " + dependency;
throw new ApplianceException( error, e );
}
if( supplier == null )
{
final String message =
- "Unresolved supplied for the dependency: "
- + dependency.getReference()
- + ", for the role: " + dependency.getKey();
+ "Unresolved supplied for the dependency: "
+ + dependency.getReference()
+ + ", for the role: " + dependency.getKey();
setEnabled( false );
throw new ApplianceException( message );
@@ -981,8 +967,8 @@
addServiceProvider( role, supplier );
getLogger().debug(
- "associated supplier: " + supplier.getName()
- + " under the key: " + role );
+ "associated supplier: " + supplier.getName()
+ + " under the key: " + role );
graph.add( supplier );
}
}
@@ -995,7 +981,7 @@
StageDescriptor[] stages = getType().getStages();
for( int i = 0; i < stages.length; i++ )
{
- StageDescriptor stage = stages[ i ];
+ StageDescriptor stage = stages[i];
if( getExtensionProvider( stage ) == null )
{
@@ -1004,18 +990,17 @@
try
{
supplier = m_engine.resolve( graph, stage, getURL().getPath() );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unable to resolve a supplier for a stage: " + stage;
+ "Unable to resolve a supplier for a stage: " + stage;
throw new ApplianceException( error, e );
}
if( supplier == null )
{
final String message =
- "Unresolved supplied for the stage: " + stage;
+ "Unresolved supplied for the stage: " + stage;
setEnabled( false );
throw new ApplianceException( message );
}
@@ -1031,16 +1016,16 @@
}
}
- /**
- * Internal utility to check if a supplied type is exposed as a service.
- * @return true if there is a matching service description for the type
- * published by the type associated with the profile that this appliance
- * is handling.
- */
+ /**
+ * Internal utility to check if a supplied type is exposed as a service.
+ * @return true if there is a matching service description for the type
+ * published by the type associated with the profile that this appliance
+ * is handling.
+ */
private boolean validReference( String ref )
{
ServiceDescriptor service =
- getType().getService( new ReferenceDescriptor( ref ) );
+ getType().getService( new ReferenceDescriptor( ref ) );
return service != null;
}
1.5 +38 -45 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/ContextBuilder.java
Index: ContextBuilder.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/ContextBuilder.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ContextBuilder.java 11 Apr 2003 19:23:56 -0000 1.4
+++ ContextBuilder.java 11 Apr 2003 19:26:01 -0000 1.5
@@ -87,10 +87,10 @@
* supplied descriptor
* @exception ContextException if a required context value cannot be resolved
*/
- static Map buildContextMap(
- ClassLoader classloader, RepositoryManager repository, ContextDescriptor descriptor,
- ContextDirective directive, Context context )
- throws ContextException
+ static Map buildContextMap(
+ ClassLoader classloader, RepositoryManager repository, ContextDescriptor descriptor,
+ ContextDirective directive, Context context )
+ throws ContextException
{
//
@@ -132,7 +132,7 @@
for( int i = 0; i < entries.length; i++ )
{
- EntryDescriptor entry = entries[ i ];
+ EntryDescriptor entry = entries[i];
String key = entry.getKey();
//
@@ -166,9 +166,9 @@
if( entry.isRequired() )
{
final String error =
- "Import directive for key: "
- + key + " via name: " + name
- + " cannot be resolved.";
+ "Import directive for key: "
+ + key + " via name: " + name
+ + " cannot be resolved.";
throw new ContextException( error );
}
}
@@ -191,21 +191,20 @@
try
{
object = ent.getValue( classloader, map );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Rresolution error for context entry directive: "
- + ent;
+ "Rresolution error for context entry directive: "
+ + ent;
throw new ContextException( error, e );
}
if( object == null )
{
final String error =
- "Unable to build a context value for the entry: '"
- + key + "' type: "
- + entry.getType();
+ "Unable to build a context value for the entry: '"
+ + key + "' type: "
+ + entry.getType();
if( entry.isRequired() )
{
@@ -227,39 +226,36 @@
try
{
boolean ok = objectImplementsType(
- classloader, object, entry.getType() );
+ classloader, object, entry.getType() );
if( ok )
{
map.put( key, object );
- }
- else
+ } else
{
final String error =
- "Object resolved for the key '"
- + key + "' of class '"
- + object.getClass().getName()
- + "' does not implement the type '"
- + entry.getType();
+ "Object resolved for the key '"
+ + key + "' of class '"
+ + object.getClass().getName()
+ + "' does not implement the type '"
+ + entry.getType();
throw new ContextException( error );
}
- }
- catch( ClassNotFoundException cnfe )
+ } catch( ClassNotFoundException cnfe )
{
final String error =
- "Context criteria for the key '" + key
- + "' specifies an unknown type '"
- + entry.getType() + "'.";
+ "Context criteria for the key '" + key
+ + "' specifies an unknown type '"
+ + entry.getType() + "'.";
throw new ContextException( error );
}
- }
- else
+ } else
{
if( entry.isRequired() )
{
final String error =
- "Unable to resolve a context value for the entry: '"
- + key + "' type: "
- + entry.getType();
+ "Unable to resolve a context value for the entry: '"
+ + key + "' type: "
+ + entry.getType();
throw new ContextException( error );
}
}
@@ -269,17 +265,16 @@
}
private static EntryDescriptor[] getMergedEntries(
- RepositoryManager repository, ContextDescriptor descriptor )
- throws IllegalArgumentException
+ RepositoryManager repository, ContextDescriptor descriptor )
+ throws IllegalArgumentException
{
try
{
Service service =
- repository.getServiceManager().getService( descriptor.getReference() );
+ repository.getServiceManager().getService( descriptor.getReference() );
EntryDescriptor[] result = descriptor.merge( service.getEntries() );
return result;
- }
- catch( UnknownServiceException e )
+ } catch( UnknownServiceException e )
{
return descriptor.getEntries();
}
@@ -302,8 +297,7 @@
try
{
return context.get( key );
- }
- catch( ContextException e )
+ } catch( ContextException e )
{
return null;
}
@@ -318,8 +312,8 @@
* @return TRUE if value is compatible with type, FALSE otherwise
*/
private static boolean objectImplementsType(
- ClassLoader classloader, final Object value, final String type )
- throws ClassNotFoundException
+ ClassLoader classloader, final Object value, final String type )
+ throws ClassNotFoundException
{
if( type == null )
{
@@ -346,8 +340,7 @@
if( array.length == 0 )
{
return true;
- }
- else
+ } else
{
Object sample = array[0];
String subtype = type.substring( type.length() - 2 );
1.3 +3 -4 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/BlockURLConnection.java
Index: BlockURLConnection.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/BlockURLConnection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BlockURLConnection.java 11 Apr 2003 19:23:56 -0000 1.2
+++ BlockURLConnection.java 11 Apr 2003 19:26:01 -0000 1.3
@@ -78,7 +78,7 @@
* The URL passed in during the creation of the URL Connection
* by the protocol handler.
*/
- private URL m_url;
+ private URL m_url;
/**
* Creation of a new <code>ApplianceURLConnection</code> handler.
@@ -152,11 +152,10 @@
try
{
return appliance.resolve( m_url, ref );
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "URL content resolution error in: " + m_url;
+ "URL content resolution error in: " + m_url;
throw new CascadingIOException( error, e );
}
}
1.5 +103 -108 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceRepository.java
Index: DefaultApplianceRepository.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceRepository.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultApplianceRepository.java 11 Apr 2003 19:23:56 -0000 1.4
+++ DefaultApplianceRepository.java 11 Apr 2003 19:26:01 -0000 1.5
@@ -69,16 +69,16 @@
* @version $Revision$ $Date$
* @todo add custom appliance selector support
*/
-public final class DefaultApplianceRepository
- implements ApplianceRepository
+public final class DefaultApplianceRepository
+ implements ApplianceRepository
{
//==================================================================
// state
//==================================================================
- /**
- * The parent appliance manager.
- */
+ /**
+ * The parent appliance manager.
+ */
private ApplianceRepository m_parent;
/**
@@ -91,23 +91,23 @@
*/
private final Map m_children = new Hashtable();
- /**
- * The name of the manager.
- */
+ /**
+ * The name of the manager.
+ */
private String m_name;
- /**
- * The full manager path
- */
+ /**
+ * The full manager path
+ */
private URL m_url;
//==============================================================
// constructor
//==============================================================
- /**
- * Creation of a root appliance repository.
- */
+ /**
+ * Creation of a root appliance repository.
+ */
public DefaultApplianceRepository()
{
m_name = "/";
@@ -115,21 +115,20 @@
try
{
m_url = new URL(
- "block", "localhost", -1, m_name, new BlockURLHandler( this ) );
- }
- catch( Throwable e )
+ "block", "localhost", -1, m_name, new BlockURLHandler( this ) );
+ } catch( Throwable e )
{
final String error =
- "Unexpected error while creating the root repository URL.";
+ "Unexpected error while creating the root repository URL.";
throw new ApplianceRuntimeException( error, e );
}
}
- /**
- * Internal constructor suppoerting the creation of a subsidiary repository.
- * @param parent the parent repository
- * @param name the subsidiary repository name
- */
+ /**
+ * Internal constructor suppoerting the creation of a subsidiary repository.
+ * @param parent the parent repository
+ * @param name the subsidiary repository name
+ */
private DefaultApplianceRepository( ApplianceRepository parent, String name )
{
m_parent = parent;
@@ -138,20 +137,18 @@
final URL url = parent.getURL();
try
{
- if( name.endsWith("/") )
+ if( name.endsWith( "/" ) )
{
m_url = new URL( url, url.getPath() + name );
- }
- else
+ } else
{
m_url = new URL( url, url.getPath() + name + "/" );
}
- }
- catch( Throwable e )
+ } catch( Throwable e )
{
final String error =
- "Unable to construct a valid URL from the base: "
- + parent.getURL() + " with the name: " + name;
+ "Unable to construct a valid URL from the base: "
+ + parent.getURL() + " with the name: " + name;
throw new ApplianceRuntimeException( error, e );
}
}
@@ -160,57 +157,57 @@
// ApplianceRepository
//==================================================================
- /**
- * Creation of a new repository as child to this repository.
- * @param engine the engine to assign
- * @param name the repository name
- * @return the repository
- */
+ /**
+ * Creation of a new repository as child to this repository.
+ * @param engine the engine to assign
+ * @param name the repository name
+ * @return the repository
+ */
public ApplianceRepository createChild( Engine engine, String name )
{
ApplianceRepository repository =
- new DefaultApplianceRepository( this, name );
+ new DefaultApplianceRepository( this, name );
final String key =
- repository.getURL().getPath().substring( getURL().getPath().length() );
+ repository.getURL().getPath().substring( getURL().getPath().length() );
m_children.put( key, repository );
return repository;
}
- /**
- * Return the repository URL.
- * @return the URL for the repository.
- */
+ /**
+ * Return the repository URL.
+ * @return the URL for the repository.
+ */
public URL getURL()
{
return m_url;
}
- /**
- * Return the set of appliance istances capable of supporting the supplied dependency.
- * @param dependency a service dependency descriptor
- * @return a matching appliance
- */
+ /**
+ * Return the set of appliance istances capable of supporting the supplied dependency.
+ * @param dependency a service dependency descriptor
+ * @return a matching appliance
+ */
public Appliance[] getAppliances( DependencyDescriptor dependency )
{
ReferenceDescriptor reference = dependency.getReference();
return getAppliances( reference );
}
- /**
- * Return the set of appliance instances capable of supporting the supplied
- * service reference.
- * @param reference a service reference
- * @return a set of candidate appliances
- */
+ /**
+ * Return the set of appliance instances capable of supporting the supplied
+ * service reference.
+ * @param reference a service reference
+ * @return a set of candidate appliances
+ */
public Appliance[] getAppliances( ReferenceDescriptor reference )
{
ArrayList list = new ArrayList();
if( m_parent != null )
{
Appliance[] appliances = m_parent.getAppliances( reference );
- for( int i=0; i<appliances.length; i++ )
+ for( int i = 0; i < appliances.length; i++ )
{
list.add( appliances[i] );
}
@@ -230,18 +227,18 @@
}
- /**
- * Return the set of appliance instances that provide the supplied extension.
- * @param stage a stage descriptor
- * @return a set of appliances capable of supporting the supplied stage
- */
+ /**
+ * Return the set of appliance instances that provide the supplied extension.
+ * @param stage a stage descriptor
+ * @return a set of appliances capable of supporting the supplied stage
+ */
public Appliance[] getAppliances( StageDescriptor stage )
{
ArrayList list = new ArrayList();
if( m_parent != null )
{
Appliance[] appliances = m_parent.getAppliances( stage );
- for( int i=0; i<appliances.length; i++ )
+ for( int i = 0; i < appliances.length; i++ )
{
list.add( appliances[i] );
}
@@ -253,7 +250,7 @@
Appliance appliance = (Appliance) iterator.next();
if( appliance.isEnabled()
- && ( appliance.getType().getExtension( stage ) != null ) )
+ && (appliance.getType().getExtension( stage ) != null) )
{
list.add( appliance );
}
@@ -262,34 +259,34 @@
return (Appliance[]) list.toArray( new Appliance[0] );
}
- /**
- * Select an appliance supporting the supplied dependency using a supplied selector.
- * @param dependency a service depedency descriptor
- * @param selector the applaice selector
- * @return the selected appliance (possibly null)
- */
+ /**
+ * Select an appliance supporting the supplied dependency using a supplied selector.
+ * @param dependency a service depedency descriptor
+ * @param selector the applaice selector
+ * @return the selected appliance (possibly null)
+ */
public Appliance getAppliance( DependencyDescriptor dependency, ApplianceSelector selector )
{
Appliance[] appliances = getAppliances( dependency );
return selector.select( appliances, dependency );
}
- /**
- * Select an appliance supporting the supplied service reference.
- * @param reference a service reference descriptor
- * @return the selected appliance (possibly null)
- */
+ /**
+ * Select an appliance supporting the supplied service reference.
+ * @param reference a service reference descriptor
+ * @return the selected appliance (possibly null)
+ */
public Appliance getAppliance( ReferenceDescriptor reference )
{
return getAppliance( reference, new DefaultApplianceSelector() );
}
- /**
- * Select an appliance supporting the supplied service reference using a supplied selector.
- * @param reference a service reference descriptor
- * @param selector the appliance selector
- * @return the selected appliance (possibly null)
- */
+ /**
+ * Select an appliance supporting the supplied service reference using a supplied selector.
+ * @param reference a service reference descriptor
+ * @param selector the appliance selector
+ * @return the selected appliance (possibly null)
+ */
public Appliance getAppliance( ReferenceDescriptor reference, ApplianceSelector selector )
{
Appliance[] appliances = getAppliances( reference );
@@ -297,33 +294,33 @@
return selector.select( appliances, dependency );
}
- /**
- * Select an appliance capable of supporting the supplied stage
- * @param stage a lifecycle stage
- * @param selector an appliance selector
- * @return the selected appliance (possibly null)
- */
+ /**
+ * Select an appliance capable of supporting the supplied stage
+ * @param stage a lifecycle stage
+ * @param selector an appliance selector
+ * @return the selected appliance (possibly null)
+ */
public Appliance getAppliance( StageDescriptor stage, ApplianceSelector selector )
{
Appliance[] appliances = getAppliances( stage );
return selector.select( appliances, stage );
}
- /**
- * Select an appliance supporting the supplied dependency using a default selector.
- * @param dependency a service depedency descriptor
- * @return the selected appliance (possibly null)
- */
+ /**
+ * Select an appliance supporting the supplied dependency using a default selector.
+ * @param dependency a service depedency descriptor
+ * @return the selected appliance (possibly null)
+ */
public Appliance getAppliance( DependencyDescriptor dependency )
{
return getAppliance( dependency, new DefaultApplianceSelector() );
}
- /**
- * Select an appliance capable of supporting the supplied stage
- * @param stage a lifecycle stage
- * @return the selected appliance (possibly null)
- */
+ /**
+ * Select an appliance capable of supporting the supplied stage
+ * @param stage a lifecycle stage
+ * @return the selected appliance (possibly null)
+ */
public Appliance getAppliance( StageDescriptor stage )
{
return getAppliance( stage, new DefaultApplianceSelector() );
@@ -337,7 +334,7 @@
* @exception NullPointerException if the supplied appliance is null.
*/
public void addAppliance( Appliance appliance )
- throws DuplicateApplianceException, NullPointerException
+ throws DuplicateApplianceException, NullPointerException
{
if( appliance == null )
{
@@ -353,21 +350,20 @@
if( appliance.getURL().getPath().startsWith( local ) )
{
final String key = appliance.getURL().getPath().substring( local.length() );
- m_appliances.put( key , appliance );
- }
- else
+ m_appliances.put( key, appliance );
+ } else
{
final String error =
- "Appliance URL " + appliance.getURL()
- + " does not match repository URL " + getURL();
+ "Appliance URL " + appliance.getURL()
+ + " does not match repository URL " + getURL();
throw new ApplianceRuntimeException( error );
}
}
- /**
- * Return an appliance relative to the supplied path.
- * @param uri the appliance path
- */
+ /**
+ * Return an appliance relative to the supplied path.
+ * @param uri the appliance path
+ */
public Appliance resolve( String uri )
{
if( uri.startsWith( m_url.getPath() ) )
@@ -380,14 +376,13 @@
if( path.indexOf( "/" ) > -1 )
{
// looking for a child
- String name = path.substring( 0, path.indexOf( "/" ) +1 );
+ String name = path.substring( 0, path.indexOf( "/" ) + 1 );
ApplianceRepository child = (ApplianceRepository) m_children.get( name );
if( child != null )
{
return child.resolve( uri );
}
- }
- else
+ } else
{
// looking for an appliance
return (Appliance) m_appliances.get( path );
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org