mcconnell 2003/03/17 21:05:48
Modified: merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
DefaultBlockLoader.java
Log:
Addition of support for optionality on supplementary service and dependency
declarations.
Revision Changes Path
1.3 +39 -30
avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlockLoader.java
Index: DefaultBlockLoader.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlockLoader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultBlockLoader.java 17 Mar 2003 04:07:39 -0000 1.2
+++ DefaultBlockLoader.java 18 Mar 2003 05:05:48 -0000 1.3
@@ -365,36 +365,42 @@
// create the block dependencies
//
- Configuration depsConfig = block.getChild( "dependencies" );
- DependencyDescriptor[] dependencies;
- try
- {
- dependencies = TYPE_CREATOR.buildDependencies( depsConfig);
- }
- catch( ConfigurationException ce )
+ Configuration depsConfig = block.getChild( "dependencies", false );
+ DependencyDescriptor[] dependencies = null;
+ if( depsConfig != null )
{
- final String error =
- "Invalid dependencies declaration in block specification:\n"
- + ConfigurationUtil.list( depsConfig );
- throw new BlockException( error, ce );
+ try
+ {
+ dependencies = TYPE_CREATOR.buildDependencies( depsConfig );
+ }
+ catch( ConfigurationException ce )
+ {
+ final String error =
+ "Invalid dependencies declaration in block specification:\n"
+ + ConfigurationUtil.list( depsConfig );
+ throw new BlockException( error, ce );
+ }
}
-
+
//
// create the block services
//
- Configuration servicesConfig = block.getChild( "dependencies" );
- ServiceDescriptor[] services;
- try
+ Configuration servicesConfig = block.getChild( "dependencies" , false );
+ ServiceDescriptor[] services = null;
+ if( servicesConfig != null )
{
- services = TYPE_CREATOR.buildServices( depsConfig);
- }
- catch( ConfigurationException ce )
- {
- final String error =
- "Invalid services declaration in block specification:\n"
- + ConfigurationUtil.list( depsConfig );
- throw new BlockException( error, ce );
+ try
+ {
+ services = TYPE_CREATOR.buildServices( servicesConfig );
+ }
+ catch( ConfigurationException ce )
+ {
+ final String error =
+ "Invalid services declaration in block specification:\n"
+ + ConfigurationUtil.list( depsConfig );
+ throw new BlockException( error, ce );
+ }
}
//
@@ -694,11 +700,8 @@
throw new BlockException( error, e );
}
- DependencyDescriptor[] dependecies = new DependencyDescriptor[0];
- ServiceDescriptor[] services = new ServiceDescriptor[0];
-
return createBlock(
- dependecies, services, engine, list, descriptor, name, partition, custom
);
+ null, null, engine, list, descriptor, name, partition, custom );
}
/**
@@ -737,8 +740,14 @@
context.put("urn:merlin:container.descriptor", descriptor );
context.put("urn:merlin:container.library", this );
context.put("urn:merlin:container.containers", containers );
- context.put("urn:merlin:container.dependencies", dependencies );
- context.put("urn:merlin:container.services", services );
+ if( dependencies != null )
+ {
+ context.put("urn:merlin:container.dependencies", dependencies );
+ }
+ if( services != null )
+ {
+ context.put("urn:merlin:container.services", services );
+ }
context.makeReadOnly();
//
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]