org.mobicents.protocols.smpp.util
Interface APIConfig

All Known Implementing Classes:
AbstractAPIConfig, PropertiesAPIConfig

public interface APIConfig

Interface for internal API configuration implementations. Implementation of this class hold the configuration for the smppapi. The API configuration is loaded by the APIConfigFactory class.

Implementations must supply a no-argument constructor so that APIConfigFactory can instantiate 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.default_version String Set the default version that will be used for new Connections
smppapi.default_alphabet String The class name of the default alphabet encoding to use. Must be an implementation of org.mobicents.smpp.util.AlphabetEncoding
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, in bytes, used on the incoming stream connection from the SMSC.
smppapi.net.buffersize_out Integer Sets the size of the buffer, in bytes, used on the outgoing stream connection to the SMSC.
smppapi.net.autoflush Boolean By default, the SmscLink class 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 EventDispatcher, which 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 TaskExecutorEventDispatcher class.
smppapi.message.segment_size Integer The default segment size to use for concatenated short messages using optional parameters.

Version:
$Id: APIConfig.java 477 2009-07-12 18:00:20Z orank $
See Also:
APIConfigFactory, PropertiesAPIConfig

Field Summary
static String BIND_TIMEOUT
           
static String DEFAULT_ALPHABET
           
static String DEFAULT_VERSION
           
static String EVENT_DISPATCHER_CLASS
           
static String EVENT_THREAD_POOL_SIZE
           
static String LAX_VERSIONS
           
static String LINK_AUTO_FLUSH
           
static String LINK_AUTOCLOSE_SNOOP
           
static String LINK_BUFFERSIZE_IN
           
static String LINK_BUFFERSIZE_OUT
           
static String LINK_TIMEOUT
           
static String SEGMENT_SIZE
           
static String TOO_MANY_IO_EXCEPTIONS
           
 
Method Summary
 boolean getBoolean(String property)
          Get a property as a boolean value.
 boolean getBoolean(String property, boolean defaultValue)
          Get a property as a boolean value.
<T> T
getClassInstance(String property, Class<T> type)
          Instantiate a new instance of a class whose class name is specified in property.
<T> T
getClassInstance(String property, Class<T> type, T defaultValue)
          Instantiate a new instance of a class whose class name is specified in property, returning a default value if the property is not set.
 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.
 void initialise()
          Initialise this properties instance.
 boolean isSet(String property)
          Determine if a property is set in the configuration.
 boolean reloadAPIConfig()
          Cause the API properties to be reloaded.
 

Field Detail

DEFAULT_VERSION

static final String DEFAULT_VERSION
See Also:
APIConfig, Constant Field Values

DEFAULT_ALPHABET

static final String DEFAULT_ALPHABET
See Also:
APIConfig, Constant Field Values

LAX_VERSIONS

static final String LAX_VERSIONS
See Also:
APIConfig, Constant Field Values

LINK_BUFFERSIZE_IN

static final String LINK_BUFFERSIZE_IN
See Also:
APIConfig, Constant Field Values

LINK_BUFFERSIZE_OUT

static final String LINK_BUFFERSIZE_OUT
See Also:
APIConfig, Constant Field Values

LINK_AUTO_FLUSH

static final String LINK_AUTO_FLUSH
See Also:
APIConfig, Constant Field Values

LINK_AUTOCLOSE_SNOOP

static final String LINK_AUTOCLOSE_SNOOP
See Also:
APIConfig, Constant Field Values

LINK_TIMEOUT

static final String LINK_TIMEOUT
See Also:
APIConfig, Constant Field Values

TOO_MANY_IO_EXCEPTIONS

static final String TOO_MANY_IO_EXCEPTIONS
See Also:
APIConfig, Constant Field Values

EVENT_DISPATCHER_CLASS

static final String EVENT_DISPATCHER_CLASS
See Also:
APIConfig, Constant Field Values

EVENT_THREAD_POOL_SIZE

static final String EVENT_THREAD_POOL_SIZE
See Also:
APIConfig, Constant Field Values

BIND_TIMEOUT

static final String BIND_TIMEOUT
See Also:
APIConfig, Constant Field Values

SEGMENT_SIZE

static final String SEGMENT_SIZE
See Also:
APIConfig, Constant Field Values
Method Detail

initialise

void initialise()
Initialise this properties instance. The APIConfigFactory will call this method once after it has instantiated the configuration implementation so that any implementation-specific actions can be carried out.


reloadAPIConfig

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.

getProperty

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

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

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

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

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

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.
Returns:
The value of property.
Throws:
PropertyNotFoundException - if property is not found in the configuration.
InvalidConfigurationException - if the value is not a valid short.

getInt

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.
Returns:
The value of property.
Throws:
InvalidConfigurationException - if the value is not a valid integer.

getInt

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.
Returns:
The value of property.
Throws:
PropertyNotFoundException - if property is not found in the configuration.
InvalidConfigurationException - if the value is not a valid integer.

getLong

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 retrieve.
defaultValue - the value to return if the property does not exist.
Returns:
The value of property.
Throws:
InvalidConfigurationException - if the value is not a valid long.

getLong

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.
Returns:
The value of property.
Throws:
PropertyNotFoundException - if property is not found in the configuration.
InvalidConfigurationException - if the value is not a valid long.

getBoolean

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.
Returns:
The value of property.
Throws:
InvalidConfigurationException - if the property has a value that cannot be parsed or interpreted as boolean.

getBoolean

boolean getBoolean(String property)
                   throws InvalidConfigurationException,
                          PropertyNotFoundException
Get a property as a boolean value. See the description of getBoolean(String, boolean) for details of how a boolean value can be specified.

Parameters:
property - The name of the property to retrieve.
Returns:
The value of property.
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.

getClassInstance

<T> T getClassInstance(String property,
                       Class<T> type)
Instantiate a new instance of a class whose class name is specified in property.

Type Parameters:
T - The expected type of the instantiated class.
Parameters:
property - The name of a property whose value is the fully qualified name of a class to instantiate.
type - The expected type of the instantiated class. This may specify a super-class or interface of the actually instantiated class.
Returns:
The new object instance.
Throws:
PropertyNotFoundException - If property is not found in the configuration.

getClassInstance

<T> T getClassInstance(String property,
                       Class<T> type,
                       T defaultValue)
Instantiate a new instance of a class whose class name is specified in property, returning a default value if the property is not set.

Type Parameters:
T - The expected type of the instantiated class.
Parameters:
property - The name of a property whose value is the fully qualified name of a class to instantiate.
type - The expected type of the instantiated class. This may specify a super-class or interface of the actually instantiated class.
Returns:
The new object instance, or defaultValue if property is not set.

isSet

boolean isSet(String property)
Determine if a property is set in the configuration.

Parameters:
property - The name of the property to test.
Returns:
true if the property is set, false if not.


Copyright © 2011 Mobicents. All Rights Reserved.