Package tigase.server.amp.db
Class MsgRepository.MsgRepositoryMDBean
java.lang.Object
tigase.db.beans.MDRepositoryBean<MsgRepositoryIfc>
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 ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from class tigase.db.beans.MDRepositoryBean
MDRepositoryBean.MDRepositoryConfigBean<A extends DataSourceAware>, MDRepositoryBean.SelectorTypeNested 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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanbelongsTo(Class<? extends BasicComponent> component) intdeleteMessagesToJID(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> TgetValueForDomain(Map<String, T> map, String domain) protected voidinitializeRepository(String domain, MsgRepositoryIfc repo) Method called to initialized passed repository instance for passed domain.voidinitRepository(String resource_uri, Map<String, String> params) Deprecated.protected voidloadExpiredQueue(int min_elements) protected voidloadExpiredQueue(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'sJIDfrom repository.booleanofferExpired(MsgRepositoryIfc repo, Object id, Element element, Date expired) voidsetCondition(ReentrantLock lock, Condition condition) voidsetDataSource(DataSource dataSource) Method called to provide class with instance of a data source.booleanstoreMessage(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, wrapInProxyMethods 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:
belongsToin interfaceComponentStatisticsProvider
-
getMessageExpired
Description copied from interface:OfflineMsgRepositoryIfcLoads 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:
getMessageExpiredin 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:
offerExpiredin 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: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:
UserNotFoundExceptionTigaseDBException
-
storeMessage
public boolean storeMessage(JID from, JID to, Date expired, Element msg, NonAuthUserRepository userRepo) throws UserNotFoundException, TigaseDBException 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:
UserNotFoundExceptionTigaseDBException
-
initRepository
@Deprecated public void initRepository(String resource_uri, Map<String, String> params) 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- Parameters:
resource_uri- value in most cases representing the database connection string.params- 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
- Specified by:
getMessagesCountin interfaceMsgRepositoryIfc- Throws:
UserNotFoundExceptionTigaseDBException
-
getMessagesList
- Specified by:
getMessagesListin interfaceMsgRepositoryIfc- Throws:
UserNotFoundExceptionTigaseDBException
-
setCondition
- Specified by:
setConditionin interfaceMsgRepositoryIfc
-
deleteMessagesToJID
public int deleteMessagesToJID(List db_ids, XMPPResourceConnection session) throws UserNotFoundException - Specified by:
deleteMessagesToJIDin interfaceMsgRepositoryIfc- Throws:
UserNotFoundException
-
loadMessagesToJID
public Queue<Element> loadMessagesToJID(List db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc) throws UserNotFoundException, TigaseDBException - Specified by:
loadMessagesToJIDin interfaceMsgRepositoryIfc- Throws:
UserNotFoundExceptionTigaseDBException
-
setDataSource
Description copied from interface:DataSourceAwareMethod called to provide class with instance of a data source.- Specified by:
setDataSourcein interfaceDataSourceAware
-
getDefaultBeanClass
Description copied from interface:RegistrarBeanWithDefaultBeanClassReturns 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:
getDefaultBeanClassin interfaceRegistrarBeanWithDefaultBeanClass
-
findClassForDataSource
protected Class<? extends MsgRepositoryIfc> findClassForDataSource(DataSource dataSource) throws DBInitException Description copied from class:MDRepositoryBeanMethod returns class implementing repository which supports data source instance provided in parameter.- Specified by:
findClassForDataSourcein classMDRepositoryBean<MsgRepositoryIfc>- Returns:
- repository class
- Throws:
DBInitException
-
initializeRepository
Description copied from class:MDRepositoryBeanMethod called to initialized passed repository instance for passed domain.
Should be empty if no custom initialization is required.- Overrides:
initializeRepositoryin classMDRepositoryBean<MsgRepositoryIfc>
-
getValueForDomain
-