ie.omk.smpp.util
Class APIConfig

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Object,Object>
          extended by java.util.Properties
              extended by ie.omk.smpp.util.APIConfig
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public final class APIConfig
extends Properties

Internal API configuration. This class holds the configuration for the smppapi. On initialisation, it searches for a file named "smppapi.properties". This file needs to be locatable in the classpath in one of the following locations: /, /ie, /ie/omk, /ie/omk/smpp or the default classloader for this class must be able to find it.

Most applications can probably accept the default settings of the API. If, however, you're trying to eke maximum performance out of your application, tweaking these settings may help.

Supported API properties are:

Property name Type Description
smppapi.lax_versions Boolean Enable or disable interpreting interface_version values of 0x00 thru 0x32 (inclusive) as SMPP version 3.3. The specification is not entirely clear in its statement on whether this is allowed or not.
smppapi.net.buffersize_in Integer Sets the size of the buffer used on the incoming stream connection from the SMSC. A plain value specified the number of bytes. A suffix of 'k' after the number will be interpreted as kilobytes and a suffix of 'm' will be interpreted as megabytes. For example, 4k will allocate a buffer size of 4096 bytes.
smppapi.net.buffersize_out Integer Sets the size of the buffer used on the outgoing stream connection to the SMSC. A plain value specified the number of bytes. A suffix of 'k' after the number will be interpreted as kilobytes and a suffix of 'm' will be interpreted as megabytes. For example, 4k will allocate a buffer size of 4096 bytes.
smppapi.net.autoflush Boolean By default, the SmscLinkclass automatically flushes the output stream after every packet written to the output stream. In high-load environments, it may be better to turn this off and manually flush the output stream only when required (after a short period of inactivity, for example).
smppapi.net.autoclose_snoop Boolean If snoop streams are set on the SMSC link object and this value is true (the default), the snoop streams will be closed when the link is closed. If false, the snoop streams will be flushed and left open when the link is closed.
smppapi.net.link_timeout Long Sets the timeout in milliseconds for network links. This value affects how long network reads should block for but its exact interpretation is link-implementation specific. For TcpLink, this value represents the SO_TIMEOUT setting on the TCP/IP socket.
smppapi.connection.bind_timeout Long The length of time, in milliseconds, to wait for a bind response packet after sending a bind request. If a packet is not received within this time period, the network connection is closed. A negative value or zero means wait indefinitely.
smppapi.connection.rcv_daemon.ioex_count Integer The number of I/O exceptions the receiver daemon will accept occurring before exiting.
smppapi.event.dispatcher String The name of a class which implements the EventDispatcherwhich will be used as the default event dispatcher for Connection objects.
smppapi.event.threaded_dispatcher.pool_size Integer The size of the thread pool used by the ThreadedEventDispatcherclass.
smppapi.event.threaded_dispatcher.queue_size Integer The size of the event FIFO queue used in the ie.omk.smpp.event.ThreadedEventDispatcher class.
smppapi.tlv.mblox_hack Boolean True to enable the MBlox hack for TLVs that have the "String" type. MBlox does not encode the nul-byte terminator for C-Octet Strings as per the specification. Enabling this option causes the StringEncoder class to skip encoding the nul-terminator on write and to assume there is no nul-terminator on read.

See Also:
Serialized Form

Field Summary
static String BIND_TIMEOUT
          See class description for documentation on the properties.
static String EVENT_DISPATCHER_CLASS
          See class description for documentation on the properties.
static String EVENT_THREAD_FIFO_QUEUE_SIZE
          See class description for documentation on the properties.
static String EVENT_THREAD_POOL_SIZE
          See class description for documentation on the properties.
static String LAX_VERSIONS
          See class description for documentation on the properties.
static String LINK_AUTO_FLUSH
          See class description for documentation on the properties.
static String LINK_AUTOCLOSE_SNOOP
          See class description for documentation on the properties.
static String LINK_BUFFERSIZE_IN
          See class description for documentation on the properties.
static String LINK_BUFFERSIZE_OUT
          See class description for documentation on the properties.
static String LINK_TIMEOUT
          See class description for documentation on the properties.
static String MBLOX_HACK
          See class description for documentation on the properties.
static String TCP_SOCKET_TIMEOUT
          Deprecated. use LINK_TIMEOUT
static String TOO_MANY_IO_EXCEPTIONS
          See class description for documentation on the properties.
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
APIConfig()
          Construct a new APIConfig object which reads properties from the default properties resource.
APIConfig(URL propertiesURL)
          Construct a new APIConfig object which reads properties from the specified URL.
 
Method Summary
static void configure(URL properties)
          Set the URL which APIConfig reads its properties from and load them.
 boolean getBoolean(String property)
          Get a property as a boolean value.
 boolean getBoolean(String property, boolean defaultValue)
          Get a property as a boolean value.
static APIConfig getInstance()
          Get the APIConfig instance.
 int getInt(String property)
          Get the value for a property, parsed as a Java int.
 int getInt(String property, int defaultValue)
          Get the value for a property, parsed as a Java int.
 long getLong(String property)
          Get the value for a property, parsed as a Java long.
 long getLong(String property, long defaultValue)
          Get the value for a property, parsed as a Java long.
 String getProperty(String property)
          Get the value for a property.
 String getProperty(String property, String defaultValue)
          Get the value for a property or return a default value if it is not set.
 short getShort(String property)
          Get the value for a property, parsed as a Java short.
 short getShort(String property, short defaultValue)
          Get the value of a property, parsed as a short.
 boolean reloadAPIConfig()
          Cause the API properties to be reloaded.
 
Methods inherited from class java.util.Properties
list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TCP_SOCKET_TIMEOUT

public static final String TCP_SOCKET_TIMEOUT
Deprecated. use LINK_TIMEOUT
See class description for documentation on the properties.

See Also:
Constant Field Values

LAX_VERSIONS

public static final String LAX_VERSIONS
See class description for documentation on the properties.

See Also:
Constant Field Values

LINK_BUFFERSIZE_IN

public static final String LINK_BUFFERSIZE_IN
See class description for documentation on the properties.

See Also:
Constant Field Values

LINK_BUFFERSIZE_OUT

public static final String LINK_BUFFERSIZE_OUT
See class description for documentation on the properties.

See Also:
Constant Field Values

LINK_AUTO_FLUSH

public static final String LINK_AUTO_FLUSH
See class description for documentation on the properties.

See Also:
Constant Field Values

LINK_AUTOCLOSE_SNOOP

public static final String LINK_AUTOCLOSE_SNOOP
See class description for documentation on the properties.

See Also:
Constant Field Values

LINK_TIMEOUT

public static final String LINK_TIMEOUT
See class description for documentation on the properties.

See Also:
Constant Field Values

TOO_MANY_IO_EXCEPTIONS

public static final String TOO_MANY_IO_EXCEPTIONS
See class description for documentation on the properties.

See Also:
Constant Field Values

EVENT_DISPATCHER_CLASS

public static final String EVENT_DISPATCHER_CLASS
See class description for documentation on the properties.

See Also:
Constant Field Values

EVENT_THREAD_POOL_SIZE

public static final String EVENT_THREAD_POOL_SIZE
See class description for documentation on the properties.

See Also:
Constant Field Values

EVENT_THREAD_FIFO_QUEUE_SIZE

public static final String EVENT_THREAD_FIFO_QUEUE_SIZE
See class description for documentation on the properties.

See Also:
Constant Field Values

BIND_TIMEOUT

public static final String BIND_TIMEOUT
See class description for documentation on the properties.

See Also:
Constant Field Values

MBLOX_HACK

public static final String MBLOX_HACK
See class description for documentation on the properties.

See Also:
Constant Field Values
Constructor Detail

APIConfig

public APIConfig()
Construct a new APIConfig object which reads properties from the default properties resource.


APIConfig

public APIConfig(URL propertiesURL)
Construct a new APIConfig object which reads properties from the specified URL.

Parameters:
propertiesURL - The URL to read properties from.
Method Detail

reloadAPIConfig

public boolean reloadAPIConfig()
Cause the API properties to be reloaded. The properties will be re-read from the same location as they were initially loaded from. If the resource has disappeared or is no longer accessible, the properties will not be loaded and false will be returned to the caller.

Returns:
true if the properties were successfully reloaded, false otherwise.

getInstance

public static APIConfig getInstance()
Get the APIConfig instance. If the APIConfig instance has not yet been initialised then this method will cause the configuration to be read from the default properties resource. The default resource will be searched for at the following locations in the classpath: /smppapi.properties /ie/smppapi.properties /ie/omk/smppapi.properties /ie/omk/smpp/smppapi.properties smppapi.properties

Returns:
An initialised instance of APIConfig.

configure

public static void configure(URL properties)
Set the URL which APIConfig reads its properties from and load them.

Parameters:
properties -

getProperty

public String getProperty(String property)
                   throws PropertyNotFoundException
Get the value for a property.

Overrides:
getProperty in class Properties
Parameters:
property - the name of the property to retrieve.
Returns:
The value for property.
Throws:
PropertyNotFoundException - if property is not found in the configuration.

getProperty

public String getProperty(String property,
                          String defaultValue)
Get the value for a property or return a default value if it is not set.

Overrides:
getProperty in class Properties
Parameters:
property - The name of the property to retrieve.
defaultValue - The value to return if property is not set.
Returns:
The value for property.

getShort

public short getShort(String property,
                      short defaultValue)
               throws InvalidConfigurationException
Get the value of a property, parsed as a short. If the property is not set, the default value is returned.

Parameters:
property - The name of the property to retrieve the value for.
defaultValue - The default value to return if the property is not set.
Returns:
The value for property.
Throws:
InvalidConfigurationException - If the value cannot be parsed as a short.

getShort

public short getShort(String property)
               throws InvalidConfigurationException,
                      PropertyNotFoundException
Get the value for a property, parsed as a Java short.

Parameters:
property - the name of the property to retrive.
Throws:
PropertyNotFoundException - if property is not found in the configuration.
InvalidConfigurationException - if the value is not a valid short.

getInt

public int getInt(String property,
                  int defaultValue)
           throws InvalidConfigurationException
Get the value for a property, parsed as a Java int. If the property is not found, the default value is returned.

Parameters:
property - the name of the property to retrive.
defaultValue - the value to return if the property does not exist.
Throws:
InvalidConfigurationException - if the value is not a valid integer.

getInt

public int getInt(String property)
           throws InvalidConfigurationException,
                  PropertyNotFoundException
Get the value for a property, parsed as a Java int.

Parameters:
property - the name of the property to retrive.
Throws:
PropertyNotFoundException - if property is not found in the configuration.
InvalidConfigurationException - if the value is not a valid integer.

getLong

public long getLong(String property,
                    long defaultValue)
             throws InvalidConfigurationException
Get the value for a property, parsed as a Java long. If the property is not found, the default value is returned.

Parameters:
property - the name of the property to retrive.
defaultValue - the value to return if the property does not exist.
Throws:
InvalidConfigurationException - if the value is not a valid long.

getLong

public long getLong(String property)
             throws InvalidConfigurationException,
                    PropertyNotFoundException
Get the value for a property, parsed as a Java long.

Parameters:
property - the name of the property to retrive.
Throws:
PropertyNotFoundException - if property is not found in the configuration.
InvalidConfigurationException - if the value is not a valid long.

getBoolean

public boolean getBoolean(String property,
                          boolean defaultValue)
                   throws InvalidConfigurationException
Get a property as a boolean value. Any of 'on', 'yes' or 'true' (irrelevant of case) will evaluate to true. Any of 'off', 'no' or 'false' will evaluate to false. Boolean parameters may also be specified as a number, where zero will equate to false while non-zero will equate to true. All other words will result in an InvalidConfigurationException being thrown.

Parameters:
property - the name of the property to look up.
defaultValue - the value to return if the property does not exist.
Throws:
InvalidConfigurationException - if the property has a value that cannot be parsed or interpreted as boolean.

getBoolean

public boolean getBoolean(String property)
                   throws InvalidConfigurationException,
                          PropertyNotFoundException
Get a property as a boolean value. Any of 'on', 'yes' or 'true' (irrelevant of case) will evaluate to true. Any of 'off', 'no' or 'false' will evaluate to false. Boolean parameters may also be specified as a number, where zero will equate to false while non-zero will equate to true. All other words will result in an exception being thrown.

Throws:
PropertyNotFoundException - if property is not found in the configuration.
InvalidConfigurationException - if the property has a value that cannot be parsed or interpreted as boolean.


Copyright © 2011 smppapi at Sourceforge. All Rights Reserved.