Package tigase.server.amp.db
Class JDBCMsgRepository
- java.lang.Object
-
- tigase.server.amp.db.MsgRepository<java.lang.Long,DataRepository>
-
- tigase.server.amp.db.JDBCMsgRepository
-
- All Implemented Interfaces:
DataSourceAware<DataRepository>,MsgRepositoryIfc<DataRepository>,OfflineMsgRepositoryIfc,Repository,RepositoryVersionAware
public class JDBCMsgRepository extends MsgRepository<java.lang.Long,DataRepository> implements RepositoryVersionAware
Created: May 3, 2010 5:28:02 PM- Author:
- Artur Hefczyc
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class tigase.server.amp.db.MsgRepository
MsgRepository.MSG_TYPES, MsgRepository.MsgDBItem<T>, MsgRepository.MsgRepositoryMDBean, MsgRepository.MsgRepositoryPoolBean<T>, MsgRepository.OfflineMessagesProcessor
-
Nested classes/interfaces inherited from interface tigase.db.Repository
Repository.Meta, Repository.SchemaId
-
Nested classes/interfaces inherited from interface tigase.db.util.RepositoryVersionAware
RepositoryVersionAware.SchemaVersion
-
-
Field Summary
Fields Modifier and Type Field Description protected DataRepositorydata_repo-
Fields inherited from class tigase.server.amp.db.MsgRepository
awaitingInExpiredQueue, earliestOffline, expiredQueue, MAX_QUEUE_SIZE, MSGS_STORE_LIMIT_KEY, OFFLINE_MSGS_KEY, parser
-
-
Constructor Summary
Constructors Constructor Description JDBCMsgRepository()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voiddeleteMessage(java.lang.Long msg_id)intdeleteMessagesToJID(java.util.List<java.lang.String> db_ids, XMPPResourceConnection session)java.util.Map<java.lang.Enum,java.lang.Long>getMessagesCount(JID to)java.util.List<Element>getMessagesList(JID to)voidinitRepository(java.lang.String conn_str, java.util.Map<java.lang.String,java.lang.String> map)Deprecated.protected voidloadExpiredQueue(int min_elements)protected voidloadExpiredQueue(java.util.Date expired)java.util.Queue<Element>loadMessagesToJID(java.util.List<java.lang.String> db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc)java.util.Queue<Element>loadMessagesToJID(XMPPResourceConnection session, boolean delete)Loads all payloads for the given user'sJIDfrom repository.java.util.Queue<Element>loadMessagesToJID(XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc)protected MsgRepository.MsgDBItemparseExpiredMessage(DomBuilderHandler domHandler, java.sql.ResultSet rs)protected java.util.Queue<Element>parseLoadedMessages(MsgRepository.OfflineMessagesProcessor proc, java.sql.ResultSet rs)voidsetDataSource(DataRepository data_repo)Method called to provide class with instance of a data source.booleanstoreMessage(JID from, JID to, java.util.Date expired, Element msg, NonAuthUserRepository userRepo)Saves the massage to the repository-
Methods inherited from class tigase.server.amp.db.MsgRepository
getInstance, getMessageExpired, getMsgsStoreLimit, setCondition
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface tigase.db.util.RepositoryVersionAware
getVersion, updateSchema
-
-
-
-
Field Detail
-
data_repo
protected DataRepository data_repo
-
-
Method Detail
-
setDataSource
public void setDataSource(DataRepository data_repo)
Description copied from interface:DataSourceAwareMethod called to provide class with instance of a data source.- Specified by:
setDataSourcein interfaceDataSourceAware<DataRepository>
-
initRepository
@Deprecated public void initRepository(java.lang.String conn_str, java.util.Map<java.lang.String,java.lang.String> map) throws DBInitExceptionDeprecated.Description copied from interface:RepositoryMethod is deprecated and should not be user any more.
The method is called to initialize the data repository. Depending on the implementation all the initialization parameters can be passed either viaresource_uriparameter as the database connection string or viaparamsmap if the required repository parameters are more complex or both.- Specified by:
initRepositoryin interfaceRepository- Overrides:
initRepositoryin classMsgRepository<java.lang.Long,DataRepository>- Parameters:
conn_str- value in most cases representing the database connection string.map- is aMapwith repository properties necessary to initialize and perform all the functions. The initialization parameters are implementation dependent.- Throws:
DBInitException- if there was an error during repository initialization. Some implementations, though, perform so called lazy initialization so even though there is a problem with the underlying repository it may not be signaled through this method call.
-
getMessagesCount
public java.util.Map<java.lang.Enum,java.lang.Long> getMessagesCount(JID to)
- Specified by:
getMessagesCountin interfaceMsgRepositoryIfc<DataRepository>
-
getMessagesList
public java.util.List<Element> getMessagesList(JID to)
- Specified by:
getMessagesListin interfaceMsgRepositoryIfc<DataRepository>
-
loadMessagesToJID
public java.util.Queue<Element> loadMessagesToJID(java.util.List<java.lang.String> db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) throws UserNotFoundException
- Specified by:
loadMessagesToJIDin interfaceMsgRepositoryIfc<DataRepository>- Specified by:
loadMessagesToJIDin classMsgRepository<java.lang.Long,DataRepository>- Throws:
UserNotFoundException
-
deleteMessagesToJID
public int deleteMessagesToJID(java.util.List<java.lang.String> db_ids, XMPPResourceConnection session) throws UserNotFoundException- Specified by:
deleteMessagesToJIDin interfaceMsgRepositoryIfc<DataRepository>- Specified by:
deleteMessagesToJIDin classMsgRepository<java.lang.Long,DataRepository>- Throws:
UserNotFoundException
-
loadMessagesToJID
public java.util.Queue<Element> loadMessagesToJID(XMPPResourceConnection session, boolean delete) throws UserNotFoundException
Description copied from interface:OfflineMsgRepositoryIfcLoads all payloads for the given user'sJIDfrom repository.- Specified by:
loadMessagesToJIDin interfaceOfflineMsgRepositoryIfc- Parameters:
session- user session which keeps all the user session data and also gives an access to the user's repository data.delete- boolean parameter controlling whether messages should be removed from repository after they retrieved.- Returns:
- a
QueueofElementobjects representing stored payloads for the given user'sJID - Throws:
UserNotFoundException
-
loadMessagesToJID
public java.util.Queue<Element> loadMessagesToJID(XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) throws UserNotFoundException
- Throws:
UserNotFoundException
-
storeMessage
public boolean storeMessage(JID from, JID to, java.util.Date expired, Element msg, NonAuthUserRepository userRepo) throws UserNotFoundException
Description copied from interface:OfflineMsgRepositoryIfcSaves the massage to the repository- Specified by:
storeMessagein interfaceOfflineMsgRepositoryIfc- Parameters:
from-JIDdenotes address of the senderto-JIDdenotes address of the receiverexpired-Dateobject denoting expiration date of the messagemsg-Elementpayload of the stanza to be saveduserRepo-NonAuthUserRepositoryinstance of non auth user repository to get user settings for offline messages- Returns:
trueif the packet was correctly saved to repository,falseotherwise.- Throws:
UserNotFoundException
-
parseLoadedMessages
protected java.util.Queue<Element> parseLoadedMessages(MsgRepository.OfflineMessagesProcessor proc, java.sql.ResultSet rs) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
deleteMessage
protected void deleteMessage(java.lang.Long msg_id)
- Specified by:
deleteMessagein classMsgRepository<java.lang.Long,DataRepository>
-
loadExpiredQueue
protected void loadExpiredQueue(int min_elements)
- Specified by:
loadExpiredQueuein classMsgRepository<java.lang.Long,DataRepository>
-
loadExpiredQueue
protected void loadExpiredQueue(java.util.Date expired)
- Specified by:
loadExpiredQueuein classMsgRepository<java.lang.Long,DataRepository>
-
parseExpiredMessage
protected MsgRepository.MsgDBItem parseExpiredMessage(DomBuilderHandler domHandler, java.sql.ResultSet rs) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-