Sun Adapter for e-Mail API

com.stc.connector.emailadapter.appconn
Class EmailApplicationConnection

java.lang.Object
  extended by com.stc.connector.emailadapter.appconn.EmailApplicationConnection
All Implemented Interfaces:
com.stc.connector.appconn.common.ApplicationConnection, com.stc.connector.framework.client.AssociateableHandle

public class EmailApplicationConnection
extends java.lang.Object
implements com.stc.connector.appconn.common.ApplicationConnection, com.stc.connector.framework.client.AssociateableHandle

This class implements the ApplicationConnection interface for the Email application connection.

Version:
$Version$
Author:
$Author: chuang $

Constructor Summary
EmailApplicationConnection(com.stc.connector.framework.eway.ManagedConnectionCallback mc, com.stc.connector.framework.util.ConfigurationHelper aConfiguration)
          Creates a new instance of EmailApplicationConnection.
 
Method Summary
 void close()
          Closes the application connection handle.
 java.lang.Object createApplication(java.lang.String appName)
          Creates an Application from the Application Connection.
 com.stc.connector.appconn.common.OutputHandler createOutputHandler()
          Creates an OutputHandler for "sending" data to the EIS.
 boolean hasMessage(EmailConfiguration configuration)
          Determines whether there are message(s) to be received.
 void invalidateConnection()
          This is called by the ManagedConnection to invalidate the connection handle.
protected  boolean isClosed()
          Check whether the Connection instance was already closed (if close was previously called).
 EmailConfiguration newConfiguration()
          Return a new EmailConfiguration instance populated with the default configuration values.
 void reassociateConnection(com.stc.connector.framework.eway.ManagedConnectionCallback mc)
          This is called by the ManagedConnection to associate the connection handle to the ManagedConnection.
 boolean receiveMessage(EmailConfiguration configuration, EmailMessage emailMsg)
          Receive the next available message.
 boolean sendMessage(EmailConfiguration configuration, EmailMessage emailMsg)
          Send the message specified in the end user properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmailApplicationConnection

public EmailApplicationConnection(com.stc.connector.framework.eway.ManagedConnectionCallback mc,
                                  com.stc.connector.framework.util.ConfigurationHelper aConfiguration)
Creates a new instance of EmailApplicationConnection.

Parameters:
mc - The ManagedConnection which created this connection.
Method Detail

close

public void close()
           throws com.stc.connector.appconn.common.ApplicationConnectionException
Closes the application connection handle. Once the close method is called, using the application created from the application connection must be forbidden and must result in an ApplicationConnectionException. The association between an application connection and the application is implementation specific.

Specified by:
close in interface com.stc.connector.appconn.common.ApplicationConnection
Throws:
com.stc.connector.appconn.common.ApplicationConnectionException - upon error.

isClosed

protected boolean isClosed()
Check whether the Connection instance was already closed (if close was previously called).

Returns:
true if already closed or the connection was already invalidated, false otherwise.

createApplication

public java.lang.Object createApplication(java.lang.String appName)
                                   throws com.stc.connector.appconn.common.ApplicationException
Creates an Application from the Application Connection. The application is an API which can be used to interact with the underlying EIS. The application API must be invalidated once the close method is called on the Application Connection. If null is passed for the application name, then the default application will be created. Otherwise, the application name will be used to create the appropriate connection.

Specified by:
createApplication in interface com.stc.connector.appconn.common.ApplicationConnection
Parameters:
appName - The name of the application to create.
Returns:
A java.lang.Object representing the EIS specific application component to interact with the EIS.
Throws:
com.stc.connector.appconn.common.ApplicationException - upon error.

createOutputHandler

public com.stc.connector.appconn.common.OutputHandler createOutputHandler()
                                                                   throws com.stc.connector.appconn.common.ApplicationException
Creates an OutputHandler for "sending" data to the EIS. If the eWay does not support an OutputHandler, then it should return null for its implementation of this method.

Specified by:
createOutputHandler in interface com.stc.connector.appconn.common.ApplicationConnection
Returns:
The eWay specific OutputHandler for handling "sending" data to the external system or null if the eWay does not have an OutputHandler.
Throws:
com.stc.connector.appconn.common.ApplicationException - upon error.

invalidateConnection

public void invalidateConnection()
                          throws javax.resource.ResourceException
This is called by the ManagedConnection to invalidate the connection handle.

Specified by:
invalidateConnection in interface com.stc.connector.framework.client.AssociateableHandle
Throws:
javax.resource.ResourceException - upon error.

reassociateConnection

public void reassociateConnection(com.stc.connector.framework.eway.ManagedConnectionCallback mc)
                           throws javax.resource.ResourceException
This is called by the ManagedConnection to associate the connection handle to the ManagedConnection. The implementation should disassociate the associated ManagedConnection and associate itself to the ManagedConnection passed in as the argument.

Specified by:
reassociateConnection in interface com.stc.connector.framework.client.AssociateableHandle
Parameters:
mc - The ManagedConnection instance with which the connection handle will associate.
Throws:
javax.resource.ResourceException - upon error.

newConfiguration

public EmailConfiguration newConfiguration()
                                    throws EmailApplicationException
Return a new EmailConfiguration instance populated with the default configuration values.

Returns:
An instance of EmailConfiguration populated with the default configuration values.
Throws:
EmailApplicationException - upon error.

sendMessage

public boolean sendMessage(EmailConfiguration configuration,
                           EmailMessage emailMsg)
                    throws EmailApplicationException
Send the message specified in the end user properties.

Parameters:
configuration - The EmailConfiguration instance which holds the connection specific information.
emailMsg - The EmailMessage instance which contains the email message to be sent.
Returns:
True if send was successful; false otherwise.
Throws:
EmailApplicationException - upon error.

receiveMessage

public boolean receiveMessage(EmailConfiguration configuration,
                              EmailMessage emailMsg)
                       throws EmailApplicationException
Receive the next available message.

Parameters:
configuration - The EmailConfiguration instance containing connection specific information.
emailMsg - The EmailMessage to put the email message that gets received.
Returns:
If there is/are more message(s) to be read then true will be returned; otherwise, false will be returned.
Throws:
EmailApplicationException - upon error.

hasMessage

public boolean hasMessage(EmailConfiguration configuration)
                   throws EmailApplicationException
Determines whether there are message(s) to be received.

Parameters:
configuration - The EmailConfiguration instance containing connection specific information.
Returns:
If there are messages to be read then true will be returned; otherwise, false will be returned.
Throws:
EmailApplicationException - upon error.

Sun Adapter for e-Mail API