tigase.vhosts

## Class VHostJDBCRepository

- java.lang.Object
- - tigase.db.comp.ConfigRepository<Item>
  - - tigase.db.comp.UserRepoRepository<VHostItem>
    - - tigase.vhosts.VHostJDBCRepository

- All Implemented Interfaces:
    Iterable<VHostItem>, ComponentRepository<VHostItem>, Repository

      public class VHostJDBCRepository
      extends UserRepoRepository<VHostItem>

  This implementation stores virtual domains in the UserRepository database. It loads initial settings and virtual hosts from the configuration file and then loads more vhosts from the database. Virtual domains from the database can overwrite (disable) vhosts loaded from the configuration file. This implementation keeps all virtual hosts and their parameters in a single database field. This might not be very efficient if you want to manager big number of virtual domains. It is sufficient for hundreds of vhosts. If you need thousands of VHosts support I advice to implement this storage in more efficient way using separate database tables instead of UserRepository. Please note there is a limit of about 300 vhosts if you use Derby database.
  Since:
    Nov 29, 2008 2:32:48 PM
  Author:
    Artur Hefczyc

- - ### Nested Class Summary

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

      `Repository.Meta`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DNS_DEF_IP_PROP_KEY` Configuration option allowing specify default IP to which VHost should resolve vhost-man/dns-def-ip=
    `static String` | `DNS_DEF_IP_PROP_VAL` Field description
    `static String` | `DNS_SRV_DEF_ADDR_PROP_KEY` Configuration option allowing specify default hostname to which VHost should resolve vhost-man/dns-srv-def-addr=
    `static String` | `DNS_SRV_DEF_ADDR_PROP_VAL` Field description
    `static String` | `DOMAINS_PER_USER_LIMIT_PROP_KEY` Configuration option allowing specify default maximum number that user can register in service vhost-man/domains-per-user-limit=
    `static int` | `DOMAINS_PER_USER_LIMIT_PROP_VAL` Field description

    - ### Fields inherited from class tigase.db.comp.UserRepoRepository

      `REPO_CLASS_PROP_KEY, REPO_URI_PROP_KEY`

    - ### Fields inherited from class tigase.db.comp.ConfigRepository

      `items, itemsHash`

    - ### Fields inherited from interface tigase.db.comp.ComponentRepository

      `COMP_REPO_BIND`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `VHostJDBCRepository()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `destroy()` Method destroys this instance of ComponentRepository releasing resources allocated for this instance of ComponentRepository if possible
    `String` | `getConfigKey()` Method description
    `String[]` | `getDefaultPropetyItems()` Method description
    `void` | `getDefaults(Map<String,Object> defs, Map<String,Object> params)` The method is called to obtain default configuration settings if there are any for this repository implementation The configuration settings are implementation dependent and there are no defaults set by the server.
    `VHostItem` | `getItemInstance()` Creates a new, uninitialized instance of the repository Item.
    `String` | `getItemsListPKey()` Method description
    `String` | `getPropertyKey()` Method description
    `BareJID` | `getRepoUser()` Method description
    `void` | `initRepository(String resource_uri, Map<String,String> params)` The method is called to initialize the data repository.
    `static void` | `main(String[] args)` Simple verification of VHost validation
    `void` | `setProperties(Map<String,Object> properties)` Method description
    `String` | `validateItem(VHostItem item)` Performs Item validation to check whether it meets the repository policy.

    - ### Methods inherited from class tigase.db.comp.UserRepoRepository

      `reload, store`

    - ### Methods inherited from class tigase.db.comp.ConfigRepository

      `addItem, addItemNoStore, addRepoChangeListener, allItems, contains, getItem, initItemsMap, itemChanged, iterator, removeItem, removeRepoChangeListener, setAutoloadTimer, size, toString`

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

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

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Field Detail

    - #### DNS_DEF_IP_PROP_KEY

          public static final String DNS_DEF_IP_PROP_KEY

      Configuration option allowing specify default IP to which VHost should resolve vhost-man/dns-def-ip=
      See Also:
        Constant Field Values

    - #### DNS_DEF_IP_PROP_VAL

          public static String DNS_DEF_IP_PROP_VAL

      Field description

    - #### DNS_SRV_DEF_ADDR_PROP_KEY

          public static final String DNS_SRV_DEF_ADDR_PROP_KEY

      Configuration option allowing specify default hostname to which VHost should resolve vhost-man/dns-srv-def-addr=
      See Also:
        Constant Field Values

    - #### DNS_SRV_DEF_ADDR_PROP_VAL

          public static String DNS_SRV_DEF_ADDR_PROP_VAL

      Field description

    - #### DOMAINS_PER_USER_LIMIT_PROP_KEY

          public static final String DOMAINS_PER_USER_LIMIT_PROP_KEY

      Configuration option allowing specify default maximum number that user can register in service vhost-man/domains-per-user-limit=
      See Also:
        Constant Field Values

    - #### DOMAINS_PER_USER_LIMIT_PROP_VAL

          public static final int DOMAINS_PER_USER_LIMIT_PROP_VAL

      Field description
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### VHostJDBCRepository

          public VHostJDBCRepository()

  - ### Method Detail

    - #### destroy

          public void destroy()

      Description copied from interface: `ComponentRepository`
      Method destroys this instance of ComponentRepository releasing resources allocated for this instance of ComponentRepository if possible

    - #### getConfigKey

          public String getConfigKey()

      Description copied from class: `ConfigRepository`
      Method description
      Specified by:
        `getConfigKey` in class `ConfigRepository<VHostItem>`

    - #### getDefaultPropetyItems

          public String[] getDefaultPropetyItems()

      Description copied from class: `ConfigRepository`
      Method description
      Specified by:
        `getDefaultPropetyItems` in class `ConfigRepository<VHostItem>`

    - #### getDefaults

          public void getDefaults(Map<String,Object> defs,
                                  Map<String,Object> params)

      Description copied from interface: `ComponentRepository`
      The method is called to obtain default configuration settings if there are any for this repository implementation The configuration settings are implementation dependent and there are no defaults set by the server. Default settings returned by this method are then saved in the configuration file and presented to the admin for further adjustments.
      Specified by:
        `getDefaults` in interface `ComponentRepository<VHostItem>`
      Overrides:
        `getDefaults` in class `UserRepoRepository<VHostItem>`
      Parameters:
        `defs` - is a `Map` collection where all repository configuration defaults must be put.
        `params` - is a `Map` collection with some preset properties for the server. These settings can be used to adjust repository defaults, for example they can contain database connection URL or initial list of virtual domains.

    - #### getItemInstance

          public VHostItem getItemInstance()

      Description copied from interface: `ComponentRepository`
      Creates a new, uninitialized instance of the repository Item.
      Returns:
        a new, uninitialized instance of the repository Item.

    - #### getItemsListPKey

          public String getItemsListPKey()

      Description copied from class: `UserRepoRepository`
      Method description
      Overrides:
        `getItemsListPKey` in class `UserRepoRepository<VHostItem>`

    - #### getPropertyKey

          public String getPropertyKey()

      Description copied from class: `ConfigRepository`
      Method description
      Specified by:
        `getPropertyKey` in class `ConfigRepository<VHostItem>`

    - #### getRepoUser

          public BareJID getRepoUser()

      Description copied from class: `UserRepoRepository`
      Method description
      Specified by:
        `getRepoUser` in class `UserRepoRepository<VHostItem>`

    - #### initRepository

          public void initRepository(String resource_uri,
                                     Map<String,String> params)
                              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.
      Parameters:
        `resource_uri` - value in most cases representing the database connection string.
        `params` - 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.

    - #### setProperties

          public void setProperties(Map<String,Object> properties)

      Description copied from class: `UserRepoRepository`
      Method description
      Specified by:
        `setProperties` in interface `ComponentRepository<VHostItem>`
      Overrides:
        `setProperties` in class `UserRepoRepository<VHostItem>`
      Parameters:
        `properties` - a `Map` with configuration settings. Content of this `Map` must not be modified. This read-only collection.

    - #### validateItem

          public String validateItem(VHostItem item)

      Description copied from interface: `ComponentRepository`
      Performs Item validation to check whether it meets the repository policy. If validation is successful the method returns `null`, otherwise it returns an error description.
      Specified by:
        `validateItem` in interface `ComponentRepository<VHostItem>`
      Overrides:
        `validateItem` in class `ConfigRepository<VHostItem>`
      Parameters:
        `item` - is an `Item` object to perform validation checking upon.
      Returns:
        `null` on success and an error message otherwise.

    - #### main

          public static void main(String[] args)

      Simple verification of VHost validation
      Parameters:
        `args` -

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