org.apache.jackrabbit.webdav.jcr.observation
Class SubscriptionImpl

java.lang.Object
  extended by org.apache.jackrabbit.webdav.jcr.observation.SubscriptionImpl
All Implemented Interfaces:
EventListener, ObservationConstants, Subscription, XmlSerializable

public class SubscriptionImpl
extends Object
implements Subscription, ObservationConstants, EventListener

The Subscription class encapsulates a single subscription with the following responsibilities:


Field Summary
 
Fields inherited from interface org.apache.jackrabbit.webdav.observation.ObservationConstants
HEADER_POLL_TIMEOUT, HEADER_SUBSCRIPTIONID, NAMESPACE, SUBSCRIPTIONDISCOVERY, XML_EVENT, XML_EVENT_TRANSACTION_ID, XML_EVENTBUNDLE, XML_EVENTDATE, XML_EVENTDISCOVERY, XML_EVENTIDENTIFIER, XML_EVENTINFO, XML_EVENTTYPE, XML_EVENTUSERDATA, XML_EVENTUSERID, XML_FILTER, XML_NODETYPE_NAME, XML_NOLOCAL, XML_SUBSCRIPTION, XML_SUBSCRIPTIONID, XML_SUBSCRIPTIONINFO, XML_UUID
 
Constructor Summary
SubscriptionImpl(SubscriptionInfo info, ObservationResource resource)
          Create a new Subscription with the given SubscriptionInfo and resource.
 
Method Summary
static EventType[] getAllEventTypes()
           
static EventType getEventType(int jcrEventType)
          Static utility method to convert the type defined by a JCR event into an EventType object.
static int getJcrEventType(EventType eventType)
          Static utility method to convert an EventType as present in the Xml body into the corresponding JCR event constant defined by Event.
 String getSubscriptionId()
          Returns the id of this subscription.
 void onEvent(EventIterator events)
          Records the events passed as a new event bundle in order to make them available with the next discoverEvents(long) request.
 Element toXml(Document document)
          Return the Xml representation of this Subscription as required for the SubscriptionDiscovery webdav property that in included in the response body of a sucessful SUBSCRIBE request or as part of a PROPFIND response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubscriptionImpl

public SubscriptionImpl(SubscriptionInfo info,
                        ObservationResource resource)
                 throws DavException
Create a new Subscription with the given SubscriptionInfo and resource.

Parameters:
info -
resource -
Throws:
DavException - if resource is not based on a JCR repository or the repository does not support observation.
Method Detail

getSubscriptionId

public String getSubscriptionId()
Returns the id of this subscription.

Specified by:
getSubscriptionId in interface Subscription
Returns:
subscriptionId

toXml

public Element toXml(Document document)
Return the Xml representation of this Subscription as required for the SubscriptionDiscovery webdav property that in included in the response body of a sucessful SUBSCRIBE request or as part of a PROPFIND response.

Specified by:
toXml in interface XmlSerializable
Parameters:
document -
Returns:
Xml representation
See Also:
XmlSerializable.toXml(Document)

onEvent

public void onEvent(EventIterator events)
Records the events passed as a new event bundle in order to make them available with the next discoverEvents(long) request. If this subscription is expired it will remove itself as listener from the observation manager.

Specified by:
onEvent in interface EventListener
Parameters:
events - to be recorded.
See Also:
EventListener.onEvent(EventIterator), discoverEvents(long)

getEventType

public static EventType getEventType(int jcrEventType)
Static utility method to convert the type defined by a JCR event into an EventType object.

Parameters:
jcrEventType -
Returns:
EventType representation of the given JCR event type.
Throws:
IllegalArgumentException - if the given int does not represent a valid type constants as defined by Event.
Valid values are

getAllEventTypes

public static EventType[] getAllEventTypes()
Returns:
The DAV event type representation for all known JCR event types.

getJcrEventType

public static int getJcrEventType(EventType eventType)
                           throws DavException
Static utility method to convert an EventType as present in the Xml body into the corresponding JCR event constant defined by Event.

Parameters:
eventType -
Returns:
Any of the event types defined by Event.
Possible values are
Throws:
DavException - if the given event type does not define a valid JCR event type, such as returned by getEventType(int).


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.