use of org.eclipse.ecf.remoteservice.eventadmin.serialization.SerializationHandler in project ecf by eclipse.
the class DistributedEventAdmin method start.
/**
* Start this distributed event admin instance. This method should be called
* prior to registering this object as an {@link EventAdmin} implementation
* with the OSGi service registry.
*/
public void start() {
if (logTracker != null)
logTracker.open();
// $NON-NLS-1$
ThreadGroup eventGroup = new ThreadGroup("Distributed EventAdmin");
eventGroup.setDaemon(true);
eventManager = new EventManager("Distributed EventAdmin Async Event Dispatcher Thread", eventGroup);
eventHandlerTracker.open();
// Other services can contribute Event topic filters which will be ignored
// by the distribution part of DistributedEventAdmin. This is primarily useful
// in cases where the Event data cannot be serialized or serialization is too
// expensive.
etfServiceTracker = new ServiceTracker(this.context, EventTopicFilter.class, new ServiceTrackerCustomizer() {
public Object addingService(ServiceReference reference) {
final EventTopicFilter etf = (EventTopicFilter) context.getService(reference);
addEventTopicFilters(etf.getFilters());
return etf;
}
public void modifiedService(ServiceReference reference, Object service) {
// nop
}
public void removedService(ServiceReference reference, Object service) {
final EventTopicFilter etf = (EventTopicFilter) service;
removeEventTopicFilters(etf.getFilters());
}
});
etfServiceTracker.open();
// SerializationHandler are responsible to handle serialization of Event properties
shServiceTracker = new ServiceTracker(this.context, SerializationHandler.class, new ServiceTrackerCustomizer() {
public Object addingService(ServiceReference reference) {
final SerializationHandler sh = (SerializationHandler) context.getService(reference);
topic2serializationHandler.put(sh.getTopic(), sh);
return sh;
}
public void modifiedService(ServiceReference reference, Object service) {
// nop
}
public void removedService(ServiceReference reference, Object service) {
final SerializationHandler sh = (SerializationHandler) service;
topic2serializationHandler.remove(sh.getTopic());
}
});
shServiceTracker.open();
}
Aggregations