org.apache.servicemix.mail
Class MailPollerEndpoint

java.lang.Object
  extended by org.apache.servicemix.common.endpoints.AbstractEndpoint
      extended by org.apache.servicemix.common.endpoints.SimpleEndpoint
          extended by org.apache.servicemix.common.endpoints.ConsumerEndpoint
              extended by org.apache.servicemix.common.endpoints.PollingEndpoint
                  extended by org.apache.servicemix.mail.MailPollerEndpoint
All Implemented Interfaces:
Endpoint, MailEndpointType

public class MailPollerEndpoint
extends PollingEndpoint
implements MailEndpointType

This is the polling endpoint for the mail component.

Author:
lhein

Field Summary
 
Fields inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
definition, description, endpoint, interfaceName, service, serviceUnit
 
Constructor Summary
MailPollerEndpoint()
          default constructor
 
Method Summary
 java.lang.String getConnection()
           
 java.util.Map<java.lang.String,java.lang.String> getCustomProperties()
           
 java.lang.String getCustomTrustManagers()
           
 java.lang.String getLocationURI()
           
 AbstractMailMarshaler getMarshaler()
           
 int getMaxFetchSize()
           
 org.apache.servicemix.store.Store getStorage()
           
 boolean isDebugMode()
           
 boolean isDeleteProcessedMessages()
           
 boolean isProcessOnlyUnseenMessages()
           
 void poll()
           
 void process(javax.jbi.messaging.MessageExchange exchange)
           
 void setConnection(java.lang.String connection)
          Specifies the connection URI used to connect to a mail server.
 void setCustomProperties(java.util.Map<java.lang.String,java.lang.String> customProperties)
          Specifies a java.util.Map which may contain additional properties for the connection.
 void setCustomTrustManagers(java.lang.String customTrustManagers)
          Specifies one or more trust manager classes separated by a semicolon (;).
These classes have to implement the Trustmanager interface and need to provide an empty default constructor to be valid.

If you want to accept all security certificates without a check you may consider using the DummyTrustManager class.
 void setDebugMode(boolean debugMode)
          Specifies if the JavaMail is run in DEBUG mode.
 void setDeleteProcessedMessages(boolean deleteProcessedMessages)
          This flag is used to indicate what happens to a processed mail polled from a mail folder.
 void setMarshaler(AbstractMailMarshaler marshaler)
          With this method you can specify a marshaler class which provides the logic for converting a mail into a normalized message.
 void setMaxFetchSize(int maxFetchSize)
          This sets the maximum amount of mails to process within one polling cycle.
 void setProcessOnlyUnseenMessages(boolean processOnlyUnseenMessages)
          This flag is used to indicate whether all mails are polled from a mail folder or only the unseen mails are processed.

If it is set to true only the unseen mails will be processed.
If it is set to false all mails will be processed.
 void setStorage(org.apache.servicemix.store.Store storage)
          Specifies a org.apache.servicemix.store.Store object which will be used for storing the identifications of already processed messages.
This store is only used with the POP3 protocol and if unseen mails are processed only.
 void start()
           
 void stop()
           
 
Methods inherited from class org.apache.servicemix.common.endpoints.PollingEndpoint
getDelay, getExecutor, getFirstTime, getPeriod, getScheduler, handlePollException, isConcurrentPolling, setConcurrentPolling, setDelay, setFirstTime, setPeriod, setScheduler
 
Methods inherited from class org.apache.servicemix.common.endpoints.ConsumerEndpoint
activate, configureExchangeTarget, deactivate, getRole, getTargetEndpoint, getTargetInterface, getTargetOperation, getTargetService, getTargetUri, setTargetEndpoint, setTargetInterface, setTargetOperation, setTargetService, setTargetUri, validate
 
Methods inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
done, fail, getChannel, getContext, getExchangeFactory, send, sendSync
 
Methods inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
getDefinition, getDescription, getEndpoint, getInterfaceName, getKey, getService, getServiceUnit, isExchangeOkay, prepareExchange, setDefinition, setDescription, setEndpoint, setInterfaceName, setService, setServiceUnit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MailPollerEndpoint

public MailPollerEndpoint()
default constructor

Method Detail

getLocationURI

public java.lang.String getLocationURI()
Overrides:
getLocationURI in class ConsumerEndpoint

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Endpoint
Overrides:
start in class PollingEndpoint
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Endpoint
Overrides:
stop in class PollingEndpoint
Throws:
java.lang.Exception

process

public void process(javax.jbi.messaging.MessageExchange exchange)
             throws java.lang.Exception
Specified by:
process in interface Endpoint
Specified by:
process in class AbstractEndpoint
Throws:
java.lang.Exception

poll

public void poll()
          throws java.lang.Exception
Specified by:
poll in class PollingEndpoint
Throws:
java.lang.Exception

isDeleteProcessedMessages

public boolean isDeleteProcessedMessages()

setDeleteProcessedMessages

public void setDeleteProcessedMessages(boolean deleteProcessedMessages)

This flag is used to indicate what happens to a processed mail polled from a mail folder. If it is set to true the mail will be deleted after it was sent into the bus successfully. If set to false the mail will reside inside the mail folder but will be marked as already seen.
If the sending of the mail results in an error, the mail will not be deleted / marked and reprocessed on next run of the polling cycle.

   The default value is false

Parameters:
deleteProcessedMessages - a boolean value as flag

getMarshaler

public AbstractMailMarshaler getMarshaler()

setMarshaler

public void setMarshaler(AbstractMailMarshaler marshaler)

With this method you can specify a marshaler class which provides the logic for converting a mail into a normalized message. This class has to extend the abstract class AbstractMailMarshaler or an extending class. If you don't specify a marshaler, the DefaultMailMarshaler will be used.

Parameters:
marshaler - a class which extends AbstractMailMarshaler

getMaxFetchSize

public int getMaxFetchSize()

setMaxFetchSize

public void setMaxFetchSize(int maxFetchSize)

This sets the maximum amount of mails to process within one polling cycle. If the maximum amount is reached all other mails in "unseen" state will be skipped.

   The default value is -1 (unlimited)

Parameters:
maxFetchSize - a int value for maximum to be polled messages

isProcessOnlyUnseenMessages

public boolean isProcessOnlyUnseenMessages()

setProcessOnlyUnseenMessages

public void setProcessOnlyUnseenMessages(boolean processOnlyUnseenMessages)

This flag is used to indicate whether all mails are polled from a mail folder or only the unseen mails are processed.

If it is set to true only the unseen mails will be processed.
If it is set to false all mails will be processed.

   The default value is true

Parameters:
processOnlyUnseenMessages - a boolean value as flag

getConnection

public java.lang.String getConnection()

setConnection

public void setConnection(java.lang.String connection)

Specifies the connection URI used to connect to a mail server.

Templates:
   <protocol>://<user>@<host>[:<port>][/<folder>]?password=<password>
      OR
   <protocol>://<host>[:<port>][/<folder>]?user=<user>;password=<password>

Details:

Name Description
protocol the protocol to use (example: pop3 or imap)
user the user name used to log into an account
host the name or ip address of the mail server
port the port number to use (optional)
folder the folder to poll from (optional)
password the password for the login

Examples:
   imap://lhein@imapserver:143/INBOX?password=mypass
   pop3://pop3server/INBOX?user=me@myhome.org;password=mypass

   The default value is null

Parameters:
connection - a String value containing the connection details

isDebugMode

public boolean isDebugMode()

setDebugMode

public void setDebugMode(boolean debugMode)

Specifies if the JavaMail is run in DEBUG mode. This means that while connecting to server and processing mails a detailed log is written to debug output.
This mode is very handy if you are experiencing problems with your mail server connection and you want to find out what is going wrong in communication with the server.

   true - the debug mode is enabled
   false - the debug mode is disabled

   The default value is false

Parameters:
debugMode - a boolean value for debug mode

getCustomTrustManagers

public java.lang.String getCustomTrustManagers()

setCustomTrustManagers

public void setCustomTrustManagers(java.lang.String customTrustManagers)

Specifies one or more trust manager classes separated by a semicolon (;).
These classes have to implement the Trustmanager interface and need to provide an empty default constructor to be valid.

If you want to accept all security certificates without a check you may consider using the DummyTrustManager class. It is actually only an empty stub without any checking logic.
But be aware that this will be a security risk in production environments.

   The default value is null

Parameters:
customTrustManagers - a String value containing one or more full class names separated by ; char

getCustomProperties

public java.util.Map<java.lang.String,java.lang.String> getCustomProperties()

setCustomProperties

public void setCustomProperties(java.util.Map<java.lang.String,java.lang.String> customProperties)

Specifies a java.util.Map which may contain additional properties for the connection.

Example for disabling TOP for POP3 headers:
 key: "mail.pop3.disabletop"
 value: "true"

   The default value is null

Parameters:
customProperties - a java.util.Map<String, String> containing connection properties

getStorage

public org.apache.servicemix.store.Store getStorage()

setStorage

public void setStorage(org.apache.servicemix.store.Store storage)

Specifies a org.apache.servicemix.store.Store object which will be used for storing the identifications of already processed messages.
This store is only used with the POP3 protocol and if unseen mails are processed only.

   The default value is null

Parameters:
storage - a org.apache.servicemix.store.Store object for storing seen message idents


Copyright © 2005-2012 FuseSource. All Rights Reserved.