Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Distributed EventAdmin Service

Hello Roshan,

First, I assume you are using the latest from HEAD (i.e. not something already released) we haven't had a release of DistributedEventAdmin yet. For reference, the classname under discussion here is org.eclipse.ecf.remoteservice.eventadmin.DistributedEventAdmin, and it's in the org.eclipse.ecf/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin project.

In answer to your question, however, it *should* support filters...i.e. here's the code in DistributedEventAdmin that retrieves EventHandler instances

private ServiceReference[] getEventHandlerServiceReferences(Event event) {
       synchronized (eventHandlerSTLock) {
           if (eventHandlerServiceTracker == null) {
               eventHandlerServiceTracker = new ServiceTracker(context,
                       EventHandler.class.getName(), null);
           ServiceReference[] refs = eventHandlerServiceTracker
           List results = new ArrayList();
           if (refs == null)
               return null;
           for (int i = 0; i < refs.length; i++) {
               String eventFilter = (String) refs[i]
               Filter filter = null;
               if (eventFilter != null) {
                   try {
                       filter = context.createFilter(eventFilter);
                       if (event.matches(filter))
                   } catch (InvalidSyntaxException e) {
logError("getEventHandlers eventFilter=" + eventFilter,
               } else
           return (ServiceReference[]) results
                   .toArray(new ServiceReference[] {});

As you can see, a Filter is created out of the EVENT_FILTER String, and then the event.matches(filter) is called to determine if there is a match. I frankly haven't had opportunity yet to write test code for a number of EVENT_FILTER values (although I will try to do that very soon), so if you have such test code that shows that this works improperly then please do 1) open a bug; 2) consider contributing test code.



roshan joseph wrote:
Could someone let me know whether the distributed eventadmin service support filters? I was trying to add a filter condition to the eventhandler code in the properties object, but the event handler is found no response to the filter. In the testeventhandler code I have added another line like
before registering the eventhandler. Events with different topic names are also processed by the handler. Really appreciate all help in advance. Thanks & Regards,


ecf-dev mailing list

Back to the top