com.openexchange.mail.event
Class PooledEvent

java.lang.Object
  extended by com.openexchange.mail.event.PooledEvent
All Implemented Interfaces:
java.lang.Comparable<java.util.concurrent.Delayed>, java.util.concurrent.Delayed

public final class PooledEvent
extends java.lang.Object
implements java.util.concurrent.Delayed

PooledEvent - A pooled event.

Author:
Thorben Betten

Constructor Summary
PooledEvent(int contextId, int userId, int accountId, java.lang.String fullname, boolean contentRelated, boolean immediateDelivery, com.openexchange.session.Session session)
          Initializes a new PooledEvent with default topic.
PooledEvent(java.lang.String topic, int contextId, int userId, int accountId, java.lang.String fullname, boolean contentRelated, boolean immediateDelivery, com.openexchange.session.Session session)
          Initializes a new PooledEvent.
 
Method Summary
 int compareTo(java.util.concurrent.Delayed o)
           
 boolean equals(java.lang.Object obj)
           
 boolean equalsByUser(int userId, int contextId)
          Checks if this pooled events matches specified user ID and context ID.
 int getAccountId()
          Gets the account ID.
 int getContextId()
          Gets the context ID.
 long getDelay(java.util.concurrent.TimeUnit unit)
           
 java.lang.String getFullname()
          Gets the fullname
 com.openexchange.session.Session getSession()
          Gets the session
 java.lang.String getTopic()
          Gets the topic for this event.
 int getUserId()
          Gets the user ID.
 int hashCode()
           
 boolean isAsync()
          Checks whether the event should be delivered asynchronously.
 boolean isContentRelated()
          Checks for a content-related event.
 long lastAccessed()
          Gets this pooled notification's last-accessed time stamp.
 PooledEvent setAsync(boolean async)
          Sets whether the event should be delivered asynchronously (default behavior).
 void touch()
          Touches this pooled notification; meaning its last-accessed time stamp is set to now.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PooledEvent

public PooledEvent(int contextId,
                   int userId,
                   int accountId,
                   java.lang.String fullname,
                   boolean contentRelated,
                   boolean immediateDelivery,
                   com.openexchange.session.Session session)
Initializes a new PooledEvent with default topic.

Parameters:
contextId - The context ID
userId - The user ID
accountId - The account ID
fullname - The folder fullname
contentRelated - true for a content-related event; otherwise false
immediateDelivery - true for immediate delivery; otherwise false
session - The session

PooledEvent

public PooledEvent(java.lang.String topic,
                   int contextId,
                   int userId,
                   int accountId,
                   java.lang.String fullname,
                   boolean contentRelated,
                   boolean immediateDelivery,
                   com.openexchange.session.Session session)
Initializes a new PooledEvent.

Parameters:
contextId - The context ID
userId - The user ID
accountId - The account ID
fullname - The folder fullname
contentRelated - true for a content-related event; otherwise false
immediateDelivery - true for immediate delivery; otherwise false
session - The session
Method Detail

setAsync

public PooledEvent setAsync(boolean async)
Sets whether the event should be delivered asynchronously (default behavior). If false EventPool.put(PooledEvent) does not return to the caller until delivery of the event is completed.

Note: Works only if this pooled event is considered for immediate delivery.

Parameters:
async - true to deliver asynchronously; otherwise false
Returns:
This pooled event with new behavior applied

isAsync

public boolean isAsync()
Checks whether the event should be delivered asynchronously.

Returns:
true to deliver asynchronously; otherwise false

getDelay

public long getDelay(java.util.concurrent.TimeUnit unit)
Specified by:
getDelay in interface java.util.concurrent.Delayed

compareTo

public int compareTo(java.util.concurrent.Delayed o)
Specified by:
compareTo in interface java.lang.Comparable<java.util.concurrent.Delayed>

getTopic

public java.lang.String getTopic()
Gets the topic for this event.

Returns:
The topic

touch

public void touch()
Touches this pooled notification; meaning its last-accessed time stamp is set to now.


lastAccessed

public long lastAccessed()
Gets this pooled notification's last-accessed time stamp.

Returns:
The last-accessed time stamp.

equalsByUser

public boolean equalsByUser(int userId,
                            int contextId)
Checks if this pooled events matches specified user ID and context ID.

Parameters:
userId - The user ID
contextId - The context ID
Returns:
true this pooled events matches; otherwise false

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getContextId

public int getContextId()
Gets the context ID.

Returns:
The context ID

getUserId

public int getUserId()
Gets the user ID.

Returns:
The user ID

getAccountId

public int getAccountId()
Gets the account ID.

Returns:
The account ID

getFullname

public java.lang.String getFullname()
Gets the fullname

Returns:
The fullname

getSession

public com.openexchange.session.Session getSession()
Gets the session

Returns:
The session

isContentRelated

public boolean isContentRelated()
Checks for a content-related event.

Returns:
true for a content-related event; otherwise false