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)...as 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);
               eventHandlerServiceTracker.open();
           }
           ServiceReference[] refs = eventHandlerServiceTracker
                   .getServiceReferences();
           List results = new ArrayList();
           if (refs == null)
               return null;
           for (int i = 0; i < refs.length; i++) {
               String eventFilter = (String) refs[i]
                       .getProperty(EventConstants.EVENT_FILTER);
               Filter filter = null;
               if (eventFilter != null) {
                   try {
                       filter = context.createFilter(eventFilter);
                       if (event.matches(filter))
                           results.add(refs[i]);
                   } catch (InvalidSyntaxException e) {
logError("getEventHandlers eventFilter=" + eventFilter,
                               e);
                       continue;
                   }
               } else
                   results.add(refs[i]);
           }
           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.

Thanks,

Scott

roshan joseph wrote:
Hi,
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
dictionary.put(EventConstants.EVENT_FILTER,"(topic=defaultTopic)");
before registering the eventhandler. Events with different topic names are also processed by the handler. Really appreciate all help in advance. Thanks & Regards,
Roshan

------------------------------------------------------------------------

_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev



Back to the top