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 14 public class DelegateCommand implements Command { 15 18 Logger log = LoggerFactory.getLogger(DelegateCommand.class); 19 20 23 String commandName; 24 25 28 public DelegateCommand(String commandName) { 29 this.commandName = commandName; 30 } 31 32 public boolean execute(Context ctx) throws Exception { 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 |