Any feedback on this Command implementation?

The idea is that as a chain of commands is executing objects get aggregated into a map. The context holds a reference to the map. At the tail end of the execution chain, this command places the objects from the map into the request as request attributes so that front end components (Tiles, JSP's etc) can display them.


Is this:
A) A terrible idea violating abstractions of the Chain of Responsibility pattern? B) A good idea demonstrating good use of the pattern?
C) Something else?



public class ContextToRequestCommand implements Command { String key = "contextToRequest";

public boolean execute(Context context) throws Exception {
HttpServletRequest request = (HttpServletRequest)context.get("request");
Map map = (Map)context.get(key);
if (map == null) {
return false;
}


       Iterator pairs = map.entrySet().iterator();
       while (pairs.hasNext()) {
           Map.Entry pair = (Map.Entry)pairs.next();
           request.setAttribute((String)pair.getKey(), pair.getValue());
       }

       return false;
   }
}


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to