tigase.vhosts
Class VhostConfigRepository

java.lang.Object
  extended by tigase.vhosts.VhostConfigRepository
All Implemented Interfaces:
VHostRepository
Direct Known Subclasses:
VHostJDBCRepository

public class VhostConfigRepository
extends java.lang.Object
implements VHostRepository

Created: Nov 27, 2008 1:53:58 PM

Version:
$Rev: 1250 $
Author:
Artur Hefczyc

Field Summary
static java.lang.String ANONYMOUS_DOMAINS_PROP_KEY
           
protected  java.util.LinkedHashMap<java.lang.String,VHostItem> vhosts
           
 
Constructor Summary
VhostConfigRepository()
           
 
Method Summary
 void addVHost(VHostItem vhost)
          The method adds a new or updates existing virtual hosts in the repository.
 boolean contains(java.lang.String domain)
          The method checks whether the given domain is stored in the repository.
 void getDefaults(java.util.Map<java.lang.String,java.lang.Object> defs, java.util.Map<java.lang.String,java.lang.Object> params)
          The method is called to obtain defualt 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 getVHost(java.lang.String domain)
          The method returns all domain configuration parameters for a given domain or null if the domain does not exist in the repository.
 void reload()
          This method is called to reload virtual hosts from the database or other permanent storage.
 void removeVHost(java.lang.String vh)
          The method is called to remove given VHost from the memory cache and permanent storage.
 void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
          The method is called to set configuration for this repository implementation.
 int size()
          The method returns number of virtual domains in the repository.
 void store()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANONYMOUS_DOMAINS_PROP_KEY

public static final java.lang.String ANONYMOUS_DOMAINS_PROP_KEY
See Also:
Constant Field Values

vhosts

protected java.util.LinkedHashMap<java.lang.String,VHostItem> vhosts
Constructor Detail

VhostConfigRepository

public VhostConfigRepository()
Method Detail

getDefaults

public void getDefaults(java.util.Map<java.lang.String,java.lang.Object> defs,
                        java.util.Map<java.lang.String,java.lang.Object> params)
Description copied from interface: VHostRepository
The method is called to obtain defualt 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 adjustements.

Specified by:
getDefaults in interface VHostRepository
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.

setProperties

public void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
Description copied from interface: VHostRepository
The method is called to set configuration for this repository implementation. The configuration is repository implementation dependent. There are no default settings for the repository.

Specified by:
setProperties in interface VHostRepository
Parameters:
properties - a Map with configuration settings. Content of this Map must not be modified. This read-only collection.

getVHost

public VHostItem getVHost(java.lang.String domain)
Description copied from interface: VHostRepository
The method returns all domain configuration parameters for a given domain or null if the domain does not exist in the repository. In other words it returns null if given domain is not local.

Specified by:
getVHost in interface VHostRepository
Parameters:
domain - a String with domain name to search for.
Returns:
a VHostItem for a given domain or null if the domain is not in the repository.

contains

public boolean contains(java.lang.String domain)
Description copied from interface: VHostRepository
The method checks whether the given domain is stored in the repository. In other words the method checks whether this is a local domain.

Specified by:
contains in interface VHostRepository
Parameters:
domain - a String with domain name to search for.
Returns:
a boolean value true if domain exist in the repository or false of domain does not exist.

reload

public void reload()
Description copied from interface: VHostRepository
This method is called to reload virtual hosts from the database or other permanent storage. It is possible that virtual domains 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 VHostRepository

store

public void store()

size

public int size()
Description copied from interface: VHostRepository
The method returns number of virtual domains in the repository.

Specified by:
size in interface VHostRepository
Returns:
an int value with number of virtual hosts in the repository.

addVHost

public void addVHost(VHostItem vhost)
Description copied from interface: VHostRepository
The method adds a new or updates existing virtual hosts in the repository. It needs to have all fields set correctly. By the default VHostItem has all fields set to "enabled". After this method call is finished a new added virtual domain must be available as a local domain for the server installation. The method adds the vhosts to memory cache and permamnent storage.

Specified by:
addVHost in interface VHostRepository
Parameters:
vhost - a VHostItem with virtual domain and all it's configuration parameters.

removeVHost

public void removeVHost(java.lang.String vh)
Description copied from interface: VHostRepository
The method is called to remove given VHost from the memory cache and permanent storage. After this method is completed the vhosts should no longer be availble as a local domain.

Specified by:
removeVHost in interface VHostRepository
Parameters:
vh - a String with domain name to remove.


Copyright © 2008 Tigase. All Rights Reserved.