1 16 package org.apache.commons.chain.impl; 17 18 19 import org.apache.commons.chain.Command; 20 import org.apache.commons.chain.Context; 21 22 23 30 31 public class NonDelegatingCommand implements Command { 32 33 34 36 37 public NonDelegatingCommand() { 38 this(""); 39 } 40 41 42 public NonDelegatingCommand(String id) { 44 this.id = id; 45 } 46 47 48 50 51 protected String id = null; 53 54 String getId() { 55 return (this.id); 56 } 57 58 public void setId(String id) { 59 this.id = id; 60 } 61 62 63 65 66 public boolean execute(Context context) throws Exception { 68 69 if (context == null) { 70 throw new IllegalArgumentException (); 71 } 72 log(context, id); 73 return (true); 74 75 } 76 77 78 79 81 82 90 protected void log(Context context, String id) { 91 StringBuffer sb = (StringBuffer ) context.get("log"); 92 if (sb == null) { 93 sb = new StringBuffer (); 94 context.put("log", sb); 95 } 96 if (sb.length() > 0) { 97 sb.append('/'); 98 } 99 sb.append(id); 100 } 101 102 103 } 104 | Popular Tags |