public class CachedSubscription extends Object
The data stored is a mix of persisted and locally cached information. This includes the
original Subscription
either passed from the client or deserialized from stored data, and
the relevant SubscriptionMetadata
.
The existence of a CachedSubscription
object between subscription CRUD
operations implies that:
SubscriptionMetadata
in this object is also in the PersistentStore
.
Subscription
in this object is registered as a service with OSGi only if
isNotRegistered()
is false.
CachedSubscription
objects are not meant to be reused. They have a 1-to-1 correspondence
with a SubscriptionMetadata
object in the backing store and are used to track that
subscription's lifecycle in OSGi.
Given the dynamic nature of Karaf and the need to handle javax.cache.event.CacheEntryEvent
s, there may be a brief period during system startup where
cached subscriptions exist in the cache but are not registered. This problem should rectify
itself as additional SubscriptionFactory
instances are registered by subscription
endpoints.
Currently, no guarantees are made regarding the state of this object during a subscription CRUD operation. Only one container operation may be active at a time.
org.codice.ddf.catalog.subscriptionstore.SubscriptionContainerImpl
Constructor and Description |
---|
CachedSubscription(SubscriptionMetadata metadata) |
Modifier and Type | Method and Description |
---|---|
protected org.osgi.framework.BundleContext |
getBundleContext() |
SubscriptionMetadata |
getMetadata() |
Optional<Subscription> |
getSubscription() |
boolean |
isNotRegistered() |
boolean |
isNotType(String type) |
boolean |
isType(String type) |
void |
registerSubscription(Subscription sub)
Register the provided
Subscription as this cached subscription's OSGi service. |
void |
registerSubscription(SubscriptionFactory factory)
Attempt to construct a
Subscription using the provided factory. |
void |
unregisterSubscription()
Removes this cached subscriptions OSGi service from the service registry.
|
public CachedSubscription(SubscriptionMetadata metadata)
public SubscriptionMetadata getMetadata()
public Optional<Subscription> getSubscription()
public boolean isType(String type)
public boolean isNotType(String type)
public boolean isNotRegistered()
public void registerSubscription(SubscriptionFactory factory)
Subscription
using the provided factory. If the resultant
subscription is valid, register it as this cached subscription's OSGi service.factory
- subscription factory corresponding to this cached subscription's type.SubscriptionRegistrationException
- if the factory can't operate on this cached
subscription.public void registerSubscription(Subscription sub)
Subscription
as this cached subscription's OSGi service.sub
- the subscription to register.SubscriptionRegistrationException
- if registration failed.public void unregisterSubscription()
isNotRegistered()
will throw an exception.SubscriptionRegistrationException
- if this cached subscription did not have a service
registered.protected org.osgi.framework.BundleContext getBundleContext()
This work is licensed under a Creative Commons Attribution 4.0 International License.