Email Answering System
Version 1.0

com.ninecode.email.connector
Class EmailSource

java.lang.Object
  |
  +--com.ninecode.email.connector.EmailSource

public class EmailSource
extends Object

Encapsulation of all the unique things for a specific Source Configuration. This currently contains the background thread that performs background polling and provides synchronized access to the Store, if the store cannot be opened (for read/write) by two agents at the same time (which is the case with my pop3 provider). These objects should only be created for unique 'Store' configurations. There is also a reference to a EmailConfigurationData object that is storeEquals() to any other configuration that shares this EmailSource, and this is used in the equals() method to determine if this Source is equal (storeEquals()) to any other.

Author:
Derrick Oswald

Field Summary
protected  EmailConfigurationData mConfigurationData
          Holds value of property configurationData.
protected static Message[] mEmpty
          Value to be returned when there are no messages.
protected  PrintWriter mPrintWriter
          The logging output stream.
protected  Session mSession
          The session object for this source.
protected  Store mStore
          Holds value of property store.
protected  Thread mThread
          Holds value of property thread.
 
Constructor Summary
EmailSource(EmailConfigurationData data)
          Creates a new instance of EmailSource
 
Method Summary
protected  Store connectStore()
          Connect to the store.
protected  void disconnectStore()
          Disconnect the Store.
 boolean equals(Object other)
          Returns true if the other object is equal to this one.
 EmailConfigurationData getConfigurationData()
          Getter for property configurationData.
 Message[] getMessages()
           
protected  Session getSession()
          Get the session associated with this connection.
 Store getStore()
          Get the email store.
 Thread getThread()
          Getter for property thread.
 int hashCode()
          Returns a hash code for this object.
protected  Message[] pickleMessages(Message[] messages)
           
 void setConfigurationData(EmailConfigurationData configurationData)
          Setter for property configurationData.
protected  void setSession(Session session)
          Set the session associated with this connection.
 void setStore(Store store)
          Setter for property store.
 void setThread(Thread thread)
          Setter for property thread.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mConfigurationData

protected EmailConfigurationData mConfigurationData
Holds value of property configurationData.


mThread

protected Thread mThread
Holds value of property thread.


mSession

protected Session mSession
The session object for this source.


mStore

protected Store mStore
Holds value of property store.


mPrintWriter

protected PrintWriter mPrintWriter
The logging output stream.


mEmpty

protected static Message[] mEmpty
Value to be returned when there are no messages. This is allocated once since it's more than likely that no messages are available when polled.

Constructor Detail

EmailSource

public EmailSource(EmailConfigurationData data)
Creates a new instance of EmailSource

Method Detail

getConfigurationData

public EmailConfigurationData getConfigurationData()
Getter for property configurationData.

Returns:
Value of property configurationData.

setConfigurationData

public void setConfigurationData(EmailConfigurationData configurationData)
Setter for property configurationData.

Parameters:
configurationData - New value of property configurationData.

getThread

public Thread getThread()
Getter for property thread.

Returns:
Value of property thread.

setThread

public void setThread(Thread thread)
Setter for property thread.

Parameters:
thread - New value of property thread.

getSession

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

Returns:
The session object.

setSession

protected void setSession(Session session)
Set the session associated with this connection.

Parameters:
session - The new session object.

connectStore

protected Store connectStore()
                      throws ResourceException
Connect to the store. Performs the actual connect on a Store object obtained from the session. The INBOX is lazily opened later.

Returns:
The connected Store object.
Throws:
ResourceException - If a problem occurs, examples are:
  • There is no such Store provider as getStoreProtocol()
  • The connect to the Store failed.

  • disconnectStore

    protected void disconnectStore()
                            throws ResourceException
    Disconnect the Store.

    Throws:
    ResourceException - If the close fails.

    getStore

    public Store getStore()
                   throws ResourceException
    Get the email store. If the store is null it creates one based on the configuration data.

    Returns:
    The store associated with the configuration data.
    Throws:
    ResourceException - if any underlying adapter error occurs.

    setStore

    public void setStore(Store store)
    Setter for property store.

    Parameters:
    store - New value of property store.

    pickleMessages

    protected Message[] pickleMessages(Message[] messages)
                                throws MessagingException
    MessagingException

    getMessages

    public Message[] getMessages()
                          throws MessagingException,
                                 ResourceException
    MessagingException
    ResourceException

    equals

    public boolean equals(Object other)
    Returns true if the other object is equal to this one. The equals method is required to hash multiple threads correctly based on configuration data. Only the storeEquals() method is considered.

    Overrides:
    equals in class Object
    Returns:
    true if the other object is equal to this one.

    hashCode

    public int hashCode()
    Returns a hash code for this object. This is needed to correctly determine uniqueness in the list of sources.

    Overrides:
    hashCode in class Object
    Returns:
    The hash code for this object. This will depend on all the properties for this bean.

    Email Answering System
    Version 1.0

    Copyright © 2003 Derrick Oswald. All rights reserved.