1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.chain;
18
19
20 import java.util.Iterator;
21
22
23 /**
24 * <p>A {@link Catalog} is a collection of named {@link Command}s (or
25 * {@link Chain}s) that can be used to retrieve the set of commands that
26 * should be performed based on a symbolic identifier. Use of catalogs
27 * is optional, but convenient when there are multiple possible chains
28 * that can be selected and executed based on environmental conditions.</p>
29 *
30 * @author Craig R. McClanahan
31 * @version $Revision: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
32 */
33
34 public interface Catalog {
35
36
37 /**
38 * <p>A default context attribute for storing a default {@link Catalog},
39 * provided as a convenience only.</p>
40 */
41 String CATALOG_KEY = "org.apache.commons.chain.CATALOG";
42
43
44 /**
45 * <p>Add a new name and associated {@link Command} or {@link Chain}
46 * to the set of named commands known to this {@link Catalog},
47 * replacing any previous command for that name.
48 *
49 * @param name Name of the new command
50 * @param command {@link Command} or {@link Chain} to be returned
51 * for later lookups on this name
52 */
53 void addCommand(String name, Command command);
54
55
56 /**
57 * <p>Return the {@link Command} or {@link Chain} associated with the
58 * specified name, if any; otherwise, return <code>null</code>.</p>
59 *
60 * @param name Name for which a {@link Command} or {@link Chain}
61 * should be retrieved
62 * @return The Command associated with the specified name.
63 */
64 Command getCommand(String name);
65
66
67
68 /**
69 * <p>Return an <code>Iterator</code> over the set of named commands
70 * known to this {@link Catalog}. If there are no known commands,
71 * an empty Iterator is returned.</p>
72 * @return An iterator of the names in this Catalog.
73 */
74 Iterator getNames();
75
76
77 }
78