You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/06/28 02:26:23 UTC
cvs commit: avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/lifecycle DeploymentStageExtension.java
mcconnell 2003/06/27 17:26:23
Modified: merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl
DefaultDeploymentService.java
Added: merlin/assembly-spi/src/java/org/apache/avalon/assembly/lifecycle
DeploymentStageExtension.java
Log:
Addition of deployment extension management.
Revision Changes Path
1.17 +42 -25 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultDeploymentService.java
Index: DefaultDeploymentService.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultDeploymentService.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- DefaultDeploymentService.java 27 Jun 2003 22:52:12 -0000 1.16
+++ DefaultDeploymentService.java 28 Jun 2003 00:26:23 -0000 1.17
@@ -56,6 +56,7 @@
import org.apache.avalon.assembly.appliance.Appliance;
import org.apache.avalon.assembly.lifecycle.DeploymentException;
import org.apache.avalon.assembly.lifecycle.DeploymentService;
+import org.apache.avalon.assembly.lifecycle.DeploymentStageExtension;
import org.apache.avalon.assembly.locator.Contextualizable;
import org.apache.avalon.assembly.locator.Locator;
import org.apache.avalon.assembly.locator.impl.DefaultLocator;
@@ -136,7 +137,7 @@
{
try
{
- final DefaultContextualizationService service =
+ final DefaultContextualizationService service =
new DefaultContextualizationService();
service.enableLogging( getLogger().getChildLogger( "context" ) );
m_contextualization = service;
@@ -196,7 +197,7 @@
int id = System.identityHashCode( instance );
getLogger().debug( "component instance: " + id );
}
- }
+ }
catch( Throwable e )
{
final String error =
@@ -206,7 +207,7 @@
}
//
- // invoke lifecycle processing on the instance commencing with
+ // invoke lifecycle processing on the instance commencing with
// logging channel assignment
//
@@ -310,7 +311,7 @@
else
{
final String error =
- "Component deployment failure in: "
+ "Component deployment failure in appliance: "
+ appliance;
throw new DeploymentException( error, ce );
}
@@ -322,13 +323,21 @@
catch( Throwable e )
{
final String error =
- "Component deployment failure in: "
+ "Component deployment failure in appliance: "
+ appliance;
throw new DeploymentException( error, e );
}
}
- private DeploymentException buildDeploymentException( Throwable e, ClassNotFoundException cnfe )
+ /**
+ * Intenal utility that list the jar files available in the
+ * context classloader in the event of a ClassNotFoundException.
+ * @param e the thrown exception
+ * @param cnfe the ClassNotFoundException exception
+ * @return the package deployment exception
+ */
+ private DeploymentException buildDeploymentException(
+ Throwable e, ClassNotFoundException cnfe )
{
final StringBuffer buffer = new StringBuffer(
"Class not found: " + cnfe.getMessage() );
@@ -347,7 +356,7 @@
}
/**
- * Destroy an appliance.
+ * Decommission an appliance.
* @param appliance the object's appliance
* @param instance the object to decommission
*/
@@ -357,7 +366,7 @@
}
/**
- * Destroy an appliance.
+ * Decommission an appliance.
* @param appliance the object's appliance
* @param instance the object to decommission
* @param disassemble TRUE if the appliance should be dissasembled
@@ -400,8 +409,8 @@
}
catch( Throwable se )
{
- final String warning =
- "Component related error while process stop phase - appliance: "
+ final String warning =
+ "Component related error while process stop phase under appliance: "
+ appliance.toString();
getLogger().warn( warning );
}
@@ -452,7 +461,7 @@
/**
* Create and assign a logging channel to the supplied object
* based on the logging directives declare by the supplied appliance.
- *
+ *
* @param object the object to assign a logging channel
* @param appliance the source of the logging information
*/
@@ -479,7 +488,7 @@
if( getLogger().isDebugEnabled() )
{
getLogger().debug( "logging: " + appliance + " on path: " + path );
- }
+ }
m_logging.addCategories( path, logging );
Logger logger = m_logging.getLoggerForCategory( path );
((LogEnabled)object).enableLogging( logger );
@@ -489,17 +498,17 @@
/**
* Configure a configurable object based on the configuration information
* exposed by the supplied appliance.
- *
+ *
* @param object the object to configure
* @param appliance the source of the configuration information
*/
- private void handleConfiguration( Appliance appliance, Configurable object )
+ private void handleConfiguration( Appliance appliance, Configurable object )
throws Exception
{
Configuration config = appliance.getConfiguration();
if( config == null )
{
- config = new DefaultConfiguration(
+ config = new DefaultConfiguration(
"configuration", this.getClass().getName() );
}
@@ -516,11 +525,11 @@
/**
* Parameterize a parameteriazable object based ot he parameters information
* exposed by the supplied appliance.
- *
- * @param object the object to parameterize
+ *
* @param appliance the source of the parameterization information
+ * @param object the object to parameterize
*/
- private void handleParameterization( Appliance appliance, Parameterizable object )
+ private void handleParameterization( Appliance appliance, Parameterizable object )
throws Exception
{
Parameters params = appliance.getParameters();
@@ -539,11 +548,11 @@
/**
* Service or compose a serviceable/composable object based on the information
* exposed by the supplied appliance.
- *
+ *
* @param object the object to service or compose
* @param appliance the source of the composition information
*/
- private void handleServiceable( Appliance appliance, Object object )
+ private void handleServiceable( Appliance appliance, Object object )
throws Exception
{
if( object instanceof Serviceable )
@@ -557,7 +566,7 @@
manager.enableLogging( getLogger().getChildLogger( "manager" ) );
((Serviceable) object).service( manager );
- }
+ }
else if( object instanceof Composable )
{
if( getLogger().isDebugEnabled() )
@@ -580,7 +589,7 @@
* @param stage the lifecycle extension stage
* @param the object to which the stage extension is to be applied
*/
- private void processCreateStage(
+ private void processCreateStage(
Appliance appliance, StageDescriptor stage, Object object )
{
try
@@ -602,13 +611,17 @@
((Creator)handler).create(
object, new DefaultLocator( appliance.getContextMap() ) );
}
+ if(handler instanceof DeploymentStageExtension)
+ {
+ ((DeploymentStageExtension)handler).create(appliance, stage, object);
+ }
provider.release( handler, this );
}
catch( Throwable e )
{
final String error =
"Extension handler execution error in appliance: '"
- + appliance
+ + appliance.toString()
+ "' under stage: '" + stage
+ "' for target: '" + object + "'";
throw new DeploymentException( error, e );
@@ -633,7 +646,7 @@
* @param stage the lifecycle extension stage
* @param the object to which the stage extension is to be applied
*/
- private void processDestroyStage(
+ private void processDestroyStage(
Appliance appliance, StageDescriptor stage, Object object )
{
try
@@ -655,13 +668,17 @@
((Creator) handler).destroy(
object, new DefaultLocator( appliance.getContextMap() ) );
}
+ if(handler instanceof DeploymentStageExtension)
+ {
+ ((DeploymentStageExtension)handler).destroy(appliance, stage, object);
+ }
provider.release( handler, this );
}
catch( Throwable e )
{
final String error =
"Extension handler execution error in appliance: '"
- + appliance
+ + appliance.toString()
+ "' under stage: '" + stage
+ "' for target: '" + object + "'";
throw new DeploymentException( error, e );
1.1 avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/lifecycle/DeploymentStageExtension.java
Index: DeploymentStageExtension.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, 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 normally appear.
4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written
permission. For written permission, please contact apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 <http://www.apache.org/>.
*/
package org.apache.avalon.assembly.lifecycle;
import org.apache.avalon.assembly.appliance.Appliance;
import org.apache.avalon.meta.info.StageDescriptor;
public interface DeploymentStageExtension
{
/**
* Invocation of the deployment creation stage extension.
* @param appliance the appliance responsible for the object under deployment
* @param stage the extension stage descriptor
* @param object the object under deployment
* @exception if a deployment error occurs
*/
public void create(Appliance appliance, StageDescriptor stage, Object object)
throws Exception;
/**
* Invocation of the deployment destroy stage extension.
* @param appliance the appliance responsible for the object under deployment
* @param stage the extension stage descriptor
* @param object the object under deployment
* @exception if a deployment error occurs
*/
public void destroy(Appliance appliance, StageDescriptor stage, Object object)
throws Exception;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org