KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > commands > DelegateCommand


1 package info.magnolia.commands;
2
3 import org.apache.commons.chain.Command;
4 import org.apache.commons.chain.Context;
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
7
8 /**
9  * Delegate to an other command at runtime
10  * @author Philipp Bracher
11  * @version $Id: DelegateCommand.java 6341 2006-09-12 09:18:27Z philipp $
12  *
13  */

14 public class DelegateCommand implements Command {
15     /**
16      * Log
17      */

18     Logger log = LoggerFactory.getLogger(DelegateCommand.class);
19
20     /**
21      * The command name used to delegate to
22      */

23     String JavaDoc commandName;
24     
25     /**
26      * @param commandName
27      */

28     public DelegateCommand(String JavaDoc commandName) {
29         this.commandName = commandName;
30     }
31
32     public boolean execute(Context ctx) throws Exception JavaDoc {
33         Command cmd = CommandsManager.getInstance().getCommand(commandName);
34         if(cmd != null){
35             return cmd.execute(ctx);
36         }
37         else{
38             log.error("can't find command {}", this.commandName);
39         }
40         return false;
41     }
42
43 }
44
Popular Tags