Hi Stefan,

On Nov 10, 2010, at 9:08 AM, Stefan abageru wrote:

> Hi devs !
> 
> I thought about adding some changes in Events and Activity Stream.
> 
> First of all, I want to remove all the listeners from Activity Stream 
> and make this class listen to AllEvent, making it capable of cathcing 
> all events that occur in the wiki (and this way, when adding a new 
> event, you wouldn't need any modifications to this class in order to 
> catch it).

How do you filter events to process? If you don't how would you display for 
example view events or internal events such as component manager descriptor 
added/removed event, or the new event being added by Anca for the XAR import?

> Secondly, I would like to modify onEvent function in the class so that 
> it uses the simpleClassName of the event occurred in order to log the 
> event (the eventType would be this simpleClassName...for example 
> DocumentSavedEvent, AnnotationAddedEvent and so on).

I don't agree with this, or I don't understand it. You get the Event object so 
you can easily get the simple class name by calling 
event.getClass().getSimpleClassName().

> And thirdly i thought about adding one field in AbstractFilterableEvent 
> called /identifier/ and make all events extend directly this class.

Again I don't agree. A notion of event identifier is not linked to a Filterable 
event IMO but to the Event class itself.

> And 
> that /identifier/ would be used in a different way by the events 
> themselves. But it would be used to retrieve infos about that events.
> And so, when logging an event, we could use classname + identifier.
> For example
> AnnotationAddedEvent + "This is my annotation" .
> CommentAddedEvent + "This is my comment" or the number of the comment.

I don't quite agree. If it's supposed to be an identifier it must be unique and 
leaving the unicity to the user will not guarantee it's unique. I'm not sure 
what you want to do:
1) Be able to differentiate 2 events. For what reason?
2) Be able to have some description of the events. Again for what reason?

Now if you need extra data, this is already taken into account in the onEvent 
method:
void onEvent(Event event, Object source, Object data);

The data parameter is there to pass extra data.
The way to use it is to create compound objects if you need to pass several 
data.

However for easiness of use, I'd agree to transform the signature into:
void onEvent(Event event, Object source, Object... data);

All that said, we have a small issue in that the listener of events need to 
know what type of data get passed and thus emitter and listeners must be in 
sync. Thus a generic listener will always have a problem since it won't know 
the type of objects it receives (since they're different for each event). Thus 
for me, when you have a generic listener you also need an EventActionHandler 
that needs to be registered against the generic listener so that it know what 
to do with the extra data passed.

How would you handle anonymous events in the Activity Stream (AS) listener? BTW 
what actions do you need to do with received events in the AS?

Thanks
-Vincent


_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to