Chain of Command and Dependency Injection

36 views
Skip to first unread message

Jeff

unread,
Nov 6, 2009, 11:20:22 AM11/6/09
to google-guice
Hi,

I have a set of command objects and a problem that is well suited to
the standard chain of command pattern using, for example, the apache
commons chain project:

http://commons.apache.org/chain/

I have used this package before and produced very small, concise and
testable classes.

However I don't like the dependence on the context, which is basically
just a mutable global map that any class can alter. My commands all
end up querying the map, downcasting objects, checking for null, etc.
and then jamming all the results back into the same map. There is no
way to determine if a chain is properly defined, if a set of commands
provides all the resources for down stream commands, etc.

Is there any example of the command pattern without the global hash
map that instead uses DI/guice for injecting dependencies and some
facility for making data available to the DI framework for future
commands?

Thanks,
Jeff
Reply all
Reply to author
Forward
0 new messages