001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.chain;
018
019
020 import java.util.Iterator;
021
022
023 /**
024 * <p>A {@link Catalog} is a collection of named {@link Command}s (or
025 * {@link Chain}s) that can be used to retrieve the set of commands that
026 * should be performed based on a symbolic identifier. Use of catalogs
027 * is optional, but convenient when there are multiple possible chains
028 * that can be selected and executed based on environmental conditions.</p>
029 *
030 * @author Craig R. McClanahan
031 * @version $Revision: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
032 */
033
034 public interface Catalog {
035
036
037 /**
038 * <p>A default context attribute for storing a default {@link Catalog},
039 * provided as a convenience only.</p>
040 */
041 String CATALOG_KEY = "org.apache.commons.chain.CATALOG";
042
043
044 /**
045 * <p>Add a new name and associated {@link Command} or {@link Chain}
046 * to the set of named commands known to this {@link Catalog},
047 * replacing any previous command for that name.
048 *
049 * @param name Name of the new command
050 * @param command {@link Command} or {@link Chain} to be returned
051 * for later lookups on this name
052 */
053 void addCommand(String name, Command command);
054
055
056 /**
057 * <p>Return the {@link Command} or {@link Chain} associated with the
058 * specified name, if any; otherwise, return <code>null</code>.</p>
059 *
060 * @param name Name for which a {@link Command} or {@link Chain}
061 * should be retrieved
062 * @return The Command associated with the specified name.
063 */
064 Command getCommand(String name);
065
066
067
068 /**
069 * <p>Return an <code>Iterator</code> over the set of named commands
070 * known to this {@link Catalog}. If there are no known commands,
071 * an empty Iterator is returned.</p>
072 * @return An iterator of the names in this Catalog.
073 */
074 Iterator getNames();
075
076
077 }
078