org.mobicents.protocols.smpp.util
Class APIConfigFactory

java.lang.Object
  extended by org.mobicents.protocols.smpp.util.APIConfigFactory

public final class APIConfigFactory
extends Object

Factory class for obtaining the API configuration. Alternative API configurations can be specified by setting the org.mobicents.smpp.configClass system property to the fully qualified class name of a class that implements the APIConfig interface. The default is PropertiesAPIConfig.

Normally, the getConfig() method will cache the loaded configuration object on first call and return the cached config on subsequent calls. If you want to override this behaviour and never cache the loaded configuration object, set the org.mobicents.smpp.cacheConfig system property to false.

For example, to run your application with a configuration implementation called app.MyAPIConfig and with singleton caching turned off, execute:
java -Dorg.mobicents.smpp.configClass=app.MyAPIConfig -Dorg.mobicents.smpp.cacheConfig=false app.MainClass

Version:
$Id: APIConfigFactory.java 452 2009-01-15 16:56:36Z orank $

Field Summary
static String CACHE_CONFIG_PROP
          The system property specifying the concrete implementation of APIConfig to read configuration properties from.
static String CONFIG_CLASS_PROP
          The system property to set to control whether a loaded configuration instance is cached as a singleton or not.
 
Method Summary
static APIConfig getConfig()
          Get the API configuration.
static APIConfig loadConfig()
          Load and initialise an APIConfig instance.
static void reset()
          Reset this APIConfigFactory.
static void setCachedConfig(APIConfig apiConfig)
          Set the cached APIConfig instance that will be returned from calls to getConfig().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_CLASS_PROP

public static final String CONFIG_CLASS_PROP
The system property to set to control whether a loaded configuration instance is cached as a singleton or not.

See Also:
Constant Field Values

CACHE_CONFIG_PROP

public static final String CACHE_CONFIG_PROP
The system property specifying the concrete implementation of APIConfig to read configuration properties from.

See Also:
Constant Field Values
Method Detail

getConfig

public static final APIConfig getConfig()
Get the API configuration. Returns a cached APIConfig instance if the configuration has previously been loaded and caching is enabled. If no configuration object has been cached, return the result of calling loadConfig() (and cache that result if caching is enabled).

The system property to enable and disable caching is read at every call to this method, so the cache strategy can be affected by Java code modifying this value.

Returns:
The API configuration implementation.
Throws:
InvalidConfigurationException - for the same reasons that loadConfig throws this exception.

loadConfig

public static final APIConfig loadConfig()
Load and initialise an APIConfig instance. The type of implementation to instantiate is read from the system property as described in the class description.

Returns:
An initialised APIConfig instance.
Throws:
InvalidConfigurationException - If the configuration class cannot be found, it does not implement APIConfig or its constructor is not visible or throws an exception.

setCachedConfig

public static final void setCachedConfig(APIConfig apiConfig)
Set the cached APIConfig instance that will be returned from calls to getConfig(). This method allows applications to set their own APIConfig implementation, bypassing the loadConfig() logic.

Parameters:
apiConfig - The APIConfig instance to cache and return from subsequent calls to getConfig().

reset

public static final void reset()
Reset this APIConfigFactory. This clears the cached configuration object so that the next call to getConfig() will reload the API configuration.



Copyright © 2011 Mobicents. All Rights Reserved.