|
From: Mason, R. <ros...@vi...> - 2004-07-13 05:26:29
|
I think what you are suggesting is an implementation detail that can be =
implemented in a specific multicaster rather than introducing a change =
to the core api.=20
I've done something similar in the MuleEventMulticaster for Spring, =
where the listener can supply an array of subscriptions i.e.
public class MuleSubscriptionEventListener implements MuleEventListener =
(implements ApplicationEventListener)
{
public String[] getSubscriptions();
}
have a look at =
http://cvs.sourceforge.net/viewcvs.py/mule/mule-extras/spring/src/java/or=
g/mule/extras/spring/events/
This allows listeners to subscribe on a filtered set of Mule events and =
supports wildcards. so say mule receives jms events on =
customer.support.queue and customer. help and email events addressed to =
su...@my..., your listener could receive all email events and =
jms message on customer.support.queue using -
<bean id=3D"myListener" class=3D"com.foo.MyListener">
<property name=3D"subscriptions">
<list>
<value>customer.support.*</value>
<value>su...@my...</value>
</list>
</property>
</bean>
>-----Original Message-----
>From: spr...@li...
>[mailto:spr...@li...]On Behalf
>Of Keith Donald
>Sent: Tuesday, 13 July 2004 1:57 PM
>To: spring-dev
>Subject: [Springframework-developer] application event filters
>
>
>Have we considered adding support for application event=20
>filters, to allow registered listeners to filter events of=20
>interest? I think that would be a nice feature, and would=20
>be simplify listener handing code, as well as improve=20
>performance.
>=20
>So for example, we could define the following interface:
>=20
>public interface ApplicationEventFilter {
> public boolean isEventOfInterest(ApplicationEvent e);
>}
>=20
>public class LifecycleApplicationEventFilter {
> public boolean isEventOfInterest(ApplicationEvent e) {
> return (e instanceof LifecycleApplicationEvent);
> }
>}
>=20
>public interface ApplicationEventMulticaster {
> public void addApplicationListener(ApplicationListener=20
>listener, ApplicationEventFilter filter);
>}
>=20
>public class SimpleApplicationEventMulticaster {
>=20
> public void addApplicationListener
>(ApplicationListener listener, ApplicationEventFilter=20
>filter) {
> this.applicationEventSubscriptions.add(new=20
>ApplicationEventSubscription(listener, filter));
> }
>=20
> public void multicastEvent(ApplicationEvent event) {
> Iterator it =3D=20
>this.applicationEventSubscriptions.iterator();
> while (it.hasNext()) {
> ApplicationEventSubscription subscription =3D=20
>(ApplicationEventSubscription) it.next();
> if (subscription.isEventOfInterest(event)) {
> subscription.broadcast(event);
> } =20
> }
> }
>}
>=20
>This is analagous to JMX's=20
>NotificationListener/NotificationFilter constructs
>
>
>-------------------------------------------------------
>This SF.Net email sponsored by Black Hat Briefings & Training.
>Attend Black Hat Briefings & Training, Las Vegas July 24-29 -=20
>digital self defense, top technical experts, no vendor pitches,=20
>unmatched networking opportunities. Visit www.blackhat.com
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
|