Class SubscriptionManagerImpl
- java.lang.Object
-
- org.apache.jackrabbit.webdav.jcr.observation.SubscriptionManagerImpl
-
- All Implemented Interfaces:
TransactionListener
,SubscriptionManager
public class SubscriptionManagerImpl extends Object implements SubscriptionManager, TransactionListener
SubscriptionManager
collects all subscriptions requested, handles the subscription timeout and provides METHODS to discover subscriptions present on a given resource as well as events for an specific subscription.
-
-
Constructor Summary
Constructors Constructor Description SubscriptionManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterCommit(TransactionResource resource, String lockToken, boolean success)
This method is called after the commit has been executed.void
beforeCommit(TransactionResource resource, String lockToken)
This method is called right before a transaction is committed.SubscriptionDiscovery
getSubscriptionDiscovery(ObservationResource resource)
Retrieve theSubscriptionDiscovery
object for the given resource.EventDiscovery
poll(String subscriptionId, long timeout, ObservationResource resource)
Retrieve all event bundles accumulated since for the subscription specified by the given id.Subscription
subscribe(SubscriptionInfo info, String subscriptionId, ObservationResource resource)
Create a newSubscription
or update an existingSubscription
and add it as eventlistener to theObservationManager
.void
unsubscribe(String subscriptionId, ObservationResource resource)
Unsubscribe theSubscription
with the given id and remove it from theObservationManager
as well as from the internal map.
-
-
-
Method Detail
-
getSubscriptionDiscovery
public SubscriptionDiscovery getSubscriptionDiscovery(ObservationResource resource)
Retrieve theSubscriptionDiscovery
object for the given resource. Note, that the discovery object will be empty if there are no subscriptions present.
Note that all subscriptions present on the given resource are returned. However, the subscription id will not be visible in order to avoid abuse by clients not having registered the subscription originally.- Specified by:
getSubscriptionDiscovery
in interfaceSubscriptionManager
- Parameters:
resource
-
-
subscribe
public Subscription subscribe(SubscriptionInfo info, String subscriptionId, ObservationResource resource) throws DavException
Create a newSubscription
or update an existingSubscription
and add it as eventlistener to theObservationManager
.- Specified by:
subscribe
in interfaceSubscriptionManager
- Parameters:
info
-subscriptionId
-resource
-- Returns:
Subscription
that has been added to theObservationManager
- Throws:
DavException
- if the subscription fails
-
unsubscribe
public void unsubscribe(String subscriptionId, ObservationResource resource) throws DavException
Unsubscribe theSubscription
with the given id and remove it from theObservationManager
as well as from the internal map.- Specified by:
unsubscribe
in interfaceSubscriptionManager
- Parameters:
subscriptionId
-resource
-- Throws:
DavException
-
poll
public EventDiscovery poll(String subscriptionId, long timeout, ObservationResource resource) throws DavException
Retrieve all event bundles accumulated since for the subscription specified by the given id.- Specified by:
poll
in interfaceSubscriptionManager
- Parameters:
subscriptionId
-timeout
- timeout in millisecondsresource
-- Returns:
- object encapsulating the events.
- Throws:
DavException
-
beforeCommit
public void beforeCommit(TransactionResource resource, String lockToken)
This method is called right before a transaction is committed.- Specified by:
beforeCommit
in interfaceTransactionListener
- Parameters:
resource
- the transaction resource which will be committed.lockToken
- the lock token
-
afterCommit
public void afterCommit(TransactionResource resource, String lockToken, boolean success)
This method is called after the commit has been executed.- Specified by:
afterCommit
in interfaceTransactionListener
- Parameters:
resource
- the transaction resource which had been committed.lockToken
- the lock token.success
- if the commit was successful.
-
-