Package tigase.server.amp.db
Class JDBCMsgRepository
- All Implemented Interfaces:
DataSourceAware<DataRepository>
,MsgRepositoryIfc<DataRepository>
,OfflineMsgRepositoryIfc
,Repository
,RepositoryVersionAware
public class JDBCMsgRepository
extends MsgRepository<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 inherited from class tigase.server.amp.db.MsgRepository
awaitingInExpiredQueue, earliestOffline, expiredQueue, MAX_QUEUE_SIZE, MSGS_STORE_LIMIT_KEY, OFFLINE_MSGS_KEY, parser
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
deleteMessage
(Long msg_id) int
deleteMessagesToJID
(List<String> db_ids, XMPPResourceConnection session) getMessagesCount
(JID to) getMessagesList
(JID to) void
initRepository
(String conn_str, Map<String, String> map) Deprecated.protected void
loadExpiredQueue
(int min_elements) protected void
loadExpiredQueue
(Date expired) loadMessagesToJID
(List<String> db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) loadMessagesToJID
(XMPPResourceConnection session, boolean delete) Loads all payloads for the given user'sJID
from repository.loadMessagesToJID
(XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) protected MsgRepository.MsgDBItem
parseExpiredMessage
(DomBuilderHandler domHandler, ResultSet rs) void
setDataSource
(DataRepository data_repo) Method called to provide class with instance of a data source.boolean
storeMessage
(JID from, JID to, Date expired, Element msg, NonAuthUserRepository userRepo) Saves the massage to the repositoryMethods 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 Details
-
data_repo
-
-
Constructor Details
-
JDBCMsgRepository
public JDBCMsgRepository()
-
-
Method Details
-
setDataSource
Description copied from interface:DataSourceAware
Method called to provide class with instance of a data source.- Specified by:
setDataSource
in interfaceDataSourceAware<DataRepository>
-
initRepository
@Deprecated public void initRepository(String conn_str, Map<String, String> map) throws DBInitExceptionDeprecated.Description copied from interface:Repository
Method 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_uri
parameter as the database connection string or viaparams
map if the required repository parameters are more complex or both.- Specified by:
initRepository
in interfaceRepository
- Overrides:
initRepository
in classMsgRepository<Long,
DataRepository> - Parameters:
conn_str
- value in most cases representing the database connection string.map
- is aMap
with 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
- Specified by:
getMessagesCount
in interfaceMsgRepositoryIfc<DataRepository>
-
getMessagesList
- Specified by:
getMessagesList
in interfaceMsgRepositoryIfc<DataRepository>
-
loadMessagesToJID
public Queue<Element> loadMessagesToJID(List<String> db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) throws UserNotFoundException - Specified by:
loadMessagesToJID
in interfaceMsgRepositoryIfc<DataRepository>
- Specified by:
loadMessagesToJID
in classMsgRepository<Long,
DataRepository> - Throws:
UserNotFoundException
-
deleteMessagesToJID
public int deleteMessagesToJID(List<String> db_ids, XMPPResourceConnection session) throws UserNotFoundException - Specified by:
deleteMessagesToJID
in interfaceMsgRepositoryIfc<DataRepository>
- Specified by:
deleteMessagesToJID
in classMsgRepository<Long,
DataRepository> - Throws:
UserNotFoundException
-
loadMessagesToJID
public Queue<Element> loadMessagesToJID(XMPPResourceConnection session, boolean delete) throws UserNotFoundException Description copied from interface:OfflineMsgRepositoryIfc
Loads all payloads for the given user'sJID
from repository.- Specified by:
loadMessagesToJID
in 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
Queue
ofElement
objects representing stored payloads for the given user'sJID
- Throws:
UserNotFoundException
-
loadMessagesToJID
public Queue<Element> loadMessagesToJID(XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) throws UserNotFoundException - Throws:
UserNotFoundException
-
storeMessage
public boolean storeMessage(JID from, JID to, Date expired, Element msg, NonAuthUserRepository userRepo) throws UserNotFoundException Description copied from interface:OfflineMsgRepositoryIfc
Saves the massage to the repository- Specified by:
storeMessage
in interfaceOfflineMsgRepositoryIfc
- Parameters:
from
-JID
denotes address of the senderto
-JID
denotes address of the receiverexpired
-Date
object denoting expiration date of the messagemsg
-Element
payload of the stanza to be saveduserRepo
-NonAuthUserRepository
instance of non auth user repository to get user settings for offline messages- Returns:
true
if the packet was correctly saved to repository,false
otherwise.- Throws:
UserNotFoundException
-
parseLoadedMessages
protected Queue<Element> parseLoadedMessages(MsgRepository.OfflineMessagesProcessor proc, ResultSet rs) throws SQLException - Throws:
SQLException
-
deleteMessage
- Specified by:
deleteMessage
in classMsgRepository<Long,
DataRepository>
-
loadExpiredQueue
protected void loadExpiredQueue(int min_elements) - Specified by:
loadExpiredQueue
in classMsgRepository<Long,
DataRepository>
-
loadExpiredQueue
- Specified by:
loadExpiredQueue
in classMsgRepository<Long,
DataRepository>
-
parseExpiredMessage
protected MsgRepository.MsgDBItem parseExpiredMessage(DomBuilderHandler domHandler, ResultSet rs) throws SQLException - Throws:
SQLException
-