|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.mail.Authenticator org.xmlBlaster.util.protocol.email.Pop3Driver
public class Pop3Driver
This class is capable to poll for emails using the POP3 protocol.
Configuration is done in xmlBlasterPlugins.xml
:
<plugin id='pop3' className='org.xmlBlaster.util.protocol.email.Pop3Driver'> <action do='LOAD' onStartupRunlevel='7' sequence='2' onFail='resource.configuration.pluginFailed'/> <action do='STOP' onShutdownRunlevel='7' sequence='5'/> <attribute id='mail.pop3.url'>pop3://xmlBlaster:xmlBlaster@localhost:110/INBOX</attribute> <attribute id='pop3PollingInterval'>500</attribute> </plugin>
Switch on logging with
-logging/org.xmlBlaster.util.protocol.email.Pop3Driver FINEand add to xmlBlasterJdk14Logging.properties:
handlers = org.xmlBlaster.util.log.XmlBlasterJdk14LoggingHandler.level = FINESTStandalone test:
1. Start a command line poller for user 'xmlBlaster': java -Dmail.pop3.url=pop3://xmlBlaster:xmlBlaster@localhost/INBOX org.xmlBlaster.util.protocol.email.Pop3Driver -receivePolling 2. Send from command line an email: java -Dmail.smtp.url=smtp://xmlBlaster:xmlBlaster@localhost org.xmlBlaster.util.protocol.email.SmtpClient -from xmlBlaster@localhost -to xmlBlaster@localhost
TODO: Implement reusing inbox.getMessage() for better performance currently we reconnect for each query ( the benefit is that we don't block the POP3 server with a permanent connection).
Field Summary | |
---|---|
static boolean |
CLEAR_MESSAGES
|
static java.lang.String |
DISCARD
|
static boolean |
LEAVE_MESSAGES
|
static java.lang.String |
OBJECTENTRY_KEY
|
static java.lang.String |
POP3_FOLDER
|
static java.lang.String |
threadName
|
protected XbUri |
xbUri
|
Constructor Summary | |
---|---|
Pop3Driver()
You need to call setSessionProperties() thereafter. |
Method Summary | |
---|---|
void |
activate()
Activate xmlBlaster access through this protocol. |
void |
deActivate()
Deactivate xmlBlaster access (standby), no clients can connect. |
int |
deregisterForEmail(I_ResponseListener listener)
Deregister all existing registrations for the given listener. |
java.lang.Object |
deregisterForEmail(java.lang.String secretSessionId,
java.lang.String requestId)
|
java.lang.String |
getEnvPrefix()
The command line key prefix |
long |
getHoldbackExpireTimeout()
|
java.util.Map.Entry[] |
getListenerInterfaces()
|
java.lang.String[] |
getListenerKeys()
|
java.lang.String |
getListeners()
Access a list of registered java listeners. |
javax.mail.Message |
getMessage()
|
java.lang.String |
getMyEmailAddress()
Returns for example "demo@localhost" which is extracted from pop3Url="pop3://demo:secret@localhost:110/INBOX" |
int |
getNumberOfHoldbackEmails()
Get the number of received emails for which no java bean is interested. |
javax.mail.PasswordAuthentication |
getPasswordAuthentication()
Used by Authenticator to access user name and password |
long |
getPollingInterval()
Access the polling interval |
static Pop3Driver |
getPop3Driver(Global glob,
I_PluginConfig pluginConfig,
java.lang.String msgIdFileName)
The Pop3Driver is a singleton in the Global scope. |
java.lang.String |
getPop3Url()
Access the POP3 MTA access configuration |
java.lang.String |
getProtocolId()
Access the xmlBlaster internal name of the protocol driver. |
javax.mail.Session |
getSession()
Access the mailing session. |
java.lang.String |
getType()
Enforced by I_Plugin |
java.lang.String |
getUrlWithoutPassword()
Returns for example "pop3://demo@localhost:110/INBOX" which is extracted from pop3Url="pop3://demo:secret@localhost:110/INBOX" |
java.lang.String |
getUsageUrl()
|
java.lang.String |
getVersion()
Enforced by I_Plugin |
void |
init(Global glob,
I_PluginConfig pluginConfig)
|
void |
init(Global glob,
PluginInfo pluginInfo)
This method is called by the PluginManager (enforced by I_Plugin). |
boolean |
isActive()
Access the current state |
boolean |
isShutdown()
Check status |
static void |
main(java.lang.String[] args)
java -Dmail.pop3.url=pop3://blue:blue@localhost:110/INBOX org.xmlBlaster.util.protocol.email.Pop3Driver -receivePolling true -clearMessages false |
EmailData[] |
readInbox(boolean clear)
Read messages from mail server with POP3. |
void |
registerForEmail(java.lang.String secretSessionId,
java.lang.String requestId,
I_ResponseListener listener)
If you are interested in an email register it here. |
protected java.lang.String |
retrieveContent(javax.mail.internet.MimePart part)
Get content text. |
void |
setHoldbackExpireTimeout(long holdbackExpireTimeout)
Configure how long a not yet dispatched message shall live in the Pop3Driver map. |
void |
setPollingInterval(long pollingInterval)
Set the polling interval |
void |
setPop3Url(java.lang.String pop3Url)
|
void |
setSessionProperties(java.util.Properties properties,
Global glob,
I_PluginConfig pluginConfig)
Set session properties and create a session. |
void |
setUsageUrl(java.lang.String url)
|
void |
shutdown()
Halt the plugin. |
void |
timeout(java.lang.Object userData)
Polling for response messages. |
java.lang.String |
usage()
JMX |
Methods inherited from class javax.mail.Authenticator |
---|
getDefaultUserName, getRequestingPort, getRequestingPrompt, getRequestingProtocol, getRequestingSite |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected XbUri xbUri
public static final boolean CLEAR_MESSAGES
public static final boolean LEAVE_MESSAGES
public static final java.lang.String POP3_FOLDER
public static java.lang.String threadName
public static final java.lang.String OBJECTENTRY_KEY
public static final java.lang.String DISCARD
Constructor Detail |
---|
public Pop3Driver()
Method Detail |
---|
public static Pop3Driver getPop3Driver(Global glob, I_PluginConfig pluginConfig, java.lang.String msgIdFileName) throws XmlBlasterException
glob
- pluginConfig
-
XmlBlasterException
public javax.mail.PasswordAuthentication getPasswordAuthentication()
getPasswordAuthentication
in class javax.mail.Authenticator
public void init(Global glob, PluginInfo pluginInfo) throws XmlBlasterException
init
in interface I_Plugin
XmlBlasterException
I_Plugin.init(org.xmlBlaster.util.Global,org.xmlBlaster.util.plugin.PluginInfo)
public void init(Global glob, I_PluginConfig pluginConfig) throws XmlBlasterException
XmlBlasterException
public java.lang.String getProtocolId()
public java.lang.String getType()
getType
in interface I_AdminPlugin
getType
in interface I_Plugin
public void registerForEmail(java.lang.String secretSessionId, java.lang.String requestId, I_ResponseListener listener)
key
- listener
- public java.lang.Object deregisterForEmail(java.lang.String secretSessionId, java.lang.String requestId)
public int deregisterForEmail(I_ResponseListener listener)
listener
- The listener to cleanup
public java.util.Map.Entry[] getListenerInterfaces()
public java.lang.String[] getListenerKeys()
public java.lang.String getListeners()
I_AdminPop3Driver
getListeners
in interface I_AdminPop3Driver
public java.lang.String getEnvPrefix()
public java.lang.String getVersion()
getVersion
in interface I_AdminPlugin
getVersion
in interface I_Plugin
public void setSessionProperties(java.util.Properties properties, Global glob, I_PluginConfig pluginConfig) throws XmlBlasterException
Example settings:
Properties props = System.getProperties(); props.put("mail.pop3.url", "pop3://joe:secret@localhost/INBOX"); props.put("mail.debug", "false");
Usage is "pop3://user:password@host:port/INBOX". Only 'INBOX' is supported for pop3. If a property is not found System.getProperty() is consulted.
XmlBlasterException
public void timeout(java.lang.Object userData)
timeout
in interface I_Timeout
userData
- You get bounced back your userData which you passed
with Timeout.addTimeoutListener()public javax.mail.Session getSession()
public javax.mail.Message getMessage()
public java.lang.String getMyEmailAddress()
public java.lang.String getUrlWithoutPassword()
public EmailData[] readInbox(boolean clear) throws XmlBlasterException
Convenience method which returns the most important fields only
clear
- If CLEAR_MESSAGES=true the messages are destroyed on the server
XmlBlasterException
public java.lang.String getPop3Url()
I_AdminPop3Driver
getPop3Url
in interface I_AdminPop3Driver
public void setPop3Url(java.lang.String pop3Url)
setPop3Url
in interface I_AdminPop3Driver
pop3Url
- Syntax is "pop3://user:password@host:port/INBOX"public long getPollingInterval()
I_AdminPop3Driver
getPollingInterval
in interface I_AdminPop3Driver
public void setPollingInterval(long pollingInterval)
I_AdminPop3Driver
setPollingInterval
in interface I_AdminPop3Driver
pollingInterval
- The timeout in milliseconds.protected java.lang.String retrieveContent(javax.mail.internet.MimePart part) throws javax.mail.MessagingException, java.io.IOException
part
- the MimePart to check for content
javax.mail.MessagingException
java.io.IOException
public void activate() throws java.lang.Exception
activate
in interface I_AdminService
java.lang.Exception
public boolean isActive()
I_AdminService
isActive
in interface I_AdminService
public void deActivate()
deActivate
in interface I_AdminService
public void shutdown()
shutdown
in interface I_AdminPlugin
shutdown
in interface I_Plugin
public boolean isShutdown()
I_AdminPlugin
isShutdown
in interface I_AdminPlugin
public java.lang.String usage()
usage
in interface I_AdminUsage
public java.lang.String getUsageUrl()
getUsageUrl
in interface I_AdminUsage
public void setUsageUrl(java.lang.String url)
setUsageUrl
in interface I_AdminUsage
public long getHoldbackExpireTimeout()
getHoldbackExpireTimeout
in interface I_AdminPop3Driver
public void setHoldbackExpireTimeout(long holdbackExpireTimeout)
I_AdminPop3Driver
setHoldbackExpireTimeout
in interface I_AdminPop3Driver
holdbackExpireTimeout
- The holdbackExpireTimeout to set.public int getNumberOfHoldbackEmails()
I_AdminPop3Driver
getNumberOfHoldbackEmails
in interface I_AdminPop3Driver
public static void main(java.lang.String[] args)
for other properties
|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |