The open source project "guts-events" is an event bus, based on Guice,
hence it is type-friendly (and never requires any cast).
It also offers several important features:
- threading policy to define thread from which event consumers are called
- priority (ordering) of event consumers calls
- filtering of events
I think it should fit your requirements well.
Some links:
- GUTS site: http://kenai.com/projects/guts
- guts-events javadoc: http://guts.kenai.com/guts-events/apidocs/
(please read the package description first, it is very comprehensive)
If you are interested and have questions or problems, then use the GUTS
mailing lists or report issues/enhancements to GUTS JIRA.
Cheers
Jean-Francois
On 26-05-2010 01:54, KreeK wrote:
I'm new to Guice and wanted to get some advice on how to use it with
our application that uses the command pattern. The app has a
CommandMap which maps Events to Commands.
commandMap.map(FooEvent.EVENT_TYPE, FooCommand.class);
Events are dispatched from an EventDispatcher and the CommandMap then
routes the Event to the Command.
// dispatched from somewhere
eventDispatcher.dispatchEvent(new FooEvent(FooEvent.EVENT, payload));
// CommanMap.java
protected void routeEventToCommand(IEvent e, Class commandClass) {
ICommand command = (ICommand) _injector.getInstance(commandClass);
command.execute(e);
}
The command executes but the event must be cast to get it's payload.
// FooCommand.java
void execute(IEvent e) {
FooEvent = (FooEvent) e;
e.getSomeObject();
}
I'd like to avoid casting. It is possible to inject the event into the
command? I've tried various configurations with Guice but always end
up with a new instance of the event in the command rather than the one
that was dispatched.
thanks!
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.