Search in sources :

Example 1 with PreSubscriptionPlugin

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);
}
Also used : InvalidSubscriptionException(ddf.catalog.event.InvalidSubscriptionException) SubscriptionFilterVisitor(ddf.catalog.pubsub.internal.SubscriptionFilterVisitor) Hashtable(java.util.Hashtable) PreSubscriptionPlugin(ddf.catalog.plugin.PreSubscriptionPlugin) EventHandler(org.osgi.service.event.EventHandler) SubscriptionNotFoundException(ddf.catalog.event.SubscriptionNotFoundException) SubscriptionExistsException(ddf.catalog.event.SubscriptionExistsException) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException) InvalidSubscriptionException(ddf.catalog.event.InvalidSubscriptionException) Predicate(ddf.catalog.pubsub.predicate.Predicate) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Aggregations

InvalidSubscriptionException (ddf.catalog.event.InvalidSubscriptionException)1 SubscriptionExistsException (ddf.catalog.event.SubscriptionExistsException)1 SubscriptionNotFoundException (ddf.catalog.event.SubscriptionNotFoundException)1 PluginExecutionException (ddf.catalog.plugin.PluginExecutionException)1 PreSubscriptionPlugin (ddf.catalog.plugin.PreSubscriptionPlugin)1 SubscriptionFilterVisitor (ddf.catalog.pubsub.internal.SubscriptionFilterVisitor)1 Predicate (ddf.catalog.pubsub.predicate.Predicate)1 Hashtable (java.util.Hashtable)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1 EventHandler (org.osgi.service.event.EventHandler)1