Package tigase.vhosts

## Class VHostJDBCRepository

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

- All Implemented Interfaces:
    `java.lang.Iterable<VHostItem>`, `ComponentRepository<VHostItem>`, `ComponentRepositoryDataSourceAware<VHostItem,​DataSource>`, `DataSourceAware<DataSource>`, `Repository`, `Initializable`, `UnregisterAware`, `VHostComponentRepository`, `VHostComponentRepositoryDataSourceAware<DataSource>`

      @ConfigAliases(@ConfigAlias(field="items",alias="virtual-hosts"))
      public class VHostJDBCRepository
      extends UserRepoRepository<VHostItem>
      implements VHostComponentRepositoryDataSourceAware<DataSource>

  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, Repository.SchemaId`

  - ### Field Summary

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

      `repo, REPO_CLASS_PROP_KEY, REPO_URI_PROP_KEY`

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

      `autoReloadInterval, items, itemsHash`

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

      `COMP_REPO_BIND`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `VHostJDBCRepository()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addItemNoStore​(VHostItem item)` | The method adds a new or updates existing Item.
    `void` | `destroy()` | Method destroys this instance of ComponentRepository releasing resources allocated for this instance of ComponentRepository if possible
    `java.lang.String` | `getConfigKey()` |
    `java.lang.String[]` | `getDefaultPropetyItems()` |
    `VHostItem` | `getDefaultVHostItem()` |
    `VHostItem` | `getItemInstance()` | Creates a new, uninitialized instance of the repository Item.
    `java.lang.String` | `getItemsListPKey()` |
    `java.lang.String` | `getMainVHostName()` |
    `java.lang.String` | `getPropertyKey()` |
    `BareJID` | `getRepoUser()` |
    `void` | `initRepository​(java.lang.String resource_uri, java.util.Map<java.lang.String,​java.lang.String> params)` | Deprecated.
    `void` | `reload()` | This method is called to reload items from the database or other permanent storage.
    `void` | `setDataSource​(DataSource dataSource)` | Method called to provide class with instance of a data source.
    `void` | `setDef_srv_address​(java.lang.String address)` |
    `void` | `setExtensionManager​(VHostItemExtensionManager extensionManager)` |
    `void` | `setItemsOld​(java.lang.String[] items_arr)` |
    `void` | `setMainVHostName​(java.lang.String vhost)` |
    `void` | `setVhostDefaultValues​(VHostItemDefaults vhostDefaultValues)` |
    `java.lang.String` | `validateItem​(VHostItem item)` | Performs Item validation to check whether it meets the repository policy.

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

      `setRepo, store`

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

      `addItem, addRepoChangeListener, allItems, beforeUnregister, contains, getDefaultItems, getDefaults, getItem, getItemsOld, initialize, initItemsMap, isInitialized, itemChanged, iterator, removeItem, removeItemNoStore, removeRepoChangeListener, setAutoloadTimer, setAutoReloadInterval, setProperties, size, toString`

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

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

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

      `addItem, addRepoChangeListener, allItems, contains, getDefaults, getItem, removeItem, removeItemNoStore, removeRepoChangeListener, setAutoloadTimer, setProperties, size, store`

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

      `forEach, iterator, spliterator`

- - ### 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
      Specified by:
        `destroy` in interface `ComponentRepository<VHostItem>`

    - #### getConfigKey

          public java.lang.String getConfigKey()

      Specified by:
        `getConfigKey` in class `ConfigRepository<VHostItem>`

    - #### getDefaultPropetyItems

          public java.lang.String[] getDefaultPropetyItems()

      Overrides:
        `getDefaultPropetyItems` in class `ConfigRepository<VHostItem>`

    - #### getItemInstance

          public VHostItem getItemInstance()

      Description copied from interface: `ComponentRepository`
      Creates a new, uninitialized instance of the repository Item.
      Specified by:
        `getItemInstance` in interface `ComponentRepository<VHostItem>`
      Returns:
        a new, uninitialized instance of the repository Item.

    - #### getItemsListPKey

          public java.lang.String getItemsListPKey()

      Overrides:
        `getItemsListPKey` in class `UserRepoRepository<VHostItem>`

    - #### getPropertyKey

          public java.lang.String getPropertyKey()

      Specified by:
        `getPropertyKey` in class `ConfigRepository<VHostItem>`

    - #### getRepoUser

          public BareJID getRepoUser()

      Specified by:
        `getRepoUser` in class `UserRepoRepository<VHostItem>`

    - #### 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 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:
        `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.

    - #### reload

          public void reload()

      Description copied from interface: `ComponentRepository`
      This method is called to reload items from the database or other permanent storage. It is possible that items list is modified externally by third-party system. When all modifications are done this method is called to refresh the class cache. Whether the implementation load whole list or just last modifications is implementation dependent.
      Specified by:
        `reload` in interface `ComponentRepository<VHostItem>`
      Overrides:
        `reload` in class `UserRepoRepository<VHostItem>`

    - #### addItemNoStore

          public void addItemNoStore​(VHostItem item)

      Description copied from interface: `ComponentRepository`
      The method adds a new or updates existing Item. It needs to have all fields set correctly. After this method call is finished a new added item must be available in the component repository. The method adds the item to memory cache but not to a permanent storage.
      Specified by:
        `addItemNoStore` in interface `ComponentRepository<VHostItem>`
      Overrides:
        `addItemNoStore` in class `ConfigRepository<VHostItem>`
      Parameters:
        `item` - a `Item` with all it's configuration parameters.

    - #### setDef_srv_address

          public void setDef_srv_address​(java.lang.String address)

    - #### validateItem

          public java.lang.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.

    - #### 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 interface `DataSourceAware<DataSource>`

    - #### getMainVHostName

          public java.lang.String getMainVHostName()

    - #### setMainVHostName

          public void setMainVHostName​(java.lang.String vhost)

    - #### getDefaultVHostItem

          public VHostItem getDefaultVHostItem()

      Specified by:
        `getDefaultVHostItem` in interface `VHostComponentRepository`

    - #### setExtensionManager

          public void setExtensionManager​(VHostItemExtensionManager extensionManager)

    - #### setItemsOld

          public void setItemsOld​(java.lang.String[] items_arr)

      Overrides:
        `setItemsOld` in class `ConfigRepository<VHostItem>`

    - #### setVhostDefaultValues

          public void setVhostDefaultValues​(VHostItemDefaults vhostDefaultValues)