org.osesb.configuration
Class SMTPClientConfiguration

java.lang.Object
  extended by org.osesb.configuration.XMLConfiguration
      extended by org.osesb.configuration.SMTPClientConfiguration

public class SMTPClientConfiguration
extends XMLConfiguration

Parses a SMTP client configuration content model in a XML configuration file and sets configuration Properties for SMTP clients in the org.osesb.connectors.smtp package. Contains convenience methods for accessing SMTP properties.

A SMTPClientConfiguration can be embedded in any XMLConfiguration;

Since:
Version .9
See Also:

Example SMTPClientConfiguration content model:

{@code
      
          mail.myserver.com
          25
          
          0
          
          true
          
          
          
          
          testClient@osesb.org
          testClient
          
          
              jdoeto1@somewhere.org
              jdoeto2@somewhere.org
          
          
              jdoecc1@somewhere.org
              jdoecc2@somewhere.org
          
          
              jdoebcc1@somewhere.org
              jdoebcc2@somewhere.org
          
      
 }

Field Summary
protected  java.util.List bccDestinationList
          List of configured BCC destination addresses.
protected  java.util.List ccDestinationList
          List of configured CC destination addresses.
protected  java.util.List toDestinationList
          List of configured To destination addresses.
 
Fields inherited from class org.osesb.configuration.XMLConfiguration
configFilePath, configurationProperties, constructedFromConfigFile, contentModelElement, ftpClientConfiguration, jaxrpcClientConfiguration, jdbcConfiguration, jmsClientConfiguration, log, rootConfigurationAttributes, smtpClientConfiguration, systemProperties, thisClassName
 
Constructor Summary
SMTPClientConfiguration(org.w3c.dom.Element contentModelElement)
          Creates a new instance of SMTPClientConfiguration given the content model Element.
SMTPClientConfiguration(java.util.Properties configurationProperties)
          Creates a new instance of SMTPClientConfiguration given the configuration Properties.
SMTPClientConfiguration(java.lang.String configFile)
          Creates a new instance of SMTPClientConfiguration given a XML configuration file.
SMTPClientConfiguration(java.lang.String configFile, java.lang.String xpathExpression)
          Creates a new instance of SMTPClientConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.
 
Method Summary
 void addBCCAddress(java.lang.String bccAddress)
          Adds a configured BCC destination address.
 void addCCAddress(java.lang.String ccAddress)
          Adds a configured CC destination address.
 void addToAddress(java.lang.String toAddress)
          Adds a configured To destination address.
 java.lang.String[] getBCCAddresses()
          Return the configured BCC destination addresses.
 java.lang.String[] getCCAddresses()
          Return the configured CC destination addresses.
 java.lang.String getFromAddress()
          Returns the From address.
 java.lang.String getFromName()
          Returns the From name.
 java.lang.String getHostname()
          Returns the SMTP host name.
 java.lang.String getPassword()
          Returns the password for the SMTP host.
 int getPort()
          Returns the SMTP port for the connection.
 int getRetryCount()
          Returns the Retry count for sending messages.
 java.lang.String[] getToAddresses()
          Return the configured To destination addresses.
 java.lang.String getUsername()
          Returns the username for the SMTP host.
protected  void loadConfiguredDestinationAddresses()
          Loads configured To, CC, and BCC destination addresses.
static void main(java.lang.String[] args)
          main() For testing and sandboxing.
 void setFromAddress(java.lang.String fromAddress)
          Sets the From address.
 void setFromName(java.lang.String fromName)
          Sets the From name.
 void setHostname(java.lang.String hostName)
          Sets the SMTP host name.
 void setPassword(java.lang.String password)
          Sets the password for the SMTP host.
 void setPort(int port)
          Sets the SMTP port for the connection.
 void setRetryCount(int retryCount)
          Sets the Retry count for sending messages.
 void setUsername(java.lang.String userName)
          Sets the username for the SMTP host.
 java.lang.String toString()
          Returns the String representation of this XMLConfiguration.
 
Methods inherited from class org.osesb.configuration.XMLConfiguration
checkXMLConfigurationClass, clear, doEncryptionInstructions, getBooleanConfigurationProperty, getBooleanRootConfigurationAttribute, getConfigFilePath, getConfigurationAttribute, getConfigurationAttributes, getConfigurationElement, getConfigurationElements, getConfigurationProperties, getConfigurationProperty, getConfigurationProperty, getContentModelElement, getDebugFlag, getDocument, getEncryptionInstructions, getFTPClientConfiguration, getIntConfigurationProperty, getIntRootConfigurationAttribute, getJAXRPCClientConfiguration, getJDBCConfiguration, getJMSClientConfiguration, getLongConfigurationProperty, getLongRootConfigurationAttribute, getName, getRootConfigurationAttribute, getRootConfigurationAttributes, getSMTPClientConfiguration, getSystemProperties, getSystemProperty, isConfigurationElementEmpty, loadConfiguration, loadExternalConfiguration, loadFTPClientConfiguration, loadJAXRPCClientConfiguration, loadJDBCConfiguration, loadJMSClientConfiguration, loadPropertiesFromContentModel, loadSMTPClientConfiguration, loadSystemProperties, mergeConfigurationProperties, setConfigFilePath, setConfigurationProperty, setDebugFlag, setFTPClientConfiguration, setJAXRPCClientConfiguration, setJDBCConfiguration, setJMSClientConfiguration, setName, setRootConfigurationAttribute, setSMTPClientConfiguration, setSystemProperties, setSystemProperty, writeConfigurationFile, writeConfigurationFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

toDestinationList

protected java.util.List toDestinationList
List of configured To destination addresses.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

See Also:
addToAddress(String toAddress)

ccDestinationList

protected java.util.List ccDestinationList
List of configured CC destination addresses.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

See Also:
addCCAddress(String toAddress)

bccDestinationList

protected java.util.List bccDestinationList
List of configured BCC destination addresses.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

See Also:
addBCCAddress(String toAddress)
Constructor Detail

SMTPClientConfiguration

public SMTPClientConfiguration(java.lang.String configFile)
                        throws java.lang.Exception
Creates a new instance of SMTPClientConfiguration given a XML configuration file. The root element of the XML configuration file is the starting element for the configuration.

Parameters:
configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
Throws:
java.lang.Exception - if there is a problem reading or parsing the configuration file.

SMTPClientConfiguration

public SMTPClientConfiguration(java.lang.String configFile,
                               java.lang.String xpathExpression)
                        throws java.lang.Exception
Creates a new instance of SMTPClientConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.

An empty xpathExpression implies that the root element of the XML configuration file is the starting element for the configuration.

Parameters:
configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
xpathExpression - A XPath expression that evaluates to the element that marks the beginning of the configuration. If following the framework convention for SMTPClientConfiguration(s), xpathExpression should have'smtp-client-configuration' as the last Element in the path.
Throws:
java.lang.Exception - if there is a problem reading or parsing the configuration file.

SMTPClientConfiguration

public SMTPClientConfiguration(org.w3c.dom.Element contentModelElement)
                        throws java.lang.Exception
Creates a new instance of SMTPClientConfiguration given the content model Element.

Parameters:
contentModelElement - The top level Element for the for the configuration.
Throws:
java.lang.Exception - if there is a fatal error transversing the configuration content model enclosed by contentModelElement.

SMTPClientConfiguration

public SMTPClientConfiguration(java.util.Properties configurationProperties)
                        throws java.lang.Exception
Creates a new instance of SMTPClientConfiguration given the configuration Properties.

Parameters:
configurationProperties - Configuration name / value pairs as Properties.
Throws:
java.lang.Exception - if incorrect parameters are passed
Method Detail

loadConfiguredDestinationAddresses

protected final void loadConfiguredDestinationAddresses()
                                                 throws java.lang.Exception
Loads configured To, CC, and BCC destination addresses.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

Throws:
java.lang.Exception - if there is a fatal error transversing the DOM that contains the configuration content model.
See Also:
JAXRPCDynamicClient.invokeService( Object[] serviceParameters, String username, String password), JAXRPCClientAddressingHandler, JAXRPCWSAddressingConfiguration

getHostname

public java.lang.String getHostname()
Returns the SMTP host name.

Returns:
the SMTP host name.

setHostname

public void setHostname(java.lang.String hostName)
Sets the SMTP host name.

Parameters:
hostName - the SMTP host name.

getUsername

public java.lang.String getUsername()
Returns the username for the SMTP host.

Returns:
the username for the SMTP host.

setUsername

public void setUsername(java.lang.String userName)
Sets the username for the SMTP host.

Parameters:
userName - the username for the SMTP host.

getPassword

public java.lang.String getPassword()
Returns the password for the SMTP host.

Returns:
the password for the SMTP host.

setPassword

public void setPassword(java.lang.String password)
Sets the password for the SMTP host.

Parameters:
password - the password for the SMTP host.

getPort

public int getPort()
Returns the SMTP port for the connection.

Returns:
the SMTP host port.

setPort

public void setPort(int port)
Sets the SMTP port for the connection.

Parameters:
port - the SMTP host port.

getRetryCount

public int getRetryCount()
Returns the Retry count for sending messages.

Returns:
retry count for sending messages.

setRetryCount

public void setRetryCount(int retryCount)
Sets the Retry count for sending messages.

Parameters:
retryCount - the retry count for sending messages.

getFromAddress

public java.lang.String getFromAddress()
Returns the From address.

Returns:
the From address.

setFromAddress

public void setFromAddress(java.lang.String fromAddress)
Sets the From address.

Parameters:
fromAddress - the From address.

getFromName

public java.lang.String getFromName()
Returns the From name.

Returns:
the From name.

setFromName

public void setFromName(java.lang.String fromName)
Sets the From name.

Parameters:
fromName - the From name.

addToAddress

public void addToAddress(java.lang.String toAddress)
Adds a configured To destination address.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

Parameters:
toAddress - the SMTP address that will be added to the configured To destination addresses.

getToAddresses

public java.lang.String[] getToAddresses()
Return the configured To destination addresses.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

Returns:
the configured To destination addresses.

addCCAddress

public void addCCAddress(java.lang.String ccAddress)
Adds a configured CC destination address.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

Parameters:
ccAddress - the SMTP address that will be added to the configured CC destination addresses.

getCCAddresses

public java.lang.String[] getCCAddresses()
Return the configured CC destination addresses.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

Returns:
the configured CC destination addresses.

addBCCAddress

public void addBCCAddress(java.lang.String bccAddress)
Adds a configured BCC destination address.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

Parameters:
bccAddress - the SMTP address that will be added to the configured BCC destination addresses.

getBCCAddresses

public java.lang.String[] getBCCAddresses()
Return the configured BCC destination addresses.

A SMTP client does not necessarily need to configure To, CC, and BCC addresses. The ISMTPClient#sendMessage() method includes signatures that support configured and dynamic To, CC, and BCC addresses.

Returns:
the configured BCC destination addresses.

toString

public java.lang.String toString()
Returns the String representation of this XMLConfiguration.

Overrides:
toString in class XMLConfiguration
Returns:
the String representation of this XMLConfiguration.

main

public static void main(java.lang.String[] args)
main() For testing and sandboxing.

Parameters:
args - commandline arguments