Package org.jivesoftware.openfire
Class OfflineMessageStore
java.lang.Object
org.jivesoftware.openfire.container.BasicModule
org.jivesoftware.openfire.OfflineMessageStore
- All Implemented Interfaces:
Module,UserEventListener
Represents the user's offline message storage. A message store holds messages that were
sent to the user while they were unavailable. The user can retrieve their messages by
setting their presence to "available". The messages will then be delivered normally.
Offline message storage is optional, in which case a null implementation is returned that
always throws UnauthorizedException when adding messages to the store.
- Author:
- Iain Shigeoka
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SystemProperty<Duration>static final SystemProperty<Duration>Members for automatic offline message cleaningstatic final SystemProperty<Boolean> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMessage(org.xmpp.packet.Message message) Adds a message to this message store.voiddeleteMessage(String username, Date creationDate) Deletes the specified offline message in the store for a user.voiddeleteMessages(String username) Deletes all offline messages in the store for a user.intReturns the number of XML messages stored for a particular user.static OfflineMessageStoreReturns the instance ofOfflineMessageStorebeing used by the XMPPServer.getMessage(String username, Date creationDate) Returns the offline message of the specified user with the given creation date.getMessages(String username, boolean delete) Returns a Collection of all messages in the store for a user.intgetSize()Returns the approximate size (in bytes) of the XML messages stored for all users.intReturns the approximate size (in bytes) of the XML messages stored for a particular user.voidvoidstart()Starts the basic module.voidstop()Stops the basic module.voiduserCreated(User user, Map<String, Object> params) A user was created.voiduserDeleting(User user, Map<String, Object> params) A user is being deleted.voiduserModified(User user, Map<String, Object> params) A user's name, email, or an extended property was changed.Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy, getName, initialize
-
Field Details
-
OFFLINE_AUTOCLEAN_DAYSTOLIVE
Members for automatic offline message cleaning -
OFFLINE_AUTOCLEAN_CHECKINTERVAL
-
OFFLINE_AUTOCLEAN_ENABLE
-
-
Constructor Details
-
OfflineMessageStore
public OfflineMessageStore()Constructs a new offline message store.
-
-
Method Details
-
getInstance
Returns the instance ofOfflineMessageStorebeing used by the XMPPServer.- Returns:
- the instance of
OfflineMessageStorebeing used by the XMPPServer.
-
addMessage
Adds a message to this message store. Messages will be stored and made available for later delivery. Note that certain messages are ignored by this implementation, for example, messages that are carbon copies, have 'no-store' hints, or for which the intended recipient is not a local user. When a message is discarded for reasons like these, this method will return 'null'.- Parameters:
message- the message to store.- Returns:
- OfflineMessage when data was stored, otherwise null.
-
getMessages
Returns a Collection of all messages in the store for a user. Messages may be deleted after being selected from the database depending on the delete param.- Parameters:
username- the username of the user who's messages you'd like to receive.delete- true if the offline messages should be deleted.- Returns:
- An iterator of packets containing all offline messages.
-
getMessage
Returns the offline message of the specified user with the given creation date. The returned message will NOT be deleted from the database.- Parameters:
username- the username of the user who's message you'd like to receive.creationDate- the date when the offline message was stored in the database.- Returns:
- the offline message of the specified user with the given creation stamp.
-
deleteMessages
Deletes all offline messages in the store for a user.- Parameters:
username- the username of the user who's messages are going to be deleted.
-
deleteMessage
Deletes the specified offline message in the store for a user. The way to identify the message to delete is based on the creationDate and username.- Parameters:
username- the username of the user who's message is going to be deleted.creationDate- the date when the offline message was stored in the database.
-
getCount
Returns the number of XML messages stored for a particular user.- Parameters:
username- the username of the user.- Returns:
- the amount of stored messages.
-
getSize
Returns the approximate size (in bytes) of the XML messages stored for a particular user.- Parameters:
username- the username of the user.- Returns:
- the approximate size of stored messages (in bytes).
-
getSize
public int getSize()Returns the approximate size (in bytes) of the XML messages stored for all users.- Returns:
- the approximate size of all stored messages (in bytes).
-
userCreated
Description copied from interface:UserEventListenerA user was created.- Specified by:
userCreatedin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
userDeleting
Description copied from interface:UserEventListenerA user is being deleted.- Specified by:
userDeletingin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
userModified
Description copied from interface:UserEventListenerA user's name, email, or an extended property was changed.- Specified by:
userModifiedin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
start
Description copied from class:BasicModuleStarts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
- Specified by:
startin interfaceModule- Overrides:
startin classBasicModule- Throws:
IllegalStateException- If start is called before initialize successfully returns
-
stop
public void stop()Description copied from class:BasicModuleStops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
- Specified by:
stopin interfaceModule- Overrides:
stopin classBasicModule
-
readSizeForAllUsers
public void readSizeForAllUsers()
-