org.fax4j.spi.extremefax.ExtremeFaxMailFaxClientSpi Maven / Gradle / Ivy
package org.fax4j.spi.extremefax;
import org.fax4j.spi.email.MailFaxClientSpi;
/**
* This class implements the fax client service provider interface.
* This implementation will invoke the requests by sending emails to a mail server that supports
* conversion between email messages and fax messages.
* The Extreme Fax mail SPI supports persistent connection to enable to reuse the same connection for all fax
* operation invocations or to create a new connection for each fax operation invocation.
* By default the SPI will create a new connection for each operation invocation however the
* org.fax4j.spi.mail.persistent.connection set to true will enable to reuse the connection.
* To set the user/password values of the mail connection the following 2 properties must be defined:
* org.fax4j.spi.mail.user.name and org.fax4j.spi.mail.password
* All properties defined in the fax4j configuration will be passed to the mail connection therefore it is
* possible to define mail specific properties (see java mail for more info) in the fax4j properties.
* This SPI only supports to submit new fax jobs.
* This implementation is not meant to promote the commercial service but to serve
* as a service provider interface for it.
*
* The configuration of the fax4j framework is made up of 3 layers.
* The configuration is based on simple properties.
* Each layer overrides the lower layers by adding/changing the property values.
* The first layer is the internal fax4j.properties file located in the fax4j jar.
* This layer contains the preconfigured values for the fax4j framework and can be changed
* by updating these properties in the higher layers.
* The second layer is the external fax4j.properties file that is located on the classpath.
* This file is optional and provides the ability to override the internal configuration for the
* entire fax4j framework.
* The top most layer is the optional java.util.Properties object provided by the external classes
* when creating a new fax client.
* These properties enable to override the configuration of the lower 2 layers.
*
* SPI Status (Draft, Beta, Stable): Stable
*
* Below table describes the configuration values relevant for this class.
* Configuration:
*
*
* Name
* Description
* Preconfigured Value
* Default Value
* Mandatory
*
*
* org.fax4j.spi.mail.persistent.connection
* True to reuse the same mail connection for all fax activites, false to create a
* new mail connection for each fax activity.
* false
* false
* false
*
*
* org.fax4j.spi.mail.user.name
* The mail account user name.
* none
* none
* false
*
*
* org.fax4j.spi.mail.password
* The mail account password.
* none
* none
* false
*
*
* javax mail properties
* Any of the javax mail properties can be defined in the fax4j properties.
* These properties will be passed to the java mail framework.
* mail.transport.protocol=smtp
* mail.smtp.port=25
* none
* false
*
*
*
* Limitations:
*
* - This SPI is based on the java mail infrastructure, therefore this SPI cannot
* connect to mail servers through a proxy server.
*
- Currently this SPI only supports submitting new fax jobs.
*
*
* Dependencies:
*
* - Required jar files: mail-1.4.jar, activation-1.1.jar
*
*
*
*
* @author Sagie Gur-Ari
* @version 1.02
* @since 0.21c
*/
public class ExtremeFaxMailFaxClientSpi extends MailFaxClientSpi
{
/**
* This class holds the SPI configuration constants.
*
* @author Sagie Gur-Ari
* @version 1.02
* @since 0.21c
*/
public enum FaxClientSpiConfigurationConstants
{
/**The mail address template value*/
MAIL_ADDRESS_TEMPLATE_VALUE("{0}@rcfax.com"),
/**The mail subject template value*/
MAIL_SUBJECT_TEMPLATE_VALUE("fax");
/**The string value*/
private String value;
/**
* This is the class constructor.
*
* @param value
* The string value
*/
private FaxClientSpiConfigurationConstants(String value)
{
this.value=value;
}
/**
* This function returns the string value.
*
* @return The string value
*/
@Override
public final String toString()
{
return this.value;
}
}
/**
* This is the default constructor.
*/
public ExtremeFaxMailFaxClientSpi()
{
super();
}
/**
* This function initializes the mail templates.
*/
@Override
protected void initializeMailTemplates()
{
//mail address template
this.mailAddressTemplate=FaxClientSpiConfigurationConstants.MAIL_ADDRESS_TEMPLATE_VALUE.toString();
//mail subject template
this.mailSubjectTemplate=FaxClientSpiConfigurationConstants.MAIL_SUBJECT_TEMPLATE_VALUE.toString();
}
}