1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.chain.impl;
17
18
19 import org.apache.commons.chain.Chain;
20 import org.apache.commons.chain.Command;
21 import org.apache.commons.chain.Context;
22
23
24 /***
25 * <p>Implementation of {@link Command} that logs its identifier and
26 * and attempts to add a new {@link Command} to the {@link Chain}. This
27 * should cause an IllegalStateException if the {@link Chain} implementation
28 * subclasses <code>ChainBase</code>.</p>
29 *
30 * @author Craig R. McClanahan
31 * @version $Revision: 155403 $ $Date: 2005-02-26 12:52:46 +0000 (Sat, 26 Feb 2005) $
32 */
33
34 public class AddingCommand extends NonDelegatingCommand {
35
36
37
38
39
40 public AddingCommand() {
41 this("", null);
42 }
43
44
45 public AddingCommand(String id, Chain parent) {
46 super(id);
47 this.parent = parent;
48 }
49
50
51
52 private Chain parent = null;
53
54
55
56
57
58
59 public boolean execute(Context context, Chain chain) throws Exception {
60
61 super.execute(context);
62 parent.addCommand(new NonDelegatingCommand("NEW"));
63 return (true);
64
65 }
66
67
68 }