tigase.server.amp.db

## Class MsgRepository<T,S extends DataSource>

- java.lang.Object
- - tigase.server.amp.db.MsgRepository<T,S>

- All Implemented Interfaces:
    DataSourceAware<S>, MsgRepositoryIfc<S>, OfflineMsgRepositoryIfc, Repository
  Direct Known Subclasses:
    JDBCMsgRepository, XMLMsgRepository

      public abstract class MsgRepository<T,S extends DataSource>
      extends Object
      implements MsgRepositoryIfc<S>

  Author:
    andrzej

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `MsgRepository.MSG_TYPES`
    `static class` | `MsgRepository.MsgDBItem<T>`
    `static class` | `MsgRepository.MsgRepositoryMDBean` Bean used to provide MsgRepository implementations
    `static interface` | `MsgRepository.OfflineMessagesProcessor`

    - ### Nested classes/interfaces inherited from interface tigase.db.Repository

      `Repository.Meta, Repository.SchemaId`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `earliestOffline`
    `protected DelayQueue<MsgRepository.MsgDBItem<T>>` | `expiredQueue`
    `protected static int` | `MAX_QUEUE_SIZE`
    `static String` | `MSGS_STORE_LIMIT_KEY`
    `static String` | `OFFLINE_MSGS_KEY`
    `protected SimpleParser` | `parser`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MsgRepository()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `deleteMessage(T db_id)`
    `abstract int` | `deleteMessagesToJID(List<String> db_ids, XMPPResourceConnection session)`
    `static MsgRepositoryIfc` | `getInstance(String cls, String id_string)`
    `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.
    `protected long` | `getMsgsStoreLimit(BareJID userJid, NonAuthUserRepository userRepo)`
    `void` | `initRepository(String conn_str, Map<String,String> map)` Deprecated.
    `protected abstract void` | `loadExpiredQueue(Date expired)`
    `protected abstract void` | `loadExpiredQueue(int max)`
    `abstract Queue<Element>` | `loadMessagesToJID(List<String> db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc)`
    `void` | `setCondition(ReentrantLock lock, Condition condition)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface tigase.db.MsgRepositoryIfc

      `getMessagesCount, getMessagesList`

    - ### Methods inherited from interface tigase.db.OfflineMsgRepositoryIfc

      `loadMessagesToJID, storeMessage`

    - ### Methods inherited from interface tigase.db.DataSourceAware

      `setDataSource`

- - ### Field Detail

    - #### OFFLINE_MSGS_KEY

          public static final String OFFLINE_MSGS_KEY

      See Also:
        Constant Field Values

    - #### MSGS_STORE_LIMIT_KEY

          public static final String MSGS_STORE_LIMIT_KEY

      See Also:
        Constant Field Values

    - #### MAX_QUEUE_SIZE

          protected static final int MAX_QUEUE_SIZE

      See Also:
        Constant Field Values

    - #### earliestOffline

          protected long earliestOffline

    - #### parser

          protected SimpleParser parser

    - #### expiredQueue

          protected DelayQueue<MsgRepository.MsgDBItem<T>> expiredQueue

  - ### Constructor Detail

    - #### MsgRepository

          public MsgRepository()

  - ### Method Detail

    - #### getInstance

          public static MsgRepositoryIfc getInstance(String cls,
                                                     String id_string)
                                              throws TigaseDBException

      Throws:
        `TigaseDBException`

    - #### loadMessagesToJID

          public abstract Queue<Element> loadMessagesToJID(List<String> db_ids,
                                                           XMPPResourceConnection session,
                                                           boolean delete,
                                                           MsgRepository.OfflineMessagesProcessor proc)
                                                    throws UserNotFoundException

      Specified by:
        `loadMessagesToJID` in interface `MsgRepositoryIfc<S extends DataSource>`
      Throws:
        `UserNotFoundException`

    - #### deleteMessagesToJID

          public abstract int deleteMessagesToJID(List<String> db_ids,
                                                  XMPPResourceConnection session)
                                           throws UserNotFoundException

      Specified by:
        `deleteMessagesToJID` in interface `MsgRepositoryIfc<S extends DataSource>`
      Throws:
        `UserNotFoundException`

    - #### initRepository

          @Deprecated
          public void initRepository(String conn_str,
                                                 Map<String,String> map)
                                          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 via `resource_uri` parameter as the database connection string or via `params` map if the required repository parameters are more complex or both.
      Specified by:
        `initRepository` in interface `Repository`
      Parameters:
        `conn_str` - value in most cases representing the database connection string.
        `map` - is a `Map` 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.

    - #### 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 interface `OfflineMsgRepositoryIfc`
      Parameters:
        `time` - time in milliseconds representing time after which given message would be considered as expired
        `delete` - 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.

    - #### setCondition

          public void setCondition(ReentrantLock lock,
                                   Condition condition)

      Specified by:
        `setCondition` in interface `MsgRepositoryIfc<S extends DataSource>`

    - #### loadExpiredQueue

          protected abstract void loadExpiredQueue(int max)

    - #### loadExpiredQueue

          protected abstract void loadExpiredQueue(Date expired)

    - #### deleteMessage

          protected abstract void deleteMessage(T db_id)

    - #### getMsgsStoreLimit

          protected long getMsgsStoreLimit(BareJID userJid,
                                           NonAuthUserRepository userRepo)
                                    throws UserNotFoundException

      Throws:
        `UserNotFoundException`

Copyright © 2004–2021 "Tigase, Inc.". All rights reserved.