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
Nested Classes Modifier and Type Class Description static class
MsgRepository.MsgRepositoryMDBean.MsgRepositoryConfigBean
static class
MsgRepository.MsgRepositoryMDBean.RepoAwareMsgDBItem
-
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
Constructors Constructor Description MsgRepositoryMDBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
belongsTo(java.lang.Class<? extends BasicComponent> component)
int
deleteMessagesToJID(java.util.List db_ids, XMPPResourceConnection session)
protected java.lang.Class<? extends MsgRepositoryIfc>
findClassForDataSource(DataSource dataSource)
Method returns class implementing repository which supports data source instance provided in parameter.java.lang.Class<?>
getDefaultBeanClass()
Returns default class for all bean which are defined using configuration as subbeans of bean implementing this interface.Element
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.java.util.Map<java.lang.Enum,java.lang.Long>
getMessagesCount(JID to)
java.util.List<Element>
getMessagesList(JID to)
protected <T> T
getValueForDomain(java.util.Map<java.lang.String,T> map, java.lang.String domain)
protected void
initializeRepository(java.lang.String domain, MsgRepositoryIfc repo)
Method called to initialized passed repository instance for passed domain.void
initRepository(java.lang.String resource_uri, java.util.Map<java.lang.String,java.lang.String> params)
Deprecated.protected void
loadExpiredQueue(int min_elements)
protected void
loadExpiredQueue(java.util.Date expired)
java.util.Queue<Element>
loadMessagesToJID(java.util.List 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'sJID
from repository.boolean
offerExpired(MsgRepositoryIfc repo, java.lang.Object id, Element element, java.util.Date expired)
void
setCondition(java.util.concurrent.locks.ReentrantLock lock, java.util.concurrent.locks.Condition condition)
void
setDataSource(DataSource dataSource)
Method called to provide class with instance of a data source.boolean
storeMessage(JID from, JID to, java.util.Date expired, Element msg, NonAuthUserRepository userRepo)
Saves the massage to the repository-
Methods 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
-
-
-
-
Method Detail
-
belongsTo
public boolean belongsTo(java.lang.Class<? extends BasicComponent> component)
- Specified by:
belongsTo
in interfaceComponentStatisticsProvider
-
getMessageExpired
public Element getMessageExpired(long time, boolean delete)
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
public boolean offerExpired(MsgRepositoryIfc repo, java.lang.Object id, Element element, java.util.Date expired)
- Specified by:
offerExpired
in interfaceMsgRepository.MsgRepositoryPoolBean
-
loadExpiredQueue
protected void loadExpiredQueue(int min_elements)
-
loadExpiredQueue
protected void loadExpiredQueue(java.util.Date expired)
-
loadMessagesToJID
public java.util.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
-
storeMessage
public boolean storeMessage(JID from, JID to, java.util.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
-
initRepository
@Deprecated public void initRepository(java.lang.String resource_uri, java.util.Map<java.lang.String,java.lang.String> params) throws DBInitException
Deprecated.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
public java.util.Map<java.lang.Enum,java.lang.Long> getMessagesCount(JID to) throws UserNotFoundException
- Specified by:
getMessagesCount
in interfaceMsgRepositoryIfc
- Throws:
UserNotFoundException
-
getMessagesList
public java.util.List<Element> getMessagesList(JID to) throws UserNotFoundException
- Specified by:
getMessagesList
in interfaceMsgRepositoryIfc
- Throws:
UserNotFoundException
-
setCondition
public void setCondition(java.util.concurrent.locks.ReentrantLock lock, java.util.concurrent.locks.Condition condition)
- Specified by:
setCondition
in interfaceMsgRepositoryIfc
-
deleteMessagesToJID
public int deleteMessagesToJID(java.util.List db_ids, XMPPResourceConnection session) throws UserNotFoundException
- Specified by:
deleteMessagesToJID
in interfaceMsgRepositoryIfc
- Throws:
UserNotFoundException
-
loadMessagesToJID
public java.util.Queue<Element> loadMessagesToJID(java.util.List db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) throws UserNotFoundException
- Specified by:
loadMessagesToJID
in interfaceMsgRepositoryIfc
- Throws:
UserNotFoundException
-
setDataSource
public void setDataSource(DataSource dataSource)
Description copied from interface:DataSourceAware
Method called to provide class with instance of a data source.- Specified by:
setDataSource
in interfaceDataSourceAware
-
getDefaultBeanClass
public java.lang.Class<?> 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 java.lang.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
protected void initializeRepository(java.lang.String domain, MsgRepositoryIfc repo)
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
protected <T> T getValueForDomain(java.util.Map<java.lang.String,T> map, java.lang.String domain)
-
-