Package tigase.server.amp.db
Class MsgRepository.MsgRepositoryMDBean
java.lang.Object
tigase.db.beans.MDRepositoryBean<T>
tigase.db.beans.MDRepositoryBeanWithStatistics<MsgRepositoryIfc>
tigase.server.amp.db.MsgRepository.MsgRepositoryMDBean
- All Implemented Interfaces:
DataSourceAware
,MsgRepositoryIfc
,OfflineMsgRepositoryIfc
,Repository
,Initializable
,RegistrarBean
,RegistrarBeanWithDefaultBeanClass
,UnregisterAware
,MsgRepository.MsgRepositoryPoolBean
,ComponentStatisticsProvider
,StatisticsProviderIfc
- Enclosing class:
- MsgRepository<T,
S extends DataSource>
@Bean(name="msgRepository",
parent=Kernel.class,
active=true,
exportable=true)
@ConfigType({DefaultMode,SessionManagerMode,ConnectionManagersMode,ComponentMode})
public static class MsgRepository.MsgRepositoryMDBean
extends MDRepositoryBeanWithStatistics<MsgRepositoryIfc>
implements MsgRepositoryIfc, MsgRepository.MsgRepositoryPoolBean
Bean used to provide MsgRepository implementations
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Nested classes/interfaces inherited from class tigase.db.beans.MDRepositoryBean
MDRepositoryBean.MDRepositoryConfigBean<A extends DataSourceAware>, MDRepositoryBean.SelectorType
Nested classes/interfaces inherited from interface tigase.db.Repository
Repository.Meta, Repository.SchemaId
-
Field Summary
Fields inherited from class tigase.db.beans.MDRepositoryBean
aliases, dataSourceSelection
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
belongsTo
(Class<? extends BasicComponent> component) int
deleteMessagesToJID
(List db_ids, XMPPResourceConnection session) protected Class<? extends MsgRepositoryIfc>
findClassForDataSource
(DataSource dataSource) Method returns class implementing repository which supports data source instance provided in parameter.Class<?>
Returns default class for all bean which are defined using configuration as subbeans of bean implementing this interface.getMessageExpired
(long time, boolean delete) Loads head of the payloads queue which holds items that would be expired after stated time with an option to delete them from repository after being retrieved.getMessagesCount
(JID to) getMessagesList
(JID to) protected <T> T
getValueForDomain
(Map<String, T> map, String domain) protected void
initializeRepository
(String domain, MsgRepositoryIfc repo) Method called to initialized passed repository instance for passed domain.void
initRepository
(String resource_uri, Map<String, String> params) Deprecated.protected void
loadExpiredQueue
(int min_elements) protected void
loadExpiredQueue
(Date expired) loadMessagesToJID
(List db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) loadMessagesToJID
(XMPPResourceConnection session, boolean delete) Loads all payloads for the given user'sJID
from repository.boolean
offerExpired
(MsgRepositoryIfc repo, Object id, Element element, Date expired) void
setCondition
(ReentrantLock lock, Condition condition) void
setDataSource
(DataSource dataSource) 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.db.beans.MDRepositoryBeanWithStatistics
everyHour, everyMinute, everySecond, getRepositories, getRepository, getStatistics, setStatisticsEnabled, updateDataSourceAware, wrapInProxy
Methods inherited from class tigase.db.beans.MDRepositoryBean
beforeUnregister, getName, initialize, onDataSourceChange, register, registerIfNotExists, repositoriesStream, setDataSourceBean, unregister
-
Constructor Details
-
MsgRepositoryMDBean
public MsgRepositoryMDBean()
-
-
Method Details
-
belongsTo
- Specified by:
belongsTo
in interfaceComponentStatisticsProvider
-
getMessageExpired
Description copied from interface:OfflineMsgRepositoryIfc
Loads head of the payloads queue which holds items that would be expired after stated time with an option to delete them from repository after being retrieved. This is blocking method, which means if there is not data to return, implementation should block the call until data is available.- Specified by:
getMessageExpired
in interfaceOfflineMsgRepositoryIfc
- Parameters:
time
- time in milliseconds representing time after which given message would be considered as expireddelete
- boolean parameter controlling whether messages should be removed from repository after they retrieved.- Returns:
- head of the payloads queue which holds items that would be expired after stated time with an option to delete them from repository after being retrieved.
-
offerExpired
- Specified by:
offerExpired
in interfaceMsgRepository.MsgRepositoryPoolBean
-
loadExpiredQueue
protected void loadExpiredQueue(int min_elements) -
loadExpiredQueue
-
loadMessagesToJID
public Queue<Element> loadMessagesToJID(XMPPResourceConnection session, boolean delete) throws UserNotFoundException, TigaseDBException 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
TigaseDBException
-
storeMessage
public boolean storeMessage(JID from, JID to, Date expired, Element msg, NonAuthUserRepository userRepo) throws UserNotFoundException, TigaseDBException 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
TigaseDBException
-
initRepository
@Deprecated public void initRepository(String resource_uri, Map<String, String> params) 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
- Parameters:
resource_uri
- value in most cases representing the database connection string.params
- 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
- Throws:
UserNotFoundException
TigaseDBException
-
getMessagesList
- Specified by:
getMessagesList
in interfaceMsgRepositoryIfc
- Throws:
UserNotFoundException
TigaseDBException
-
setCondition
- Specified by:
setCondition
in interfaceMsgRepositoryIfc
-
deleteMessagesToJID
public int deleteMessagesToJID(List db_ids, XMPPResourceConnection session) throws UserNotFoundException - Specified by:
deleteMessagesToJID
in interfaceMsgRepositoryIfc
- Throws:
UserNotFoundException
-
loadMessagesToJID
public Queue<Element> loadMessagesToJID(List db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) throws UserNotFoundException, TigaseDBException - Specified by:
loadMessagesToJID
in interfaceMsgRepositoryIfc
- Throws:
UserNotFoundException
TigaseDBException
-
setDataSource
Description copied from interface:DataSourceAware
Method called to provide class with instance of a data source.- Specified by:
setDataSource
in interfaceDataSourceAware
-
getDefaultBeanClass
Description copied from interface:RegistrarBeanWithDefaultBeanClass
Returns default class for all bean which are defined using configuration as subbeans of bean implementing this interface. This allows users to have more convenient configuration file without the need to specify class for each of subbbeans if most of them will have the same class.- Specified by:
getDefaultBeanClass
in interfaceRegistrarBeanWithDefaultBeanClass
-
findClassForDataSource
protected Class<? extends MsgRepositoryIfc> findClassForDataSource(DataSource dataSource) throws DBInitException Description copied from class:MDRepositoryBean
Method returns class implementing repository which supports data source instance provided in parameter.- Specified by:
findClassForDataSource
in classMDRepositoryBean<MsgRepositoryIfc>
- Returns:
- repository class
- Throws:
DBInitException
-
initializeRepository
Description copied from class:MDRepositoryBean
Method called to initialized passed repository instance for passed domain.
Should be empty if no custom initialization is required.- Overrides:
initializeRepository
in classMDRepositoryBean<MsgRepositoryIfc>
-
getValueForDomain
-