|
Email Answering System Version 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ninecode.email.connector.EmailConnectionData | +--com.ninecode.email.connector.EmailConfigurationData | +--com.ninecode.email.connector.EmailManagedConnectionFactory
Generate javax.mail connections wrapped for the Connector architecture.
Field Summary | |
protected PrintWriter |
mPrintWriter
The logging output stream. |
protected static HashSet |
mSources
Set of email sources. |
Fields inherited from class com.ninecode.email.connector.EmailConfigurationData |
mBackgroundThread, mBackgroundThreadInitialDelay, mBackgroundThreadPollDelay, mBackgroundThreadReconnectDelay, mQueueConnectionFactoryResourceReference, mQueueConnectionReference, mStoreFile, mStoreHost, mStorePort, mStoreProtocol, mTransportFile, mTransportHost, mTransportPort, mTransportProtocol |
Fields inherited from class com.ninecode.email.connector.EmailConnectionData |
mMailProperties, mPropertySupport, mStorePassword, mStoreUserName, mTransportPassword, mTransportUserName |
Constructor Summary | |
EmailManagedConnectionFactory()
Creates a new instance of EmailManagedConnectionFactory. |
|
EmailManagedConnectionFactory(EmailConfigurationData data)
Creates a new instance of EmailManagedConnectionFactory. |
Method Summary | |
Object |
createConnectionFactory()
Creates a Connection Factory instance. |
Object |
createConnectionFactory(ConnectionManager manager)
Creates a Connection Factory instance. |
ManagedConnection |
createManagedConnection(Subject subject,
ConnectionRequestInfo info)
Creates a new physical connection to the underlying EIS resource manager. |
boolean |
equals(Object obj)
Check if this ManagedConnectionFactory is equal to another ManagedConnectionFactory . |
protected static EmailSource |
findSourceForConfiguration(EmailConfigurationData data)
Look up the configuration in the list of sources. |
protected void |
forward(Message[] messages)
Perform "best effort" to forward the messages to the jms queue. |
protected EmailConfigurationData |
getDefaults()
Get the default settings. |
PrintWriter |
getLogWriter()
Get the log writer for this ManagedConnectionFactory instance. |
protected static EmailSource |
getSourceForCurrentThread()
Look up the current thread in the list of sources. |
int |
hashCode()
Returns the hash code for the ManagedConnectionFactory. |
protected void |
initialDelay()
Sleep for a few seconds while the container sets *all* our properties. |
protected String |
mark()
Create a time marker for the current time. |
ManagedConnection |
matchManagedConnections(Set set,
Subject subject,
ConnectionRequestInfo info)
Returns a matched connection from the candidate set of connections. |
void |
run()
Perform background polling for incoming email. |
protected void |
sendMessage(String reply,
String subject,
String content,
byte[] data)
Send a jms message with the contents of the email as data. |
void |
setBackgroundThread(boolean state)
Override setter for property BackgroundThread. |
void |
setBackgroundThread(Boolean state)
Override setter for property BackgroundThread. |
void |
setLogWriter(PrintWriter writer)
Set the log writer for this ManagedConnectionFactory instance. |
protected void |
sleep(int delay,
long then)
Sleep for a few milliseconds. |
protected void |
startThread()
Start a new thread running against this Runnable object. |
Methods inherited from class com.ninecode.email.connector.EmailConnectionData |
addPropertyChangeListener, clone, dup, getMailProperties, getPassword, getStorePassword, getStoreUserName, getTransportPassword, getTransportUserName, getUserName, override, removePropertyChangeListener, setMailProperties, setPassword, setStorePassword, setStoreUserName, setTransportPassword, setTransportUserName, setUserName |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected PrintWriter mPrintWriter
protected static HashSet mSources
EmailSource
objects that are unique according to
storeEquals()
.
This set provides for one thread to be running for each distinct
configuration that has background polling enabled, and provides
for synchronized access to distinct mail stores through the Source.
Constructor Detail |
public EmailManagedConnectionFactory()
public EmailManagedConnectionFactory(EmailConfigurationData data)
Method Detail |
protected EmailConfigurationData getDefaults()
protected void startThread()
Runnable
object.
public void setBackgroundThread(Boolean state)
setBackgroundThread
in class EmailConfigurationData
state
- New value of property BackgroundThread.EmailConfigurationData.setBackgroundThread(boolean)
public void setBackgroundThread(boolean state)
setBackgroundThread
in class EmailConfigurationData
state
- New value of property BackgroundThread.protected void sendMessage(String reply, String subject, String content, byte[] data) throws ResourceException
data
- The message to send.
ResourceException
- If a problem occurs, such as:
protected void initialDelay()
protected void forward(Message[] messages)
messages
- The messages to be forwarded.protected void sleep(int delay, long then)
delay
- The number of milliseconds to sleep.then
- The current time when processing started.
This is used to moderate the sleep time so that polls happen at nearly
exactly the requested interval. For example, in the following snippet
the delay between processes is zero if processing takes more than 50
milliseconds:
while (true) { long t = System.currentTimeMillis (); .. do some processing .. sleep (50, t); }
protected static EmailSource getSourceForCurrentThread() throws ResourceAdapterInternalException
ResourceAdapterInternalException
- If there is no source that
has the current thread.protected static EmailSource findSourceForConfiguration(EmailConfigurationData data) throws ResourceAdapterInternalException
ResourceAdapterInternalException
- If there is no source that
has that configuration.protected String mark()
public void run()
Store
is obtained
and periodically polled for new messages.
Messages are forwarded to the configured queue.
On encountering a third connection failure the polling switches to a
waiting state using a (longer) reconnect delay time. On a successful
connection it reverts to the original polling interval.
run
in interface Runnable
initialDelay()
,
EmailConfigurationData.getBackgroundThreadPollDelay()
,
EmailConfigurationData.getBackgroundThreadReconnectDelay()
public Object createConnectionFactory() throws ResourceException
createConnectionFactory
in interface ManagedConnectionFactory
ResourceException
- Generic exception.
ResourceAdapterInternalException
- Resource adapter related error condition.public Object createConnectionFactory(ConnectionManager manager) throws ResourceException
createConnectionFactory
in interface ManagedConnectionFactory
manager
- ConnectionManager to be associated with created EIS connection factory instance.
ResourceException
- Generic exception.
ResourceAdapterInternalException
- Resource adapter related error condition.public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo info) throws ResourceException
createManagedConnection
in interface ManagedConnectionFactory
subject
- Caller's security information.info
- - Additional resource adapter specific connection request information.
ResourceException
- Generic exception.
SecurityException
- Security related error.
ResourceAllocationException
- Failed to allocate system
resources for connection request.
ResourceAdapterInternalException
- Resource adapter related
error condition.
EISSystemException
- Internal error condition in EIS instance.public boolean equals(Object obj)
ManagedConnectionFactory
is equal to another ManagedConnectionFactory
.
Compares the configuration information in this managed connection against
configuration information in the given ManagedConnectionFactory
(NOTE: it does not compare LogWriter or state information).
equals
in interface ManagedConnectionFactory
equals
in class EmailConfigurationData
true
if two instances are equal.public PrintWriter getLogWriter() throws ResourceException
getLogWriter
in interface ManagedConnectionFactory
null
if none has been set yet.
ResourceException
- Generic exception.public int hashCode()
hashCode
in interface ManagedConnectionFactory
hashCode
in class EmailConfigurationData
public ManagedConnection matchManagedConnections(Set set, Subject subject, ConnectionRequestInfo info) throws ResourceException
matchManagedConnections
in interface ManagedConnectionFactory
set
- Candidate connection set.subject
- Caller's security information.info
- Additional resource adapter specific connection request information.
null
.
ResourceException
- Generic exception.
SecurityException
- Security related error.
ResourceAdapterInternalException
- Resource adapter related error condition.
NotSupportedException
- If operation is not supported.public void setLogWriter(PrintWriter writer)
setLogWriter
in interface ManagedConnectionFactory
writer
- An out stream for error logging and tracing.
|
Email Answering System Version 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |