com.atlassian.crowd.event
Class EventStoreGeneric

java.lang.Object
  extended by com.atlassian.crowd.event.EventStoreGeneric
All Implemented Interfaces:
EventStore

public final class EventStoreGeneric
extends Object
implements EventStore

Thread-safe EventStore implementation that uses main memory as a backing store. The amount of events stored is fixed, and after reaching the limit, the oldest events will start to get dropped.


Constructor Summary
EventStoreGeneric(long maxStoredEvents)
          Creates a new EventStoreGeneric instance.
 
Method Summary
 String getCurrentEventToken()
          Returns a token that can be used for querying events that have happened after the token was generated.
 Events getNewEvents(String eventToken)
          Returns an events object which contains a new eventToken and events that happened after the given eventToken was generated.
 void invalidateEvents()
          Removes all events from the EventStore.
 void storeEvent(OperationEvent event)
          Stores the given event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventStoreGeneric

public EventStoreGeneric(long maxStoredEvents)
Creates a new EventStoreGeneric instance.

Parameters:
maxStoredEvents - maximum amount of events to keep in the memory
Method Detail

getCurrentEventToken

public String getCurrentEventToken()
Description copied from interface: EventStore
Returns a token that can be used for querying events that have happened after the token was generated.

If the event token has not changed since the last call to this method, it is guaranteed that no new events have been received.

The format of event token is implementation specific and can change without a warning.

Specified by:
getCurrentEventToken in interface EventStore
Returns:
token that can be used for querying events that have happened after the token was generated.

getNewEvents

public Events getNewEvents(String eventToken)
                    throws EventTokenExpiredException
Description copied from interface: EventStore
Returns an events object which contains a new eventToken and events that happened after the given eventToken was generated.

If for any reason event store is unable to retrieve events that happened after the event token was generated, an EventTokenExpiredException will be thrown. The caller is then expected to call EventStore.getCurrentEventToken() again before asking for new events.

Specified by:
getNewEvents in interface EventStore
Parameters:
eventToken - event token that was retrieved by a call to EventStore.getCurrentEventToken() or EventStore.getNewEvents(String)
Returns:
events object which contains a new eventToken and events that happened after the given eventToken was generated.
Throws:
EventTokenExpiredException - if events that happened after the event token was generated can not be retrieved

storeEvent

public void storeEvent(OperationEvent event)
Description copied from interface: EventStore
Stores the given event. Implementations are free to limit the amount of events stored.

Specified by:
storeEvent in interface EventStore
Parameters:
event - event to be stored

invalidateEvents

public void invalidateEvents()
Description copied from interface: EventStore
Removes all events from the EventStore.

Specified by:
invalidateEvents in interface EventStore


Copyright © 2013 Atlassian. All Rights Reserved.