Email Answering System
Version 1.0

com.ninecode.email.connector
Class EmailConnection

java.lang.Object
  |
  +--com.ninecode.email.connector.EmailConnection
All Implemented Interfaces:
Connection, LocalTransaction

public class EmailConnection
extends Object
implements Connection, LocalTransaction

Client accessible connection object. A javax.mail session presented as a Common Client Interface connection. An application level connection to the underlying javax.mail subsystem. The java.mail Session object is actually held by the ManagedConnection that creates this object. Interactions originate from this object.

Author:
Derrick Oswald

Field Summary
protected  EmailManagedConnection mConnection
          The managed connection that created this connection.
protected  EmailConnectionData mData
          The connection data for this particular connection.
protected  ArrayList mInteractions
          The interactions created from thsi connection.
 
Constructor Summary
protected EmailConnection(EmailManagedConnection connection, EmailConnectionData data)
          Create an EmailConnection.
 
Method Summary
 void begin()
          Begins a local transaction on an EIS instance.
protected  void checkManagedConnection()
          Check the managed connection associated with this connection.
 void close()
          Initiates close of the connection handle at the application level.
protected  void closeInteraction(EmailInteraction interaction)
          Close an interaction created by this connection.
 void commit()
          Commits the current local transaction and release all locks held by the underlying EIS instance.
 Interaction createInteraction()
          Creates an Interaction associated with this Connection.
protected  EmailConnectionData getConnectionData()
          Get the connection data associated with this connection.
 LocalTransaction getLocalTransaction()
          Returns a LocalTransaction instance that enables a component to demarcate resource manager local transactions on the Connection.
protected  EmailManagedConnection getManagedConnection()
          Get the managed connection associated with this connection.
protected  Message[] getMessages()
          Get any messages.
 ConnectionMetaData getMetaData()
          Gets the information on the underlying EIS instance represented through an active connection.
 ResultSetInfo getResultSetInfo()
          Gets the information on the ResultSet functionality supported by a connected EIS instance.
protected  Session getSession()
          Get the session associated with this connection.
protected  Transport getTransport()
          Get the transport associated with this connection.
 void rollback()
          Rollbacks the current resource manager local transaction.
protected  void setManagedConnection(EmailManagedConnection connection)
          Set the managed connection associated with this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mConnection

protected EmailManagedConnection mConnection
The managed connection that created this connection.


mData

protected EmailConnectionData mData
The connection data for this particular connection.


mInteractions

protected ArrayList mInteractions
The interactions created from thsi connection.

Constructor Detail

EmailConnection

protected EmailConnection(EmailManagedConnection connection,
                          EmailConnectionData data)
Create an EmailConnection.

Parameters:
connection - The managed connection that created this connection.
data - The specific connection data to be used for this connection. This may be different that the connection data within the managed connection object's configuration data if the Subject or ConnectionRequestInfo specified alternate connection data.
Method Detail

checkManagedConnection

protected void checkManagedConnection()
                               throws ResourceException
Check the managed connection associated with this connection.

Throws:
ResourceException - If this is a closed connection.

getManagedConnection

protected EmailManagedConnection getManagedConnection()
                                               throws ResourceException
Get the managed connection associated with this connection.

Returns:
The managed connection object.
Throws:
ResourceException - If this is a closed connection.

setManagedConnection

protected void setManagedConnection(EmailManagedConnection connection)
Set the managed connection associated with this connection. Used by the associateConnection() method of the managed connection to switch this application level connection to another underlying managed connection (physical connection).

Parameters:
connection - The managed connection object to associate with this connection.
See Also:
EmailManagedConnection.associateConnection(Object)

getConnectionData

protected EmailConnectionData getConnectionData()
                                         throws ResourceException
Get the connection data associated with this connection. Only needed by EmailConnectionMetaData class.

Returns:
The connection data object.
ResourceException

getSession

protected Session getSession()
                      throws ResourceException
Get the session associated with this connection.

Returns:
The session object.
Throws:
ResourceException - If this is a closed connection.

getTransport

protected Transport getTransport()
                          throws ResourceException
Get the transport associated with this connection.

Returns:
The transport object.
Throws:
ResourceException - If this is a closed connection.

getMessages

protected Message[] getMessages()
                         throws ResourceException,
                                MessagingException
Get any messages.

Returns:
The array of messages.
Throws:
ResourceException - If this is a closed connection.
MessagingException

closeInteraction

protected void closeInteraction(EmailInteraction interaction)
Close an interaction created by this connection.


close

public void close()
           throws ResourceException
Initiates close of the connection handle at the application level. A client should not use a closed connection to interact with an EIS.

Specified by:
close in interface Connection
Throws:
ResourceException - Exception thrown if close on a connection handle fails. Any invalid connection close invocation--example, calling close on a connection handle that is already closed--should also throw this exception.

createInteraction

public Interaction createInteraction()
                              throws ResourceException
Creates an Interaction associated with this Connection. An Interaction enables an application to execute EIS functions.

Specified by:
createInteraction in interface Connection
Returns:
Interaction instance.
Throws:
ResourceException - Failed to create an Interaction.

getLocalTransaction

public LocalTransaction getLocalTransaction()
                                     throws ResourceException
Returns a LocalTransaction instance that enables a component to demarcate resource manager local transactions on the Connection. The method returns this object which implements LocalTransaction.

Specified by:
getLocalTransaction in interface Connection
Returns:
LocalTransaction instance.
Throws:
ResourceException - Failed to return a LocalTransaction instance because of a resource adapter error.
NotSupportedException - Demarcation of Resource manager local transactions is not supported on this Connection.
See Also:
begin(), commit(), rollback()

getMetaData

public ConnectionMetaData getMetaData()
                               throws ResourceException
Gets the information on the underlying EIS instance represented through an active connection.

Specified by:
getMetaData in interface Connection
Returns:
ConnectionMetaData instance representing information about the EIS instance.
Throws:
ResourceException - Failed to get information about the connected EIS instance. Error can be resource adapter-internal, EIS-specific or communication related.

getResultSetInfo

public ResultSetInfo getResultSetInfo()
                               throws ResourceException
Gets the information on the ResultSet functionality supported by a connected EIS instance. This method throws NotSupportedException since the ResultSet paradigm doesn't apply to email messages.

Specified by:
getResultSetInfo in interface Connection
Returns:
ResultSetInfo instance.
Throws:
ResourceException - Failed to get ResultSet related information.
NotSupportedException - ResultSet functionality is not supported.

commit

public void commit()
            throws ResourceException
Commits the current local transaction and release all locks held by the underlying EIS instance. This method delegates the call to the ManagedConnection that created this object.

Specified by:
commit in interface LocalTransaction
Throws:
ResourceException - Failed to commit a local transaction. Examples of error cases are:
  • Resource adapter internal or EIS-specific error.
  • Violation of integrity constraints, deadlock detection, communication failure during transaction completion, or any retry requirement.
  • Connection is participating in an active JTA transaction.
  • Invalid transaction context; commit operation invoked without an active transaction context.
  • See Also:
    EmailManagedConnection.commit()

    begin

    public void begin()
               throws ResourceException
    Begins a local transaction on an EIS instance. This method delegates the call to the ManagedConnection that created this object.

    Specified by:
    begin in interface LocalTransaction
    Throws:
    ResourceException - Failed to begin a local transaction. Examples of error cases are:
  • Resource adapter internal or EIS-specific error.
  • Connection is already participating in a local or JTA transaction.
  • See Also:
    EmailManagedConnection.begin()

    rollback

    public void rollback()
                  throws ResourceException
    Rollbacks the current resource manager local transaction. This method delegates the call to the ManagedConnection that created this object.

    Specified by:
    rollback in interface LocalTransaction
    Throws:
    ResourceException - Failed to rollback a local transaction. Examples of error cases are:
  • Resource adapter internal or EIS-specific error.
  • Connection is participating in an active JTA transaction.
  • Invalid transaction context; rollback operation invoked without an active transaction context
  • See Also:
    EmailManagedConnection.rollback()

    Email Answering System
    Version 1.0

    Copyright © 2003 Derrick Oswald. All rights reserved.