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:23:56 UTC
cvs commit: avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance MappedServiceManager.java DefaultApplianceFactory.java DefaultApplianceContext.java BlockURLHandler.java DefaultAppliance.java ContextBuilder.java DefaultApplianceSelector.java BlockURLConnection.java DefaultApplianceRepository.java
leosimons 2003/04/11 12:23:56
Modified: merlin/assembly/src/java/org/apache/avalon/assembly/appliance
MappedServiceManager.java
DefaultApplianceFactory.java
DefaultApplianceContext.java BlockURLHandler.java
DefaultAppliance.java ContextBuilder.java
DefaultApplianceSelector.java
BlockURLConnection.java
DefaultApplianceRepository.java
Log:
optimize imports, remove unused stuff.
Revision Changes Path
1.2 +1 -1 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MappedServiceManager.java 13 Mar 2003 01:03:47 -0000 1.1
+++ MappedServiceManager.java 11 Apr 2003 19:23:56 -0000 1.2
@@ -54,8 +54,8 @@
import java.util.Iterator;
import java.util.Map;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
/**
* This class is a static implementation of a <code>ServiceManager</code>. Allow ineritance
1.4 +46 -89 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultApplianceFactory.java 10 Apr 2003 04:36:13 -0000 1.3
+++ DefaultApplianceFactory.java 11 Apr 2003 19:23:56 -0000 1.4
@@ -50,58 +50,44 @@
package org.apache.avalon.assembly.appliance;
-import java.net.URL;
import java.util.Map;
-import java.util.Hashtable;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.LogEnabled;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.assembly.lifestyle.LifestyleException;
-import org.apache.avalon.assembly.lifecycle.AssemblyException;
import org.apache.avalon.assembly.engine.Engine;
import org.apache.avalon.assembly.engine.EngineClassLoader;
-import org.apache.avalon.assembly.lifestyle.LifestyleService;
-import org.apache.avalon.assembly.lifestyle.DefaultLifestyleService;
-import org.apache.avalon.assembly.lifestyle.LifestyleHandler;
-import org.apache.avalon.assembly.lifecycle.DeploymentService;
import org.apache.avalon.assembly.lifecycle.DefaultDeploymentService;
+import org.apache.avalon.assembly.lifecycle.DeploymentService;
+import org.apache.avalon.assembly.lifestyle.DefaultLifestyleService;
+import org.apache.avalon.assembly.lifestyle.LifestyleService;
+import org.apache.avalon.assembly.locator.Contextualizable;
import org.apache.avalon.assembly.locator.DefaultLocator;
import org.apache.avalon.assembly.locator.Locator;
-import org.apache.avalon.assembly.locator.Contextualizable;
import org.apache.avalon.assembly.logging.LoggingManager;
-import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.StageDescriptor;
-import org.apache.avalon.meta.model.LoggingDirective;
-import org.apache.avalon.meta.model.Profile;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.meta.info.Type;
-import org.apache.excalibur.mpool.DefaultPoolManager;
+import org.apache.avalon.meta.model.Profile;
import org.apache.excalibur.mpool.PoolManager;
-import org.apache.excalibur.event.command.CommandManager;
-import org.apache.excalibur.event.command.TPCThreadManager;
/**
- * An appliance factory is a service that provides support for the creation
+ * An appliance factory is a service that provides support for the creation
* of new {@link Appliance} instances. An appliance factory is responsible
- * for the creation of a particular type of appliance, reflecting the
+ * for the creation of a particular type of appliance, reflecting the
* component model and deployment strategy of the component that the appliance
* type is based on.
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
* @version $Revision$ $Date$
- */
+ */
public class DefaultApplianceFactory extends AbstractLogEnabled
implements ApplianceFactory, Contextualizable, Initializable
{
/**
- * Utility method to create a new default appliance factory.
+ * 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
@@ -109,17 +95,17 @@
* @return the new appliance factory
* @exception ApplianceException if a creation error occurs
*/
- public static ApplianceFactory createApplianceFactory(
- EngineClassLoader loader, Logger logger, ApplianceRepository repository,
- Locator system )
+ public static ApplianceFactory createApplianceFactory(
+ EngineClassLoader loader, Logger logger, ApplianceRepository repository,
+ Locator system )
throws ApplianceException
{
- return createApplianceFactory(
+ return createApplianceFactory(
loader, DefaultApplianceFactory.class.getName(), logger, repository, system );
}
/**
- * Utility method to create a new appliance factory.
+ * 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
@@ -128,9 +114,9 @@
* @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 )
+ public static ApplianceFactory createApplianceFactory(
+ Engine loader, String classname, Logger logger,
+ ApplianceRepository repository, Locator system )
throws ApplianceException
{
if( classname == null )
@@ -165,7 +151,7 @@
//
// we are building a custom appliance factory
- //
+ //
try
{
@@ -173,7 +159,7 @@
.getType( classname );
Profile profile = loader.getRepository().getProfileManager()
.getProfile( type );
- DefaultApplianceContext context =
+ DefaultApplianceContext context =
new DefaultApplianceContext( profile );
context.put( "urn:assembly:appliance.repository", repository );
context.put( "urn:assembly:logging", system.get( "urn:assembly:logging" ) );
@@ -187,15 +173,15 @@
}
else
{
- final String error =
- "Supplied classname '" + classname
+ final String error =
+ "Supplied classname '" + classname
+ "' does not implement the ApplianceFactory interface.";
throw new ApplianceException( error );
}
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Could not create appliance factory using : " + classname;
throw new ApplianceException( error, e );
}
@@ -209,7 +195,7 @@
* @return the new factory
* @exception ApplianceException if a creation error occurs
*/
- private static ApplianceFactory createDefaultApplianceFactory(
+ private static ApplianceFactory createDefaultApplianceFactory(
final Logger logger, final Locator context, final ApplianceRepository repository )
throws ApplianceException
{
@@ -224,7 +210,7 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Unexpected error while attempting to create default appliance factory.";
throw new ApplianceException( error, e );
}
@@ -274,8 +260,8 @@
* @param shared TRUE if this appliance can be shared
* @return the appliance
*/
- public Appliance createAppliance(
- Locator system, Engine engine, ApplianceContext context, Logger logger )
+ public Appliance createAppliance(
+ Locator system, Engine engine, ApplianceContext context, Logger logger )
throws ApplianceException
{
if( engine == null )
@@ -293,8 +279,8 @@
//
// we are building a custom appliance
- //
-
+ //
+
LifestyleService lifestyle = createLifestyleService( engine, m_pool );
DefaultLocator locator = null;
@@ -311,13 +297,13 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Unexpected error while building appliance context.";
throw new ApplianceException( error, e );
}
String classname = context.getApplianceClassname();
- if(( classname == null )
+ if(( classname == null )
|| ( classname.equals( DefaultAppliance.class.getName() ) ) )
{
//
@@ -334,7 +320,7 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Unable to create appliance from context: " + context.getName();
throw new ApplianceException( error, e );
}
@@ -351,10 +337,10 @@
Map map = context.getDeploymentContext();
Type type = engine.getRepository()
.getTypeManager().getType( classname );
- Profile profile =
+ Profile profile =
engine.getRepository().getProfileManager()
.getProfile( type );
- DefaultApplianceContext cntx =
+ DefaultApplianceContext cntx =
new DefaultApplianceContext( profile, map );
cntx.put( "urn:assembly:engine", engine );
cntx.put( "urn:assembly:lifestyle.service", lifestyle );
@@ -373,15 +359,15 @@
}
else
{
- final String error =
- "Supplied classname '" + classname
+ final String error =
+ "Supplied classname '" + classname
+ "' does not implement the Appliance interface.";
throw new ApplianceException( error );
}
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Could not create appliance using : " + classname;
throw new ApplianceException( error, e );
}
@@ -389,41 +375,12 @@
}
/**
- * Return a new appliance instance.
- * @param context the appliance context
- * @return the new appliance instance
- */
- private Appliance getApplianceInstance(
- EngineClassLoader engine, ApplianceContext context )
- throws ApplianceException
- {
- if( context.getApplianceClassname() == null )
- {
- return new DefaultAppliance();
- }
- else
- {
- try
- {
- Class clazz = engine.loadClass( context.getApplianceClassname() );
- return (Appliance) clazz.newInstance();
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to create the appliance instance.";
- 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
*/
- private LifestyleService createLifestyleService(
+ private LifestyleService createLifestyleService(
Engine engine, PoolManager pool ) throws ApplianceException
{
try
@@ -442,13 +399,13 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Unexpected error during bootstrap lifecycle service creation.";
throw new ApplianceException( error, e );
}
}
- private DeploymentService createDeploymentService()
+ private DeploymentService createDeploymentService()
throws ApplianceException
{
try
@@ -464,7 +421,7 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Internal error while attempting to create bootstrap deployment service.";
throw new ApplianceException( error, e );
}
1.2 +13 -48 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultApplianceContext.java 13 Mar 2003 01:03:44 -0000 1.1
+++ DefaultApplianceContext.java 11 Apr 2003 19:23:56 -0000 1.2
@@ -50,45 +50,25 @@
package org.apache.avalon.assembly.appliance;
-import java.util.Map;
-import java.util.Hashtable;
import java.util.ArrayList;
+import java.util.Map;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.DefaultContext;
-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.assembly.engine.EngineClassLoader;
-import org.apache.avalon.assembly.lifestyle.LifestyleException;
-import org.apache.avalon.assembly.lifestyle.LifestyleService;
-import org.apache.avalon.assembly.lifestyle.LifestyleHandler;
import org.apache.avalon.assembly.locator.DefaultLocator;
-import org.apache.avalon.meta.info.Type;
-import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.StageDescriptor;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.meta.info.LoggerDescriptor;
-import org.apache.avalon.meta.model.Profile;
-import org.apache.avalon.meta.model.LoggingDirective;
+import org.apache.avalon.meta.info.Type;
import org.apache.avalon.meta.model.Category;
import org.apache.avalon.meta.model.ContextDirective;
-
+import org.apache.avalon.meta.model.LoggingDirective;
+import org.apache.avalon.meta.model.Profile;
import org.apache.excalibur.configuration.CascadingConfiguration;
/**
* An appliance context aggregates the set of arguments that are supplied to
* and appliance instance. These arguments are applied relative to a base
* profile declared under the appliance context constructor.
- *
+ *
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
@@ -103,11 +83,6 @@
*/
private Profile m_profile;
- /**
- * The enabled status of the profile. Normally a profile is enabled however, a
- * failure to assemble will result in the disabling of the profile.
- */
- private boolean m_enabled = true;
/**
* The activation policy - TRUE if activation on startup, FALSE to activate on request.
@@ -119,16 +94,6 @@
*/
private String m_partition;
- /**
- * The appliance domain.
- */
- private String m_domain;
-
- /**
- * The deployment context.
- */
- private Map m_context;
-
/**
* The appliance name.
*/
@@ -319,7 +284,7 @@
* @exception IllegalStateException if the logging categories have been set
* @exception NullPointerException if the supplied directive is nulls
*/
- public void setLoggingDirective( LoggingDirective directives )
+ public void setLoggingDirective( LoggingDirective directives )
throws IllegalStateException, NullPointerException
{
checkWriteable();
@@ -347,7 +312,7 @@
/**
* Return the context directive from the profile. The context directive
- * returned from this method is the context directive contained within the
+ * returned from this method is the context directive contained within the
* profile supplied to the appliance context constructor.
*
* @return the context directive
@@ -431,7 +396,7 @@
}
/**
- * Creates a new parameters object based on the merge of the
+ * Creates a new parameters object based on the merge of the
* profile parameters and supplied parameters. Profile parameters
* remain unchanged. Supplied parameters take precedence over profile
* parameters.
@@ -522,7 +487,7 @@
* Set the startup policy for the component. If TRUE, startup
* of the component will be executed during normal lifecycle processing
* on request for a new component instance. If FALSE the startup phase
- * will be ommitted. This policy enables container implementations to
+ * will be ommitted. This policy enables container implementations to
* take over startup sequencing of the components they are managing.
*
* @param policy the startup policy
@@ -588,7 +553,7 @@
}
return category;
}
-
+
public String toString()
{
return "[" + getName() + "]";
1.2 +20 -22 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BlockURLHandler.java 10 Apr 2003 04:36:13 -0000 1.1
+++ BlockURLHandler.java 11 Apr 2003 19:23:56 -0000 1.2
@@ -1,14 +1,14 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
@@ -20,13 +20,13 @@
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software
- * itself, if and wherever such third-party acknowledgments
+ * Alternately, this acknowledgment may appear in the software
+ * itself, if and wherever such third-party acknowledgments
* normally appear.
*
- * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
+ * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -49,9 +49,9 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
+ * information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
- */
+ */
package org.apache.avalon.assembly.appliance;
@@ -60,8 +60,6 @@
import java.net.URLConnection;
import java.net.URLStreamHandler;
-import org.apache.avalon.assembly.appliance.ApplianceRepository;
-
/**
* <p>A URL handler for the appliance protocol.<p>
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
@@ -85,7 +83,7 @@
*/
public BlockURLHandler( ApplianceRepository repository )
{
- if( repository == null )
+ if( repository == null )
{
throw new NullPointerException( "repository" );
}
@@ -191,13 +189,13 @@
String user = url.getUserInfo();
String host = url.getHost();
- if( host == null )
+ if( host == null )
{
host = "localhost";
}
int port = url.getPort();
- if( port == -1 )
+ if( port == -1 )
{
port = getDefaultPort();
}
1.8 +46 -70 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultAppliance.java 10 Apr 2003 04:36:13 -0000 1.7
+++ DefaultAppliance.java 11 Apr 2003 19:23:56 -0000 1.8
@@ -72,8 +72,8 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.meta.info.ContextDescriptor;
import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.ServiceDescriptor;
import org.apache.avalon.meta.info.ReferenceDescriptor;
+import org.apache.avalon.meta.info.ServiceDescriptor;
import org.apache.avalon.meta.info.StageDescriptor;
import org.apache.avalon.meta.info.Type;
import org.apache.avalon.meta.model.ContextDirective;
@@ -84,28 +84,28 @@
* <p>The DefaultAppliance class manages the establishment of a component
* type relative to a deployment criteria. Once established, an appliance
* provides support for the deployment of component instances on request.
- * An appliance is responsible for component lifestyle and lifecycle
+ * An appliance is responsible for component lifestyle and lifecycle
* management during the deployment and decommission cycles.</p>
- * <p>The implementation supports the association of possibly multiple
- * appliance instances as service providers in accordance with component
- * type dependency declarations during assembly. Once assembled, an
+ * <p>The implementation supports the association of possibly multiple
+ * appliance instances as service providers in accordance with component
+ * type dependency declarations during assembly. Once assembled, an
* appliance is capable of handling <code>resolve</code> and <code>release</code>
* requests. Components instances returned from the <code>resolve</code>
- * method are guaranteed to be fully deployed. Client applications may
- * subsequently <code>release</code> the acquired component back to the
+ * method are guaranteed to be fully deployed. Client applications may
+ * subsequently <code>release</code> the acquired component back to the
* appliance when no longer needed. The appliance implementation will apply
- * appropriate recovery policies based on the lifestyle policy associated
+ * appropriate recovery policies based on the lifestyle policy associated
* with the component type.</p>
*
* <p><b>Code Example</b></p>
* <pre>
*
* //
- * // get a deployment template for a component and use this to
+ * // get a deployment template for a component and use this to
* // create an appliance context
* //
- *
+ *
* {@link Engine} engine = (Engine) Thread.currentThread().getContextClassLoader();
* {@link RepositoryManager} repository = engine.getRepository();
* {@link Type} type = repository.getStandardTypeManager().getType( "MyComponent" );
@@ -114,7 +114,7 @@
* context.makeReadOnly();
*
* //
- * // create and assembly an appliance then use the appliance to get
+ * // create and assembly an appliance then use the appliance to get
* // a fully deployed component reference
* //
*
@@ -124,7 +124,7 @@
* Object object = appliance.resolve( this );
*
* //
- * // after finishing with the return object, release it back to
+ * // after finishing with the return object, release it back to
* // the appliance
* //
*
@@ -204,16 +204,6 @@
private URL m_url;
/**
- * The system domain.
- */
- private String m_domain;
-
- /**
- * The deployment context.
- */
- private Map m_deployment;
-
- /**
* The appliance name.
*/
private String m_name;
@@ -236,12 +226,12 @@
/**
* Flag holding the dissasembled state of the block.
- */
+ */
private boolean m_disassembled = false;
/**
* The appliance manager.
- */
+ */
private ApplianceRepository m_repository;
//=====================================================================
@@ -281,19 +271,11 @@
catch( Throwable e )
{
final String error =
- "Cannot load class for appliance " + this
+ "Cannot load class for appliance " + this
+ " from classname: " + classname;
throw new ApplianceException( error, e );
}
-
- try
- {
- m_domain = (String) m_system.get( "urn:assembly:domain" );
- }
- catch( Throwable e )
- {
- m_domain = "localhost";
- }
+
m_name = m_applianceContext.getName();
m_path = m_applianceContext.getPartitionName() + m_name;
@@ -307,14 +289,14 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Unexpected lifestyle handler establishment failure in appliance: " + this;
throw new ApplianceException( error, e );
}
if( getLogger().isDebugEnabled() )
{
- final String message =
+ final String message =
"created appliance: " + getURL();
getLogger().debug( message );
}
@@ -326,7 +308,7 @@
/**
* Resolve a object to a value. If the appliance has not been assembled
- * the implementation will attempt a self assembly prior to
+ * the implementation will attempt a self assembly prior to
* resolving the service.
*
* @param partition the context within the the resolution is applied
@@ -352,7 +334,7 @@
{
if( !m_assembled )
{
- final String message =
+ final String message =
"invoking self assembly in appliance: " + this;
getLogger().debug( message );
try
@@ -361,8 +343,8 @@
}
catch( ApplianceException ae )
{
- final String error =
- "Unable to resolve service due to a self assembly failure in appliance: "
+ final String error =
+ "Unable to resolve service due to a self assembly failure in appliance: "
+ this;
throw new LocatorException( error, ref, ae );
}
@@ -372,8 +354,8 @@
{
if( !validReference( ref ) )
{
- final String error =
- "Requested service ref: " + ref
+ final String error =
+ "Requested service ref: " + ref
+ " is unknown within appliance: " + this;
throw new LocatorException( ref, error );
}
@@ -385,7 +367,7 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Internal lifestyle handler error during qualified resolution "
+ " relative to reference: " + ref;
throw new LocatorException( ref, error, e );
@@ -406,7 +388,7 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Lifestyle handler raised a release error in appliance: " + this;
throw new ApplianceRuntimeException( error, e );
}
@@ -458,7 +440,7 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Unexpected url creation error in appliance: " + this;
throw new ApplianceRuntimeException( error, e );
}
@@ -470,15 +452,15 @@
* 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
+ * @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
+ final String error =
+ "Requested service ref: " + type
+ " is unknown within appliance: " + this;
throw new UnknownServiceException( error );
}
@@ -633,7 +615,7 @@
if( graph == null )
{
- throw new NullPointerException( "graph" );
+ throw new NullPointerException( "graph" );
}
m_graph = graph;
@@ -653,9 +635,9 @@
if( getLogger().isDebugEnabled() )
{
Appliance[] providers = m_graph.getProviderGraph( this );
- StringBuffer buffer =
- new StringBuffer(
- "assembled: " + this.toString()
+ StringBuffer buffer =
+ new StringBuffer(
+ "assembled: " + this.toString()
+ " providers: (" + providers.length + ") " );
for( int k=0; k<providers.length; k++ )
@@ -736,7 +718,7 @@
map.put( "urn:avalon:partition", getURL().getPath() );
//
- // setup the home and working directory for the components but don't
+ // setup the home and working directory for the components but don't
// actually create the directories - that needs to be handled in a context
// object on demand
//
@@ -755,12 +737,6 @@
map.put( "urn:avalon:work", tmp );
//
- // assign the updated map as the deployment context
- //
-
- m_deployment = map;
-
- //
// ## NEXT 2 lines should be reviewed - is it needed ?
// ## should not be required if alias is working properly
//
@@ -771,15 +747,15 @@
}
catch( Throwable e )
{
- final String error =
- "Unexpected exception while preparing deployment context in appliance: "
+ final String error =
+ "Unexpected exception while preparing deployment context in appliance: "
+ this;
throw new ApplianceException( error, e );
}
//
// create a temporary context object to hold both the system context
- // and any context values supplied by the client and use this as the
+ // and any context values supplied by the client and use this as the
// context information source that is supplied to the context builder
//
@@ -788,12 +764,12 @@
Context source = new DefaultContext( map, m_system );
ContextDirective directive = m_applianceContext.getContextDirective();
RepositoryManager repository = m_engine.getRepository();
- return ContextBuilder.buildContextMap(
+ return ContextBuilder.buildContextMap(
m_engine, repository, descriptor, directive, source );
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Unable to create context map in appliance: " + this;
throw new ApplianceException( error, e );
}
@@ -914,7 +890,7 @@
//
ContextDescriptor context = getType().getContext();
- String ext = context.getAttribute(
+ String ext = context.getAttribute(
"urn:assembly:lifecycle.context.strategy" );
if(( ext != null ) && ( getContextProvider() == null ) )
{
@@ -926,7 +902,7 @@
try
{
- supplier =
+ supplier =
m_engine.resolve( graph, stage, getURL().getPath() );
}
catch( Throwable e )
@@ -982,7 +958,7 @@
{
setEnabled( false );
final String error =
- "Unable to deploy a supplier for a service dependency."
+ "Unable to deploy a supplier for a service dependency."
+ "\n appliance: " + this
+ "\n dependency: " + dependency;
throw new ApplianceException( error, e );
@@ -992,7 +968,7 @@
{
final String message =
"Unresolved supplied for the dependency: "
- + dependency.getReference()
+ + dependency.getReference()
+ ", for the role: " + dependency.getKey();
setEnabled( false );
@@ -1063,7 +1039,7 @@
*/
private boolean validReference( String ref )
{
- ServiceDescriptor service =
+ ServiceDescriptor service =
getType().getService( new ReferenceDescriptor( ref ) );
return service != null;
}
1.4 +29 -43 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ContextBuilder.java 3 Apr 2003 22:14:06 -0000 1.3
+++ ContextBuilder.java 11 Apr 2003 19:23:56 -0000 1.4
@@ -50,36 +50,23 @@
package org.apache.avalon.assembly.appliance;
-import java.util.Map;
-import java.lang.reflect.Constructor;
import java.util.HashMap;
+import java.util.Map;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.assembly.appliance.Appliance;
import org.apache.avalon.assembly.engine.RepositoryManager;
-import org.apache.avalon.assembly.engine.EngineClassLoader;
import org.apache.avalon.assembly.engine.service.UnknownServiceException;
-import org.apache.avalon.assembly.locator.DefaultLocator;
-import org.apache.avalon.assembly.locator.Locator;
-import org.apache.avalon.meta.model.Entry;
-import org.apache.avalon.meta.model.Import;
-import org.apache.avalon.meta.model.Profile;
-import org.apache.avalon.meta.model.ContextDirective;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.meta.info.ContextDescriptor;
import org.apache.avalon.meta.info.EntryDescriptor;
-import org.apache.avalon.meta.info.ExtensionDescriptor;
-import org.apache.avalon.meta.info.ReferenceDescriptor;
import org.apache.avalon.meta.info.Service;
+import org.apache.avalon.meta.model.ContextDirective;
+import org.apache.avalon.meta.model.Entry;
+import org.apache.avalon.meta.model.Import;
/**
- * The context service provides support for the contextualization of a
- * supplied component instance relative to the criteria establihsed under a
+ * The context service provides support for the contextualization of a
+ * supplied component instance relative to the criteria establihsed under a
* supplied appliance.
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
@@ -100,17 +87,17 @@
* supplied descriptor
* @exception ContextException if a required context value cannot be resolved
*/
- static Map buildContextMap(
- ClassLoader classloader, RepositoryManager repository, ContextDescriptor descriptor,
+ static Map buildContextMap(
+ ClassLoader classloader, RepositoryManager repository, ContextDescriptor descriptor,
ContextDirective directive, Context context )
throws ContextException
{
//
// Create a new empty map that we will populate based on the descriptor
- // criteria, with assistance from the supplied directive, using the supplied
+ // criteria, with assistance from the supplied directive, using the supplied
// context as the source. The initial map is populated with a set of default
- // values irrespective of meta declarations. This is primarily to deal with
+ // values irrespective of meta declarations. This is primarily to deal with
// legacy container assumptions.
//
@@ -133,12 +120,12 @@
map.put( "urn:avalon:partition", context.get( "urn:avalon:partition" ) );
//
- // get the entries declared by the context descriptor plus and
+ // get the entries declared by the context descriptor plus and
// entries declared within a service definition if one exists
//
EntryDescriptor[] entries = getMergedEntries( repository, descriptor );
-
+
//
// commence population of the map
//
@@ -179,7 +166,7 @@
if( entry.isRequired() )
{
final String error =
- "Import directive for key: "
+ "Import directive for key: "
+ key + " via name: " + name
+ " cannot be resolved.";
throw new ContextException( error );
@@ -216,7 +203,7 @@
if( object == null )
{
final String error =
- "Unable to build a context value for the entry: '"
+ "Unable to build a context value for the entry: '"
+ key + "' type: "
+ entry.getType();
@@ -239,7 +226,7 @@
{
try
{
- boolean ok = objectImplementsType(
+ boolean ok = objectImplementsType(
classloader, object, entry.getType() );
if( ok )
{
@@ -248,9 +235,9 @@
else
{
final String error =
- "Object resolved for the key '"
+ "Object resolved for the key '"
+ key + "' of class '"
- + object.getClass().getName()
+ + object.getClass().getName()
+ "' does not implement the type '"
+ entry.getType();
throw new ContextException( error );
@@ -259,7 +246,7 @@
catch( ClassNotFoundException cnfe )
{
final String error =
- "Context criteria for the key '" + key
+ "Context criteria for the key '" + key
+ "' specifies an unknown type '"
+ entry.getType() + "'.";
throw new ContextException( error );
@@ -270,7 +257,7 @@
if( entry.isRequired() )
{
final String error =
- "Unable to resolve a context value for the entry: '"
+ "Unable to resolve a context value for the entry: '"
+ key + "' type: "
+ entry.getType();
throw new ContextException( error );
@@ -281,15 +268,14 @@
return map;
}
- private static EntryDescriptor[] getMergedEntries(
- RepositoryManager repository, ContextDescriptor descriptor )
+ private static EntryDescriptor[] getMergedEntries(
+ RepositoryManager repository, ContextDescriptor descriptor )
throws IllegalArgumentException
{
try
{
- Service service =
+ Service service =
repository.getServiceManager().getService( descriptor.getReference() );
- EntryDescriptor[] entries = service.getEntries();
EntryDescriptor[] result = descriptor.merge( service.getEntries() );
return result;
}
@@ -331,7 +317,7 @@
* @param type the desired type
* @return TRUE if value is compatible with type, FALSE otherwise
*/
- private static boolean objectImplementsType(
+ private static boolean objectImplementsType(
ClassLoader classloader, final Object value, final String type )
throws ClassNotFoundException
{
@@ -346,9 +332,9 @@
}
//
- // if the supplied type argument ends with [] then we are dealing
- // with an array argument and as such, if the array length is 0
- // the the type matches anything otherwise we apply a type chack
+ // if the supplied type argument ends with [] then we are dealing
+ // with an array argument and as such, if the array length is 0
+ // the the type matches anything otherwise we apply a type chack
// on the first entry in the array
//
1.2 +6 -7 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceSelector.java
Index: DefaultApplianceSelector.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceSelector.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultApplianceSelector.java 13 Mar 2003 01:03:46 -0000 1.1
+++ DefaultApplianceSelector.java 11 Apr 2003 19:23:56 -0000 1.2
@@ -50,15 +50,14 @@
package org.apache.avalon.assembly.appliance;
-import org.apache.avalon.meta.info.StageDescriptor;
import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.assembly.engine.profile.ProfileSelector;
+import org.apache.avalon.meta.info.StageDescriptor;
/**
* Interface implemented by a service selection implementation mechanism. Classes
* implementing the selector interface may be activated during the selection of
- * candidate service providers during assembly. A component author may declare a
- * selection class explicitly via a service dependency attribute with the attribute
+ * candidate service providers during assembly. A component author may declare a
+ * selection class explicitly via a service dependency attribute with the attribute
* name of <code>urn:avalon:appliance.selector</code>.
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
@@ -67,7 +66,7 @@
class DefaultApplianceSelector implements ApplianceSelector
{
/**
- * Returns the preferred appliance form an available selection of
+ * Returns the preferred appliance form an available selection of
* candidate service providers.
* @param appliances the set of candidate appliance instances
* @param dependency the dependency for which the appliance is required
@@ -84,7 +83,7 @@
}
/**
- * Returns the preferred appliance form an available selection of candidate
+ * Returns the preferred appliance form an available selection of candidate
* extension providers
* @param appliances the set of candidate appliance instances
* @param stage the stage for which the appliance is required
1.2 +20 -24 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BlockURLConnection.java 10 Apr 2003 04:36:13 -0000 1.1
+++ BlockURLConnection.java 11 Apr 2003 19:23:56 -0000 1.2
@@ -1,14 +1,14 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
@@ -20,13 +20,13 @@
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software
- * itself, if and wherever such third-party acknowledgments
+ * Alternately, this acknowledgment may appear in the software
+ * itself, if and wherever such third-party acknowledgments
* normally appear.
*
- * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
+ * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -49,9 +49,9 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
+ * information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
- */
+ */
package org.apache.avalon.assembly.appliance;
@@ -59,10 +59,6 @@
import java.net.URL;
import java.net.URLConnection;
-import org.apache.avalon.assembly.appliance.Appliance;
-import org.apache.avalon.assembly.appliance.ApplianceRepository;
-import org.apache.avalon.assembly.appliance.CascadingIOException;
-
/**
* URL connection handler for the service protocol. New instances of
* the <code>ServiceURLConnection</code> are created by a service
@@ -79,7 +75,7 @@
private ApplianceRepository m_repository;
/**
- * The URL passed in during the creation of the URL Connection
+ * The URL passed in during the creation of the URL Connection
* by the protocol handler.
*/
private URL m_url;
@@ -150,7 +146,7 @@
}
//
- // otherwise resolve the service relative to the #ref
+ // otherwise resolve the service relative to the #ref
//
try
@@ -159,7 +155,7 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"URL content resolution error in: " + m_url;
throw new CascadingIOException( error, e );
}
1.4 +23 -26 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultApplianceRepository.java 10 Apr 2003 04:36:13 -0000 1.3
+++ DefaultApplianceRepository.java 11 Apr 2003 19:23:56 -0000 1.4
@@ -50,19 +50,16 @@
package org.apache.avalon.assembly.appliance;
-import java.util.Map;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
-import java.util.ArrayList;
-import java.net.URL;
+import java.util.Map;
import org.apache.avalon.assembly.engine.Engine;
-import org.apache.avalon.framework.Version;
import org.apache.avalon.meta.info.DependencyDescriptor;
-import org.apache.avalon.meta.info.StageDescriptor;
import org.apache.avalon.meta.info.ReferenceDescriptor;
-import org.apache.avalon.meta.info.InfoDescriptor;
-import org.apache.avalon.meta.model.Profile;
+import org.apache.avalon.meta.info.StageDescriptor;
/**
* The default appliance manager provides support for {@link Appliance}
@@ -93,7 +90,7 @@
* Table of subsidary repositories.
*/
private final Map m_children = new Hashtable();
-
+
/**
* The name of the manager.
*/
@@ -117,7 +114,7 @@
try
{
- m_url = new URL(
+ m_url = new URL(
"block", "localhost", -1, m_name, new BlockURLHandler( this ) );
}
catch( Throwable e )
@@ -152,8 +149,8 @@
}
catch( Throwable e )
{
- final String error =
- "Unable to construct a valid URL from the base: "
+ final String error =
+ "Unable to construct a valid URL from the base: "
+ parent.getURL() + " with the name: " + name;
throw new ApplianceRuntimeException( error, e );
}
@@ -171,10 +168,10 @@
*/
public ApplianceRepository createChild( Engine engine, String name )
{
- ApplianceRepository repository =
+ ApplianceRepository repository =
new DefaultApplianceRepository( this, name );
- final String key =
+ final String key =
repository.getURL().getPath().substring( getURL().getPath().length() );
m_children.put( key, repository );
@@ -202,7 +199,7 @@
}
/**
- * Return the set of appliance instances capable of supporting the supplied
+ * Return the set of appliance instances capable of supporting the supplied
* service reference.
* @param reference a service reference
* @return a set of candidate appliances
@@ -254,8 +251,8 @@
while( iterator.hasNext() )
{
Appliance appliance = (Appliance) iterator.next();
-
- if( appliance.isEnabled()
+
+ if( appliance.isEnabled()
&& ( appliance.getType().getExtension( stage ) != null ) )
{
list.add( appliance );
@@ -301,7 +298,7 @@
}
/**
- * Select an appliance capable of supporting the supplied stage
+ * 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)
@@ -323,7 +320,7 @@
}
/**
- * Select an appliance capable of supporting the supplied stage
+ * Select an appliance capable of supporting the supplied stage
* @param stage a lifecycle stage
* @return the selected appliance (possibly null)
*/
@@ -339,7 +336,7 @@
* for the underlying profile
* @exception NullPointerException if the supplied appliance is null.
*/
- public void addAppliance( Appliance appliance )
+ public void addAppliance( Appliance appliance )
throws DuplicateApplianceException, NullPointerException
{
if( appliance == null )
@@ -351,7 +348,7 @@
{
throw new DuplicateApplianceException( appliance.toString() );
}
-
+
final String local = getURL().getPath();
if( appliance.getURL().getPath().startsWith( local ) )
{
@@ -360,9 +357,9 @@
}
else
{
- final String error =
- "Appliance URL " + appliance.getURL()
- + " does not match repository URL " + getURL();
+ final String error =
+ "Appliance URL " + appliance.getURL()
+ + " does not match repository URL " + getURL();
throw new ApplianceRuntimeException( error );
}
}
@@ -372,14 +369,14 @@
* @param uri the appliance path
*/
public Appliance resolve( String uri )
- {
+ {
if( uri.startsWith( m_url.getPath() ) )
{
// its in scope so substract the path of this repository
// from the supplied uri then get the name of the child
String path = uri.substring( m_url.getPath().length() );
-
+
if( path.indexOf( "/" ) > -1 )
{
// looking for a child
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org