public class EventProcessorImpl extends Object implements EventProcessor, org.osgi.service.event.EventHandler, PostIngestPlugin
Modifier and Type | Class and Description |
---|---|
static class |
EventProcessorImpl.DateType
Enumeration of metacard Date attributes that can be used for subscriptions.
|
Modifier and Type | Field and Description |
---|---|
protected org.osgi.framework.BundleContext |
bundleContext |
protected CatalogFramework |
catalog |
static double |
EQUATORIAL_RADIUS_IN_METERS |
protected org.osgi.service.event.EventAdmin |
eventAdmin |
protected List<PreDeliveryPlugin> |
preDelivery |
protected List<PreSubscriptionPlugin> |
preSubscription |
EVENT_METACARD, EVENT_OLD_METACARD, EVENT_TIME, EVENTS_TOPIC_CREATED, EVENTS_TOPIC_DELETED, EVENTS_TOPIC_UPDATED
Constructor and Description |
---|
EventProcessorImpl() |
EventProcessorImpl(org.osgi.framework.BundleContext bundleContext,
org.osgi.service.event.EventAdmin eventAdmin,
List<PreSubscriptionPlugin> preSubscription,
List<PreDeliveryPlugin> preDelivery,
CatalogFramework catalog) |
Modifier and Type | Method and Description |
---|---|
String |
createSubscription(Subscription subscription)
Create a
Subscription with an automatically-generated id. |
void |
createSubscription(Subscription subscription,
String subscriptionId)
Register a
Subscription with this CatalogFramework . |
void |
deleteSubscription(String subscriptionId)
Deletes the subscription associated with the given id.
|
void |
destroy() |
void |
handleEvent(org.osgi.service.event.Event event)
By default the Felix EventAdmin implementation has a timeout of 5000 ms.
|
void |
init() |
void |
notifyCreated(Metacard newMetacard)
|
void |
notifyDeleted(Metacard oldMetacard)
|
void |
notifyUpdated(Metacard newMetacard,
Metacard oldMetacard)
|
protected void |
postEvent(String topic,
Metacard card,
Metacard oldCard)
Posts a Metacard to a given topic
|
CreateResponse |
process(CreateResponse createResponse)
Processes the
CreateResponse . |
DeleteResponse |
process(DeleteResponse deleteResponse)
Processes the
DeleteResponse . |
UpdateResponse |
process(UpdateResponse updateResponse)
Processes the
UpdateResponse . |
static void |
processEntry(Metacard metacard,
String operation,
org.osgi.service.event.EventAdmin eventAdmin)
Processes an entry by adding properties from the metacard to the event.
|
void |
updateSubscription(Subscription subscription,
String subscriptionId)
Updates the subscription associated with the given id.
|
public static final double EQUATORIAL_RADIUS_IN_METERS
protected org.osgi.service.event.EventAdmin eventAdmin
protected org.osgi.framework.BundleContext bundleContext
protected List<PreSubscriptionPlugin> preSubscription
protected List<PreDeliveryPlugin> preDelivery
protected CatalogFramework catalog
public EventProcessorImpl()
public EventProcessorImpl(org.osgi.framework.BundleContext bundleContext, org.osgi.service.event.EventAdmin eventAdmin, List<PreSubscriptionPlugin> preSubscription, List<PreDeliveryPlugin> preDelivery, CatalogFramework catalog)
public static void processEntry(Metacard metacard, String operation, org.osgi.service.event.EventAdmin eventAdmin)
metacard
- - the metacard to processoperation
- - The type of event PubSubConstants
eventAdmin
- - OSGi EventAdmin service used post eventspublic void init()
public void destroy()
public void handleEvent(org.osgi.service.event.Event event)
handleEvent
in interface org.osgi.service.event.EventHandler
public String createSubscription(Subscription subscription) throws InvalidSubscriptionException
EventProcessor
Subscription
with an automatically-generated id.createSubscription
in interface EventProcessor
subscription
- the Subscription
to registerString
an id for the registered Subscription
that can be used later by
calling #unsubscribe(String)
InvalidSubscriptionException
- if this EventProcessor
can not support the Filter
of the provided Subscription
.EventProcessor.createSubscription(Subscription, String)
public void createSubscription(Subscription subscription, String subscriptionId) throws InvalidSubscriptionException, SubscriptionExistsException
EventProcessor
Subscription
with this CatalogFramework
.
Note: Subscription
s are transient, not durable, i.e., only maintained in
memory and will be lost if DDF is shutdown.
Durability must be implemented by the client bundle (typically an endpoint - refer to DurableSubscription
for an example).
Note: A Subscription
can also be registered using the whiteboard
model:
To register a Subscription
via the whiteboard model, simply register any implementation
of Subscription
with OSGi registry under the interface Subscription
. To
unregister the Subscription
, simply unregister the service that was originally
registered. Subscription
s registered in this manner do not get a subscription id and
cannot be unsubscribed via the EventProcessor
Implementations of this method
must call the PreSubscriptionPlugin.process(Subscription)
method for each
createSubscription
in interface EventProcessor
subscription
- the Subscription
to registersubscriptionId
- the desired idInvalidSubscriptionException
- if this EventProcessor
can not support the Filter
of the provided Subscription
.SubscriptionExistsException
- if a subscription with this ID already existspublic void updateSubscription(Subscription subscription, String subscriptionId) throws SubscriptionNotFoundException
EventProcessor
updateSubscription
in interface EventProcessor
subscription
- the subscription to updatesubscriptionId
- the subscription id to identify the subscriptionSubscriptionNotFoundException
- if the subscription was not foundpublic void deleteSubscription(String subscriptionId) throws SubscriptionNotFoundException
EventProcessor
deleteSubscription
in interface EventProcessor
subscriptionId
- the subscription id to identify the subscription to deleteSubscriptionNotFoundException
- if the subscription was not foundpublic void notifyCreated(Metacard newMetacard)
EventProcessor
EventProcessor
that a Metacard
(or equivalent) has been created in
a RemoteSource
.
Implementations of this method must:
PreDeliveryPlugin.processCreate(Metacard)
method for
all of the registered PreDeliveryPlugin
s
DeliveryMethod.created(Metacard)
method of the DeliveryMethod
of
matching Subscription
s with the new Metacard
created.
notifyCreated
in interface EventProcessor
newMetacard
- the newly created Metacard
RemoteSource
,
FederatedSource
,
ConnectedSource
public void notifyUpdated(Metacard newMetacard, Metacard oldMetacard)
EventProcessor
EventProcessor
that a Metacard
(or equivalent) has been updated in
a RemoteSource
.
Implementations of this method must:
PreDeliveryPlugin.processUpdateHit(ddf.catalog.operation.Update)
method of all registered PreDeliveryPlugin
s when a Metacard
has been updated and the new version matches a Subscription
Call PreDeliveryPlugin.processUpdateMiss(ddf.catalog.operation.Update)
method of all registered PreDeliveryPlugin
s when a Metacard
has been updated and the new version matches a Subscription
but the old
version does not
DeliveryMethod
with the updated Metacard
.
notifyUpdated
in interface EventProcessor
newMetacard
- the new version of the Metacard
oldMetacard
- the previous version of the Metacard
(optional, pass null
if
not relevant)FederatedSource
,
RemoteSource
,
ConnectedSource
public void notifyDeleted(Metacard oldMetacard)
EventProcessor
EventProcessor
that a Metacard
(or equivalent) has been deleted in
a RemoteSource
.
Implementations of this method must:
Metacard
is fully populated) call all active matching
Subscription
s associated DeliveryMethod.deleted(Metacard)
with the Metacard
that was deleted.
Metacard
only has Metacard.getId()
, call all
active Subscription
s.
notifyDeleted
in interface EventProcessor
oldMetacard
- the deleted Metacard
RemoteSource
,
FederatedSource
,
ConnectedSource
protected void postEvent(String topic, Metacard card, Metacard oldCard)
topic
- - The topic to post the eventcard
- - The Metacard that will be posted to the topicpublic CreateResponse process(CreateResponse createResponse) throws PluginExecutionException
PostIngestPlugin
CreateResponse
.process
in interface PostIngestPlugin
createResponse
- the CreateResponse
to processCreateResponse
to pass to the next PostIngestPlugin
, or if this is the last PostIngestPlugin
to be calledPluginExecutionException
- thrown when an error occurs during processingpublic UpdateResponse process(UpdateResponse updateResponse) throws PluginExecutionException
PostIngestPlugin
UpdateResponse
.process
in interface PostIngestPlugin
updateResponse
- the UpdateResponse
to processUpdateResponse
to pass to the next PostIngestPlugin
, or if this is the last PostIngestPlugin
to be calledPluginExecutionException
- thrown when an error occurs during processingpublic DeleteResponse process(DeleteResponse deleteResponse) throws PluginExecutionException
PostIngestPlugin
DeleteResponse
.process
in interface PostIngestPlugin
deleteResponse
- the DeleteResponse
to processDeleteResponse
to pass to the next PostIngestPlugin
, or if this is the last PostIngestPlugin
to be calledPluginExecutionException
- thrown when an error occurs during processingThis work is licensed under a Creative Commons Attribution 4.0 International License.