mcconnell 2003/12/28 14:30:18
Modified: merlin/composition/api/src/java/org/apache/avalon/composition/model
ContainmentModel.java
merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
DefaultContainmentModel.java
Log:
Add interface and implemetation updates to support model removal.
Revision Changes Path
1.8 +8 -1
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java
Index: ContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ContainmentModel.java 5 Dec 2003 01:27:12 -0000 1.7
+++ ContainmentModel.java 28 Dec 2003 22:30:18 -0000 1.8
@@ -159,6 +159,13 @@
Model addModel( Profile profile ) throws ModelException;
/**
+ * Removal of a named model for the containment model.
+ *
+ * @param name the name of the subsidiary model to be removed
+ */
+ void removeModel( String name );
+
+ /**
* Return the set of service export directives.
* @return t he export directives
*/
1.11 +31 -3
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
Index: DefaultContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultContainmentModel.java 5 Dec 2003 01:27:12 -0000 1.10
+++ DefaultContainmentModel.java 28 Dec 2003 22:30:18 -0000 1.11
@@ -340,10 +340,38 @@
private Model addModel( String name, Model model ) throws ModelException
{
- m_models.put( name, model );
- return model;
+ synchronized( m_models )
+ {
+ m_models.put( name, model );
+ return model;
+ }
}
+ /**
+ * Removal of a named model for the containment model.
+ *
+ * @param name the name of the subsidiary model to be removed
+ * @exception IllegalArgumentException if the supplied name is unknown
+ */
+ public void removeModel( String name ) throws IllegalArgumentException
+ {
+ synchronized( m_models )
+ {
+ Object model = m_models.get( name );
+ if( null == name )
+ {
+ final String error =
+ "No model named [" + name
+ + "] is referenced with the model ["
+ + this + "].";
+ throw new IllegalArgumentException( error );
+ }
+ else
+ {
+ m_models.remove( name );
+ }
+ }
+ }
/**
* Creation of a new instance of a deployment model within
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]