use of ddf.catalog.plugin.PreSubscriptionPlugin in project ddf by codice.
the class EventProcessorImpl method createSubscription.
@Override
public void createSubscription(Subscription subscription, String subscriptionId) throws InvalidSubscriptionException, SubscriptionExistsException {
String methodName = "createSubscription";
LOGGER.debug("ENTERING: {}", methodName);
LOGGER.debug("Creating Evaluation Criteria... ");
try {
for (PreSubscriptionPlugin plugin : preSubscription) {
LOGGER.debug("Processing subscription with preSubscription plugin");
subscription = plugin.process(subscription);
}
SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor();
Predicate finalPredicate = (Predicate) subscription.accept(visitor, null);
LOGGER.debug("predicate from filter visitor: {}", finalPredicate);
String[] topics = new String[] { PubSubConstants.PUBLISHED_EVENT_TOPIC_NAME };
Dictionary<String, String[]> props = new Hashtable<>(1, 1);
props.put(EventConstants.EVENT_TOPIC, topics);
ServiceRegistration serviceRegistration = bundleContext.registerService(EventHandler.class.getName(), new PublishedEventHandler(finalPredicate, subscription, preDelivery, catalog, threadPool), props);
existingSubscriptions.put(subscriptionId, serviceRegistration);
LOGGER.debug("Subscription {} created.", subscriptionId);
} catch (Exception e) {
LOGGER.info("Error while creating subscription predicate: ", e);
throw new InvalidSubscriptionException(e);
}
LOGGER.debug("EXITING: {}", methodName);
}
Aggregations