tigase.server.amp

## Class MsgRepository<T>

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

- All Implemented Interfaces:
    MsgRepositoryIfc, Repository
  Direct Known Subclasses:
    JDBCMsgRepository

      public abstract class MsgRepository<T>
      extends Object
      implements MsgRepositoryIfc

  Author:
    andrzej

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `MsgRepository.BroadcastMsg`
    `static class` | `MsgRepository.MSG_TYPES`
    `protected class` | `MsgRepository.MsgDBItem`
    `static interface` | `MsgRepository.OfflineMessagesProcessor`

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

      `Repository.Meta`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<String,MsgRepository.BroadcastMsg>` | `broadcastMessages`
    `protected long` | `broadcastMessagesLastCleanup`
    `protected long` | `earliestOffline`
    `protected DelayQueue<MsgRepository.MsgDBItem>` | `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
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `deleteMessage(T db_id)`
    `abstract int` | `deleteMessagesToJID(List<String> db_ids, XMPPResourceConnection session)`
    `String` | `dumpBroadcastMessageKeys()`
    `protected abstract void` | `ensureBroadcastMessageRecipient(String id, BareJID recipient)`
    `Collection<MsgRepository.BroadcastMsg>` | `getBroadcastMessages()`
    `MsgRepository.BroadcastMsg` | `getBroadcastMsg(String id)`
    `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.
    `abstract Map<Enum,Long>` | `getMessagesCount(JID to)`
    `abstract List<Element>` | `getMessagesList(JID to)`
    `protected long` | `getMsgsStoreLimit(BareJID userJid, NonAuthUserRepository userRepo)`
    `String` | `getStanzaTo()`
    `void` | `initRepository(String conn_str, Map<String,String> map)` The method is called to initialize the data repository.
    `protected abstract void` | `insertBroadcastMessage(String id, Element msg, Date expire, BareJID recipient)`
    `protected abstract void` | `loadExpiredQueue(Date expired)`
    `protected abstract void` | `loadExpiredQueue(int max)`
    `abstract void` | `loadMessagesToBroadcast()`
    `abstract Queue<Element>` | `loadMessagesToJID(List<String> db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc)`
    `boolean` | `updateBroadcastMessage(String id, Element msg, Date expire, BareJID recipient)`

    - ### 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

      `loadMessagesToJID, storeMessage`

- - ### 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

    - #### parser

          protected SimpleParser parser

    - #### earliestOffline

          protected long earliestOffline

    - #### expiredQueue

          protected DelayQueue<MsgRepository.MsgDBItem> expiredQueue

    - #### broadcastMessagesLastCleanup

          protected long broadcastMessagesLastCleanup

    - #### broadcastMessages

          protected Map<String,MsgRepository.BroadcastMsg> broadcastMessages

  - ### Constructor Detail

    - #### MsgRepository

          public MsgRepository()

  - ### Method Detail

    - #### getInstance

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

      Throws:
        `TigaseDBException`

    - #### loadExpiredQueue

          protected abstract void loadExpiredQueue(int max)

    - #### loadExpiredQueue

          protected abstract void loadExpiredQueue(Date expired)

    - #### deleteMessage

          protected abstract void deleteMessage(T db_id)

    - #### loadMessagesToBroadcast

          public abstract void loadMessagesToBroadcast()

    - #### ensureBroadcastMessageRecipient

          protected abstract void ensureBroadcastMessageRecipient(String id,
                                                                  BareJID recipient)

    - #### insertBroadcastMessage

          protected abstract void insertBroadcastMessage(String id,
                                                         Element msg,
                                                         Date expire,
                                                         BareJID recipient)

    - #### getMessagesCount

          public abstract Map<Enum,Long> getMessagesCount(JID to)
                                                   throws UserNotFoundException

      Throws:
        `UserNotFoundException`

    - #### getMessagesList

          public abstract List<Element> getMessagesList(JID to)
                                                 throws UserNotFoundException

      Throws:
        `UserNotFoundException`

    - #### loadMessagesToJID

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

      Throws:
        `UserNotFoundException`

    - #### deleteMessagesToJID

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

      Throws:
        `UserNotFoundException`

    - #### initRepository

          public void initRepository(String conn_str,
                                     Map<String,String> map)
                              throws DBInitException

      Description copied from interface: `Repository`
      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.

    - #### getMsgsStoreLimit

          protected long getMsgsStoreLimit(BareJID userJid,
                                           NonAuthUserRepository userRepo)

    - #### getBroadcastMsg

          public MsgRepository.BroadcastMsg getBroadcastMsg(String id)

    - #### dumpBroadcastMessageKeys

          public String dumpBroadcastMessageKeys()

    - #### getBroadcastMessages

          public Collection<MsgRepository.BroadcastMsg> getBroadcastMessages()

    - #### updateBroadcastMessage

          public boolean updateBroadcastMessage(String id,
                                                Element msg,
                                                Date expire,
                                                BareJID recipient)

    - #### getMessageExpired

          public Element getMessageExpired(long time,
                                           boolean delete)

      Description copied from interface: `MsgRepositoryIfc`
      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 `MsgRepositoryIfc`
      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.

    - #### getStanzaTo

          public String getStanzaTo()

Copyright © 2017 "Tigase, Inc.". All rights reserved.