mcconnell 2003/06/16 07:25:02
Modified: merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
StandardBlock.java
Log:
Improved dependency management. As a result of this change the dependencies
resolution within a particular block are isolated.
Revision Changes Path
1.11 +21 -11
avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.java
Index: StandardBlock.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- StandardBlock.java 12 Jun 2003 18:56:19 -0000 1.10
+++ StandardBlock.java 16 Jun 2003 14:25:02 -0000 1.11
@@ -141,6 +141,11 @@
private ContainmentProfile m_descriptor;
/**
+ * The dependency graph for the internal assembly of the block
+ */
+ private DependencyGraph m_graph;
+
+ /**
* The set of components established as a result of the declared
* startup policy of the components contained within this container.
* One exception exists in that subsidiary blocks are entered as the
@@ -278,6 +283,15 @@
return m_repository.getURL();
}
+ protected DependencyGraph getDependencyGraph()
+ {
+ if( m_graph == null )
+ {
+ throw new IllegalStateException( "assembly" );
+ }
+ return m_graph;
+ }
+
/**
* Resolve a object to a value qualified by a supplied service reference.
*
@@ -399,7 +413,7 @@
*
* @exception ApplianceException if an error occurs during appliance assembly
*/
- public void assemble( DependencyGraph graph ) throws ApplianceException
+ public void assemble( DependencyGraph parent ) throws ApplianceException
{
if( m_assembled )
{
@@ -407,7 +421,7 @@
}
m_assembled = true;
- super.assemble( graph );
+ super.assemble( parent );
//
// now that we have assembled ourself we can continue with the
@@ -425,6 +439,9 @@
// at the same of lower levels
//
+ DependencyGraph graph = new DependencyGraph( parent );
+ m_graph = graph;
+
Appliance[] appliances = getAppliances();
for( int i=0; i<appliances.length; i++ )
{
@@ -439,14 +456,7 @@
for( int i=0; i<appliances.length; i++ )
{
Appliance appliance = appliances[i];
- if( appliance instanceof Block )
- {
- appliance.assemble( new DependencyGraph( graph ) );
- }
- else
- {
- appliance.assemble( graph );
- }
+ appliance.assemble( graph );
}
}
@@ -650,7 +660,7 @@
catch( Throwable e )
{
final String error =
- "Could not establish a appliance: "
+ "Could not establish a subsidiary appliance: "
+ appliance
+ " in block: " + this;
throw new BlockException( error, e );
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]