Package tigase.vhosts
Class VHostJDBCRepository
- All Implemented Interfaces:
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.
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_KEYFields inherited from class tigase.db.comp.ConfigRepository
autoReloadInterval, items, itemsHashFields inherited from interface tigase.db.comp.ComponentRepository
COMP_REPO_BIND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddItemNoStore(VHostItem item) The method adds a new or updates existing Item.voiddestroy()Method destroys this instance of ComponentRepository releasing resources allocated for this instance of ComponentRepository if possibleString[]Creates a new, uninitialized instance of the repository Item.voidinitRepository(String resource_uri, Map<String, String> params) Deprecated.voidreload()This method is called to reload items from the database or other permanent storage.voidsetDataSource(DataSource dataSource) Method called to provide class with instance of a data source.voidsetDef_srv_address(String address) voidsetExtensionManager(VHostItemExtensionManager extensionManager) voidsetItemsOld(String[] items_arr) voidsetMainVHostName(String vhost) voidsetVhostDefaultValues(VHostItemDefaults vhostDefaultValues) validateItem(VHostItem item) Performs Item validation to check whether it meets the repository policy.Methods inherited from class tigase.db.comp.UserRepoRepository
setRepo, storeMethods 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface tigase.db.comp.ComponentRepository
addItem, addRepoChangeListener, allItems, contains, getDefaults, getItem, removeItem, removeItemNoStore, removeRepoChangeListener, setAutoloadTimer, setProperties, size, storeMethods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Constructor Details
-
VHostJDBCRepository
public VHostJDBCRepository()
-
-
Method Details
-
destroy
public void destroy()Description copied from interface:ComponentRepositoryMethod destroys this instance of ComponentRepository releasing resources allocated for this instance of ComponentRepository if possible- Specified by:
destroyin interfaceComponentRepository<VHostItem>
-
getConfigKey
- Specified by:
getConfigKeyin classConfigRepository<VHostItem>
-
getDefaultPropetyItems
- Overrides:
getDefaultPropetyItemsin classConfigRepository<VHostItem>
-
getItemInstance
Description copied from interface:ComponentRepositoryCreates a new, uninitialized instance of the repository Item.- Specified by:
getItemInstancein interfaceComponentRepository<VHostItem>- Returns:
- a new, uninitialized instance of the repository Item.
-
getItemsListPKey
- Overrides:
getItemsListPKeyin classUserRepoRepository<VHostItem>
-
getPropertyKey
- Specified by:
getPropertyKeyin classConfigRepository<VHostItem>
-
getRepoUser
- Specified by:
getRepoUserin classUserRepoRepository<VHostItem>
-
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.
-
reload
public void reload()Description copied from interface:ComponentRepositoryThis 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:
reloadin interfaceComponentRepository<VHostItem>- Overrides:
reloadin classUserRepoRepository<VHostItem>
-
addItemNoStore
Description copied from interface:ComponentRepositoryThe 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:
addItemNoStorein interfaceComponentRepository<VHostItem>- Overrides:
addItemNoStorein classConfigRepository<VHostItem>- Parameters:
item- aItemwith all it's configuration parameters.
-
setDef_srv_address
-
validateItem
Description copied from interface:ComponentRepositoryPerforms Item validation to check whether it meets the repository policy. If validation is successful the method returnsnull, otherwise it returns an error description.- Specified by:
validateItemin interfaceComponentRepository<VHostItem>- Overrides:
validateItemin classConfigRepository<VHostItem>- Parameters:
item- is anItemobject to perform validation checking upon.- Returns:
nullon success and an error message otherwise.
-
setDataSource
Description copied from interface:DataSourceAwareMethod called to provide class with instance of a data source.- Specified by:
setDataSourcein interfaceDataSourceAware<DataSource>
-
getMainVHostName
-
setMainVHostName
-
getDefaultVHostItem
- Specified by:
getDefaultVHostItemin interfaceVHostComponentRepository
-
setExtensionManager
-
setItemsOld
- Overrides:
setItemsOldin classConfigRepository<VHostItem>
-
setVhostDefaultValues
-