public class FetchMail extends Object implements Runnable, LogEnabled, Configurable
Class FetchMail
is an Avalon task that is periodically triggered
to fetch mail from a JavaMail Message Store.
The lifecycle of an instance of FetchMail
is managed by Avalon.
The configure(Configuration)
method is invoked to parse and
validate Configuration properties. The targetTriggered(String) method is
invoked to execute the task.
When triggered, a sorted list of Message Store Accounts to be processed is
built. Each Message Store Account is processed by delegating to
StoreProcessor
.
There are two kinds of Message Store Accounts, static and dynamic. Static
accounts are expliciltly declared in the Configuration. Dynamic accounts are
built each time the task is executed, one per each user defined to James,
using the James user name with a configurable prefix and suffix to define the
host user identity and recipient identity for each Account. Dynamic accounts
allow FetchMail
to fetch mail for all James users without
modifying the Configuration parameters or restarting the Avalon server.
To fully understand the operations supported by this task, read the Class
documention for each Class in the delegation chain starting with this class'
delegate, StoreProcessor
.
Constructor and Description |
---|
FetchMail()
Constructor for POP3mail.
|
Modifier and Type | Method and Description |
---|---|
protected Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> |
computeDynamicAccounts()
Computes the dynamicAccounts.
|
protected Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> |
computeDynamicAccounts(Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> oldAccounts,
org.apache.james.fetchmail.FetchMail.ParsedDynamicAccountParameters parameters)
Compute the dynamicAccounts for the passed parameters.
|
protected List<org.apache.james.fetchmail.FetchMail.ParsedDynamicAccountParameters> |
computeParsedDynamicAccountParameters()
Computes the ParsedDynamicAccountParameters.
|
protected javax.mail.Session |
computeSession()
Answers a new Session.
|
protected List<org.apache.james.fetchmail.Account> |
computeStaticAccounts()
Computes the staticAccounts.
|
void |
configure(org.apache.commons.configuration.HierarchicalConfiguration configuration)
Method configure parses and validates the Configuration data and creates
a new
ParsedConfiguration , an Account for each
configured static account and a
ParsedDynamicAccountParameters for each dynamic account. |
protected org.apache.james.fetchmail.ParsedConfiguration |
getConfiguration()
Returns the configuration.
|
protected DNSService |
getDNSService()
Returns the DNSService.
|
DomainList |
getDomainList() |
protected Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> |
getDynamicAccounts()
Returns the dynamicAccounts.
|
protected UsersRepository |
getLocalUsers()
Returns the localUsers.
|
MailQueue |
getMailQueue() |
protected List<org.apache.james.fetchmail.FetchMail.ParsedDynamicAccountParameters> |
getParsedDynamicAccountParameters()
Returns the ParsedDynamicAccountParameters.
|
protected javax.mail.Session |
getSession()
Returns the session, lazily initialized if required.
|
protected List<org.apache.james.fetchmail.Account> |
getStaticAccounts()
Returns the accounts.
|
protected boolean |
isFetching()
Returns the fetching.
|
protected void |
resetDynamicAccounts()
Resets the dynamicAccounts.
|
void |
run()
Method target triggered fetches mail for each configured account.
|
void |
setDNSService(DNSService dns) |
void |
setDomainList(DomainList domainList) |
protected void |
setDynamicAccounts(Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> dynamicAccounts)
Sets the dynamicAccounts.
|
protected void |
setFetching(boolean fetching)
Sets the fetching.
|
void |
setLog(org.slf4j.Logger logger)
Sets the service log.
|
void |
setMailQueue(MailQueue queue) |
protected void |
setParsedConfiguration(org.apache.james.fetchmail.ParsedConfiguration configuration)
Sets the configuration.
|
protected void |
setParsedDynamicAccountParameters(List<org.apache.james.fetchmail.FetchMail.ParsedDynamicAccountParameters> parsedDynamicAccountParameters)
Sets the ParsedDynamicAccountParameters.
|
protected void |
setSession(javax.mail.Session session)
Sets the session.
|
protected void |
setSessionParameters(org.apache.commons.configuration.HierarchicalConfiguration configuration)
Propagate any Session parameters in the configuration to the Session.
|
protected void |
setStaticAccounts(List<org.apache.james.fetchmail.Account> accounts)
Sets the accounts.
|
void |
setUsersRepository(UsersRepository urepos) |
protected void |
updateDynamicAccounts()
Updates the dynamicAccounts.
|
protected void |
updateParsedDynamicAccountParameters()
Updates the ParsedDynamicAccountParameters.
|
protected void |
updateSession()
Updates the current Session.
|
protected void |
updateStaticAccounts()
Updates the staticAccounts.
|
public void configure(org.apache.commons.configuration.HierarchicalConfiguration configuration) throws org.apache.commons.configuration.ConfigurationException
ParsedConfiguration
, an Account
for each
configured static account and a
ParsedDynamicAccountParameters
for each dynamic account.configure
in interface Configurable
org.apache.commons.configuration.ConfigurationException
Configurable.configure(HierarchicalConfiguration)
public void run()
protected boolean isFetching()
protected void setFetching(boolean fetching)
fetching
- The fetching to setprotected org.apache.james.fetchmail.ParsedConfiguration getConfiguration()
protected void setParsedConfiguration(org.apache.james.fetchmail.ParsedConfiguration configuration)
configuration
- The configuration to setprotected UsersRepository getLocalUsers()
protected DNSService getDNSService()
public void setDNSService(DNSService dns)
public void setUsersRepository(UsersRepository urepos)
public final void setLog(org.slf4j.Logger logger)
LogEnabled
setLog
in interface LogEnabled
logger
- not nullprotected List<org.apache.james.fetchmail.Account> getStaticAccounts()
protected void setStaticAccounts(List<org.apache.james.fetchmail.Account> accounts)
accounts
- The accounts to setprotected void updateStaticAccounts()
protected void updateParsedDynamicAccountParameters()
protected void updateDynamicAccounts() throws org.apache.commons.configuration.ConfigurationException
org.apache.commons.configuration.ConfigurationException
protected List<org.apache.james.fetchmail.Account> computeStaticAccounts()
protected List<org.apache.james.fetchmail.FetchMail.ParsedDynamicAccountParameters> computeParsedDynamicAccountParameters()
protected Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> computeDynamicAccounts() throws org.apache.commons.configuration.ConfigurationException
org.apache.commons.configuration.ConfigurationException
protected Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> getDynamicAccounts() throws org.apache.commons.configuration.ConfigurationException
org.apache.commons.configuration.ConfigurationException
protected void setDynamicAccounts(Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> dynamicAccounts)
dynamicAccounts
- The dynamicAccounts to setprotected Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> computeDynamicAccounts(Map<org.apache.james.fetchmail.FetchMail.DynamicAccountKey,DynamicAccount> oldAccounts, org.apache.james.fetchmail.FetchMail.ParsedDynamicAccountParameters parameters) throws org.apache.commons.configuration.ConfigurationException
oldAccounts
- parameters
- org.apache.commons.configuration.ConfigurationException
protected void resetDynamicAccounts()
protected List<org.apache.james.fetchmail.FetchMail.ParsedDynamicAccountParameters> getParsedDynamicAccountParameters()
protected void setParsedDynamicAccountParameters(List<org.apache.james.fetchmail.FetchMail.ParsedDynamicAccountParameters> parsedDynamicAccountParameters)
parsedDynamicAccountParameters
- The ParsedDynamicAccountParameters to setprotected javax.mail.Session getSession()
protected javax.mail.Session computeSession()
protected void updateSession()
protected void setSession(javax.mail.Session session)
session
- The session to setprotected void setSessionParameters(org.apache.commons.configuration.HierarchicalConfiguration configuration) throws org.apache.commons.configuration.ConfigurationException
configuration
- The configuration containing the parametersorg.apache.commons.configuration.ConfigurationException
public void setMailQueue(MailQueue queue)
public MailQueue getMailQueue()
public void setDomainList(DomainList domainList)
public DomainList getDomainList()
Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.