@Override
public synchronized void registerEvent(RemoteEvent event, String portId, String returnAddress, String serviceId) {
String name =
String.format("Notify %s via %s when %s occurs", returnAddress.toString(), portId, event.getClassName());
name = getUniqueRuleName(name);
RuleBaseElementId id = new RuleBaseElementId(RuleBaseElementType.Rule, name);
String eventMatcher = makeEventMatcher(event);
try {
String osgiHelperStatement;
if (serviceId == null) {
osgiHelperStatement = String.format(OSGI_HELPER_TEMPLATE1, portId, returnAddress);