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 2004/07/11 19:01:57 UTC
svn commit: rev 22818 - in avalon/trunk/runtime/composition: api/src/java/org/apache/avalon/composition/model impl/src/java/org/apache/avalon/composition/model/impl
Author: mcconnell
Date: Sun Jul 11 10:01:56 2004
New Revision: 22818
Added:
avalon/trunk/runtime/composition/api/src/java/org/apache/avalon/composition/model/DuplicateNameException.java
Modified:
avalon/trunk/runtime/composition/api/src/java/org/apache/avalon/composition/model/ModelRepository.java
avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModelRepository.java
Log:
Updates corresponding to RUNTIME-40 (elimination of the possibility to add a model to a container with the same name as an existing model).
Added: avalon/trunk/runtime/composition/api/src/java/org/apache/avalon/composition/model/DuplicateNameException.java
==============================================================================
--- (empty file)
+++ avalon/trunk/runtime/composition/api/src/java/org/apache/avalon/composition/model/DuplicateNameException.java Sun Jul 11 10:01:56 2004
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.composition.model;
+
+/**
+ * Exception raised in response to a model assembly failure.
+ *
+ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
+ * @version $Revision: 1.5 $ $Date: 2004/03/07 22:10:39 $
+ */
+public class DuplicateNameException
+ extends ModelException
+{
+ /**
+ * Construct a new <code>DuplicateNameException</code> instance.
+ *
+ * @param name The conflicting name.
+ */
+ public DuplicateNameException( final String name )
+ {
+ super( name, null );
+ }
+}
+
Modified: avalon/trunk/runtime/composition/api/src/java/org/apache/avalon/composition/model/ModelRepository.java
==============================================================================
--- avalon/trunk/runtime/composition/api/src/java/org/apache/avalon/composition/model/ModelRepository.java (original)
+++ avalon/trunk/runtime/composition/api/src/java/org/apache/avalon/composition/model/ModelRepository.java Sun Jul 11 10:01:56 2004
@@ -93,9 +93,10 @@
/**
* Add an model to the repository.
*
- * @param model the model to add
+ * @param model the model to add
+ * @exception DuplicateNameException if the name is already bound
*/
- void addModel( DeploymentModel model );
+ void addModel( DeploymentModel model ) throws DuplicateNameException;
/**
* Add an model to the repository.
@@ -103,15 +104,22 @@
* @param name the name to register the model under
* @param model the model to add
*/
- void addModel( String name, DeploymentModel model );
+ void addModel( String name, DeploymentModel model ) throws DuplicateNameException;
/**
- * Remove an model from the repository.
+ * Remove a named model from the repository.
*
- * @param model the model to remove
+ * @param name the name of the model to remove
*/
- void removeModel( DeploymentModel model );
+ void removeModel( String name );
+ /**
+ * Remove a model from the repository.
+ *
+ * @param model the model to remove
+ */
+ void removeModel( DeploymentModel model );
+
/**
* Locate an model meeting the supplied criteria.
*
Modified: avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModelRepository.java
==============================================================================
--- avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModelRepository.java (original)
+++ avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModelRepository.java Sun Jul 11 10:01:56 2004
@@ -24,6 +24,7 @@
import org.apache.avalon.composition.model.DeploymentModel;
import org.apache.avalon.composition.model.ModelRepository;
+import org.apache.avalon.composition.model.DuplicateNameException;
import org.apache.avalon.framework.logger.Logger;
@@ -247,8 +248,10 @@
* @param model the model to add
*/
public void addModel( DeploymentModel model )
- {
- m_models.put( model.getName(), model );
+ throws DuplicateNameException
+ {
+ final String name = model.getName();
+ addModel( name, model );
}
/**
@@ -257,19 +260,34 @@
* @param name the name to register the model under
* @param model the model to add
*/
- public void addModel( String name, DeploymentModel model )
+ public void addModel( String name, DeploymentModel model )
+ throws DuplicateNameException
{
+ if( null != m_models.get( name ) )
+ {
+ throw new DuplicateNameException( name );
+ }
m_models.put( name, model );
}
/**
- * Remove an model from the repository.
+ * Remove a model from the repository.
*
* @param model the model to remove
*/
public void removeModel( DeploymentModel model )
{
- m_models.remove( model.getName() );
+ removeModel( model.getName() );
+ }
+
+ /**
+ * Remove a named model from the repository.
+ *
+ * @param name the name of the model to remove
+ */
+ public void removeModel( String name )
+ {
+ m_models.remove( name );
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org