org.osgi.service.event.EventHandler Java Examples

The following examples show how to use org.osgi.service.event.EventHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventAdminImpl.java    From concierge with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * send an event asynchronously.
 * 
 * @param event
 *            the Event.
 * 
 * @see org.osgi.service.event.EventAdmin#postEvent(org.osgi.service.event.Event)
 */
public void postEvent(final Event event) {
	if (security != null) {
		// TODO: cache permissions
		security.checkPermission(new TopicPermission(event.getTopic(),
				TopicPermission.PUBLISH));
	}

	final Subscription[] subscriptions = (Subscription[]) eventHandlerSubscriptions.values()
			.toArray(new Subscription[eventHandlerSubscriptions.size()]);
	final ArrayList handlers = new ArrayList(subscriptions.length);
	for (int i = 0; i < subscriptions.length; i++) {
		if (subscriptions[i].matches(event)) {
			handlers.add(subscriptions[i].getHandler());
		}
	}

	synchronized (eventQueue) {
		eventQueue.add(new QueueElement(event, (EventHandler[]) handlers
				.toArray(new EventHandler[handlers.size()])));
		eventQueue.notifyAll();
	}
}
 
Example #2
Source File: Subscription.java    From concierge with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * creates a new EventHandlerSubscription instance.
 * 
 * @param handler
 *            an <code>EventHandler</code> that wants to subscribe.
 * @param topics
 *            an array of strings representing the topics.
 * @param filter
 *            a <code>Filter</code> for matching event properties.
 */
Subscription(final EventHandler eventHandler, final String[] topics,
		final Filter filter) {
	// security check
	if (EventAdminImpl.security != null) {
		ArrayList checkedTopics = new ArrayList(topics.length);
		for (int i = 0; i < topics.length; i++) {
			try {
				EventAdminImpl.security
						.checkPermission(new TopicPermission(topics[i],
								TopicPermission.SUBSCRIBE));
				checkedTopics.add(topics[i]);
			} catch (SecurityException se) {
				System.err
						.println("Bundle does not have permission for subscribing to "
								+ topics[i]);
			}
		}
		this.topics = (String[]) checkedTopics
				.toArray(new String[checkedTopics.size()]);
	} else {
		this.topics = topics;
	}
	this.handler = eventHandler;
	this.filter = filter;
}
 
Example #3
Source File: Scenario1TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * run the test
 */
public void runTest() throws Throwable {
  numOfasynchMessages=0;
  numOfsynchMessages=0;
  synchMessageExpectedNumber=0;
  asynchMessageExpectedNumber=0;

  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
  /* register the service */
  serviceRegistration = bundleContext
    .registerService(EventHandler.class.getName(), this, props);

  assertNotNull(getName()
                + " service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }

}
 
Example #4
Source File: TLAEditorActivator.java    From tlaplus with MIT License 6 votes vote down vote up
public void start(final BundleContext context) throws Exception {
	plugin = this;
	
    super.start(context);
    
	final Dictionary<String, Object> serviceRegistrationProperties = new Hashtable<>();
	serviceRegistrationProperties.put(EventConstants.EVENT_TOPIC, IThemeEngine.Events.THEME_CHANGED);
	
	themeChangeEventRegistration = context.registerService(EventHandler.class.getName(), new EventHandler() {
		@Override
		public void handleEvent(final Event event) {
			tlaCodeScanner = null;
			pcalCodeScanner = null;
			setDarkThemeStatus();
		}
	}, serviceRegistrationProperties);
}
 
Example #5
Source File: Scenario13TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * run the test
 */
public void runTest() throws Throwable {
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
  /* register the service */
  serviceRegistration = bundleContext.registerService
    (EventHandler.class.getName(), this, props);

  assertNotNull(getName()
                + " service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }

}
 
Example #6
Source File: Scenario12TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void runTest() throws Throwable {
    msgs = new Hashtable();
    msgs.put(ERROR_MSG, Boolean.FALSE);
    msgs.put(WARN_MSG, Boolean.FALSE);
    msgs.put(INFO_MSG, Boolean.FALSE);
    msgs.put(DEBUG_MSG, Boolean.FALSE);
    /* create the hashtable to put properties in */
    Hashtable props = new Hashtable();
    /* put service.pid property in hashtable */
    props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
    /* register the service */
    serviceRegistration = bundleContext.registerService(EventHandler.class
            .getName(), this, props);
    /* assert not null */
    assertNotNull(displayName + " Can't get service", serviceRegistration);
}
 
Example #7
Source File: FuntionalTestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * run the test
 */
public void runTest() throws Throwable {
  /* create the hashtable to put properties in */
  Hashtable props = new Hashtable();
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
  /* register the service */
  serviceRegistration = bundleContext.registerService
    (EventHandler.class.getName(), this, props);


  assertNotNull(getName()
                + " service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }

}
 
Example #8
Source File: Scenario14TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * run the test
 */
public void runTest() throws Throwable {
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
  /* register the service */
  serviceRegistration = bundleContext.registerService
    (EventHandler.class.getName(), this, props);

  assertNotNull(getName() +" service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }

}
 
Example #9
Source File: Scenario5TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void runTest() throws Throwable {
  asynchMessages = 0;
  synchMessages = 0;
  System.out
    .println("!!! TO RUN THIS TEST CORRECTLY TWO EVENTADMINS NEEDS TO RUN IN THE FRAMEWORK!!!");
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* determine what topicType to use */
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);

  /* register the service */
  serviceRegistration = bundleContext.registerService(
                                                      EventHandler.class.getName(), this, props);

  assertNotNull(getName()
                + " service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }
}
 
Example #10
Source File: Scenario2TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void runTest() throws Throwable {
  asynchMessages=0;
  synchMessages=0;
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
  /* register the service */
  serviceRegistration = bundleContext.registerService(
                                                      EventHandler.class.getName(), this, props);

  assertNotNull(getName()
                + " service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }
}
 
Example #11
Source File: Scenario4TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void runTest() throws Throwable {
  asynchMessages=0;
  synchMessages=0;
  unidentMessages=0;
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
  /*if the filter to consume isn't null */
  if (filterToConsume != null){
    /* put service.pid property in hashtable */
    props.put(EventConstants.EVENT_FILTER, filterToConsume);
  }

  /* register the service */
  serviceRegistration = bundleContext.registerService(
                                                      EventHandler.class.getName(), this, props);

  assertNotNull(getName()
                + " service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }
}
 
Example #12
Source File: Scenario7TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void runTest() throws Throwable {
  asynchMessages = 0;
  synchMessages = 0;
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* determine what topicType to use */
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);

  /* register the service */
  serviceRegistration = bundleContext.registerService(
                                                      EventHandler.class.getName(), this, props);

  assertNotNull(getName()
                + " service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }
}
 
Example #13
Source File: Scenario7TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void runTest() throws Throwable {
  asynchMessages = 0;
  synchMessages = 0;
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* determine what topicType to use */
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);

  /* register the service */
  serviceRegistration = bundleContext.registerService(
                                                      EventHandler.class.getName(), this, props);

  assertNotNull(getName()
                + " service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }
}
 
Example #14
Source File: Scenario6TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * use this to register a consumer without assertion
 */
public void register() {
  shouldAssert = false;
  assertType = 3;
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
  /* register the service */
  serviceRegistration = bundleContext.registerService(EventHandler.class.getName(), this,
                                                      props);
}
 
Example #15
Source File: EventAdminImpl.java    From concierge with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * thread loop.
 * 
 * @see java.lang.Thread#run()
 */
public void run() {
	try {
		while (running) {
			synchronized (eventQueue) {
				if (eventQueue.isEmpty()) {
					// wait until something arrives
					eventQueue.wait();
				}
				// get the element and deliver it
				QueueElement element = (QueueElement) eventQueue
						.remove(0);
				final EventHandler[] handlers = element.handlers;
				final Event event = element.event;
				try {
					for (int i = 0; i < handlers.length; i++) {
						handlers[i].handleEvent(event);
					}
				} catch (Throwable t) {
					t.printStackTrace();
				}
			}
		}
	} catch (InterruptedException ie) {
		ie.printStackTrace();
	}
}
 
Example #16
Source File: Scenario10TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void runTest() throws Throwable {
    eventCounter = 0;
    /* create the hashtable to put properties in */
    Hashtable props = new Hashtable();
    /* put service.pid property in hashtable */
    props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
    /* register the service */
    serviceRegistration = bundleContext.registerService(EventHandler.class
            .getName(), this, props);
    /* assert not null */
    assertNotNull(displayName + " Can't get service", serviceRegistration);
}
 
Example #17
Source File: Scenario11TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void runTest() throws Throwable {
    eventCounter = 0;
    registeredCounter = 0;
    modifiedCounter = 0;
    unregisteringCounter = 0;
    /* create the hashtable to put properties in */
    Hashtable props = new Hashtable();
    /* put service.pid property in hashtable */
    props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
    /* register the service */
    serviceRegistration = bundleContext.registerService(EventHandler.class
            .getName(), this, props);
    /* assert not null */
    assertNotNull(displayName + " Can't get service", serviceRegistration);
}
 
Example #18
Source File: Scenario3TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void runTest() throws Throwable {
  asynchMessages = 0;
  synchMessages = 0;
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* determine what topicType to use */
  if (useCorrectTopicType) {
    /* put service.pid property in hashtable */
    props.put(EventConstants.EVENT_TOPIC,
              topicsToConsumeStringArray);
  } else {
    /* put service.pid property in hashtable */
    props.put(EventConstants.EVENT_TOPIC, topicsToConsumeArrayList);
  }

  /* register the service */
  serviceRegistration = bundleContext.registerService(
                                                      EventHandler.class.getName(), this, props);

  assertNotNull(getName()
                + " service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }
}
 
Example #19
Source File: SystemCollectorTest.java    From karaf-decanter with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws Exception {
    // configure system collector
    File file = new File(System.getProperty("karaf.etc"), "org.apache.karaf.decanter.collector.system.cfg");
    try (PrintWriter writer = new PrintWriter(new FileWriter(file))) {
        writer.write("command.df=df -h");
    }

    // create event handler
    List<Event> received = new ArrayList();
    EventHandler eventHandler = new EventHandler() {
        @Override
        public void handleEvent(Event event) {
            received.add(event);
        }
    };
    Hashtable serviceProperties = new Hashtable();
    serviceProperties.put(EventConstants.EVENT_TOPIC, "decanter/collect/*");
    bundleContext.registerService(EventHandler.class, eventHandler, serviceProperties);

    // install decanter
    System.out.println(executeCommand("feature:repo-add decanter " + System.getProperty("decanter.version")));
    System.out.println(executeCommand("feature:install decanter-collector-system", new RolePrincipal("admin")));

    System.out.println("Waiting scheduler ...");
    while (received.size() == 0) {
        Thread.sleep(500);
    }

    Assert.assertTrue(received.size() >= 1);

    Assert.assertEquals("decanter/collect/system/command_df", received.get(0).getTopic());
    Assert.assertNotNull(received.get(0).getProperty("command.df"));
    Assert.assertEquals("system", received.get(0).getProperty("type"));
    Assert.assertEquals("root", received.get(0).getProperty("karafName"));
}
 
Example #20
Source File: LogCollectorTest.java    From karaf-decanter with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws Exception {
    // install log collector
    System.out.println(executeCommand("feature:repo-add decanter " + System.getProperty("decanter.version")));
    System.out.println(executeCommand("feature:install decanter-collector-log", new RolePrincipal("admin")));

    List<Event> received = new ArrayList<>();
    // plugin event handler
    EventHandler eventHandler = new EventHandler() {
        @Override
        public void handleEvent(Event event) {
            received.add(event);
        }
    };
    Hashtable serviceProperties = new Hashtable();
    serviceProperties.put(EventConstants.EVENT_TOPIC, "decanter/collect/*");
    bundleContext.registerService(EventHandler.class, eventHandler, serviceProperties);

    LOGGER.info("This is a test");

    Assert.assertEquals(1, received.size());
    Assert.assertEquals("decanter/collect/log/org_apache_karaf_decanter_itests_collector_LogCollectorTest", received.get(0).getTopic());
    Assert.assertEquals("INFO", received.get(0).getProperty("level"));
    Assert.assertEquals("log", received.get(0).getProperty("type"));
    Assert.assertEquals("This is a test", received.get(0).getProperty("message"));
    Assert.assertEquals("root", received.get(0).getProperty("karafName"));
    Assert.assertEquals("org.apache.karaf.decanter.itests.collector.LogCollectorTest", received.get(0).getProperty("loggerName"));
    Assert.assertEquals("org.ops4j.pax.logging.slf4j.Slf4jLogger", received.get(0).getProperty("loggerClass"));
    Assert.assertEquals("This is a test", received.get(0).getProperty("renderedMessage"));

}
 
Example #21
Source File: MqttCollectorTest.java    From karaf-decanter with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 60000)
public void test() throws Exception {
    // install decanter
    System.out.println(executeCommand("feature:install decanter-collector-mqtt", new RolePrincipal("admin")));

    Thread.sleep(500);

    // create event handler
    List<Event> received = new ArrayList();
    EventHandler eventHandler = new EventHandler() {
        @Override
        public void handleEvent(Event event) {
            received.add(event);
        }
    };
    Hashtable serviceProperties = new Hashtable();
    serviceProperties.put(EventConstants.EVENT_TOPIC, "decanter/collect/*");
    bundleContext.registerService(EventHandler.class, eventHandler, serviceProperties);

    // send MQTT message
    MqttClient client = new MqttClient("tcp://localhost:1883", "d:decanter:collector:test");
    client.connect();
    MqttMessage message = new MqttMessage();
    message.setPayload("This is a test".getBytes(StandardCharsets.UTF_8));
    client.publish("decanter", message);

    System.out.println("Waiting messages ...");
    while (received.size() == 0) {
        Thread.sleep(500);
    }

    Assert.assertEquals(1, received.size());

    Assert.assertEquals("decanter/collect/mqtt/decanter", received.get(0).getTopic());
    Assert.assertTrue(((String) received.get(0).getProperty("payload")).contains("This is a test"));
    Assert.assertEquals("root", received.get(0).getProperty("karafName"));
    Assert.assertEquals("mqtt", received.get(0).getProperty("type"));

}
 
Example #22
Source File: SocketCollectorTest.java    From karaf-decanter with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws Exception {
    // install decanter
    System.out.println(executeCommand("feature:repo-add decanter " + System.getProperty("decanter.version")));
    System.out.println(executeCommand("feature:install decanter-collector-socket", new RolePrincipal("admin")));

    Thread.sleep(2000);

    // create event handler
    List<Event> received = new ArrayList();
    EventHandler eventHandler = new EventHandler() {
        @Override
        public void handleEvent(Event event) {
            received.add(event);
        }
    };
    Hashtable serviceProperties = new Hashtable();
    serviceProperties.put(EventConstants.EVENT_TOPIC, "decanter/collect/*");
    bundleContext.registerService(EventHandler.class, eventHandler, serviceProperties);

    Socket socket = new Socket("localhost", 34343);
    try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()))) {
        writer.write("{\"test\":\"test\"}");
    }

    while (received.size() == 0) {
        Thread.sleep(500);
    }

    Assert.assertEquals(1, received.size());

    Assert.assertEquals("decanter/collect/socket", received.get(0).getTopic());
    Assert.assertEquals("test", received.get(0).getProperty("test"));
    Assert.assertEquals("root", received.get(0).getProperty("karafName"));
    Assert.assertEquals("socket", received.get(0).getProperty("type"));
}
 
Example #23
Source File: ConsoleTrigger.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * This method is used to set a callback object to the RuleEngine
 *
 * @param ruleCallback a callback object to the RuleEngine.
 */
@Override
public void setCallback(final ModuleHandlerCallback callback) {
    super.setCallback(callback);
    final Dictionary<String, Object> registrationProperties = new Hashtable<String, Object>();
    registrationProperties.put(EventConstants.EVENT_TOPIC, eventTopic);
    registration = context.registerService(EventHandler.class, this, registrationProperties);
}
 
Example #24
Source File: TrackedEventHandler.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void update(ServiceReference<EventHandler> sr)
{
  this.sr = sr;
  // removeAllReferences();
  updateEventFilter();
  updateTopicsAndWildcards();
}
 
Example #25
Source File: Scenario6TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * use this method to register a consumer with assertion
 *
 * @param value
 *            if the consumer should assert
 * @param type
 *            what type it should assert
 */
public void register(boolean value, int type) {

  shouldAssert = value;
  assertType = type;
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
  /* register the service */
  serviceRegistration = bundleContext.registerService(EventHandler.class.getName(), this,
                                                      props);
  assertNotNull(displayName + " Can't get service", serviceRegistration);

}
 
Example #26
Source File: InternalAdminEvent.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void log(TrackedEventHandler handler, String txt)
{
  final ServiceReference<EventHandler> sr = handler.getServiceReference();
  final Bundle b = sr.getBundle();
  String binfo = (b != null) ?
    "  bundle.id=" + b.getBundleId() + "  bundle.name=" + b.getSymbolicName()
    : " No bundle info";
  Activator.log.error(txt + "  Service.id="
                      + sr.getProperty(Constants.SERVICE_ID) + binfo +
                      " topic=" + event.getTopic(), sr);
}
 
Example #27
Source File: TrackedEventHandler.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static TrackedEventHandler create(EventHandlerTracker eht,
                                         ServiceReference<EventHandler> sr,
                                         EventHandler eh)
{
  TrackedEventHandler teh = new TrackedEventHandler(eht, eh);
  teh.update(sr);
  return teh;
}
 
Example #28
Source File: EventHandlerTracker.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public EventHandlerTracker(BundleContext bc)
{
  this.bc = bc;
  tracker = new ServiceTracker<EventHandler, TrackedEventHandler>(
                                                                  bc,
                                                                  EventHandler.class,
                                                                  this);
}
 
Example #29
Source File: EventHandlerTracker.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public TrackedEventHandler addingService(ServiceReference<EventHandler> serviceReference)
{
  EventHandler eh = bc.getService(serviceReference);
  if (eh != null) {
    return TrackedEventHandler.create(this, serviceReference, eh);
  } else {
    return null;
  }
}
 
Example #30
Source File: EventReaderDispatcher.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void open() {
  if(reg == null) {
    Dictionary<String, Object> props = new Hashtable<String, Object>();
    props.put(EventConstants.EVENT_TOPIC,  new String[] { topic });
    if(filter != null && !"".equals(filter)) {
      props.put(EventConstants.EVENT_FILTER, filter);
    }
    reg = bc.registerService(EventHandler.class, this, props);
  }
}