FileDocCategorySizeDatePackage
FetchScheduler.javaAPI DocApache James 2.3.15661Fri Jan 12 12:56:24 GMT 2007org.apache.james.fetchmail

FetchScheduler

public class FetchScheduler extends org.apache.avalon.framework.logger.AbstractLogEnabled implements org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, FetchSchedulerMBean
A class to instantiate and schedule a set of mail fetching tasks $Id: FetchScheduler.java 494012 2007-01-08 10:23:58Z norman $
see
org.apache.james.fetchmail.FetchMailOriginal#configure(Configuration) FetchMailOriginal

Fields Summary
private org.apache.avalon.framework.configuration.Configuration
conf
Configuration object for this service
private org.apache.avalon.framework.service.ServiceManager
m_manager
The service manager that allows access to the system services
private org.apache.avalon.cornerstone.services.scheduler.TimeScheduler
scheduler
The scheduler service that is used to trigger fetch tasks.
private volatile boolean
enabled
Whether this service is enabled.
private ArrayList
theFetchTaskNames
Constructors Summary
Methods Summary
public voidconfigure(org.apache.avalon.framework.configuration.Configuration conf)

see
org.apache.avalon.framework.configuration.Configurable#configure(Configuration)

        this.conf = conf;
    
public voiddispose()

see
org.apache.avalon.framework.activity.Disposable#dispose()

        if (enabled)
        {
            getLogger().info("FetchMail dispose...");
            Iterator nameIterator = theFetchTaskNames.iterator();
            while (nameIterator.hasNext())
            {
                scheduler.removeTrigger((String) nameIterator.next());
            }
            getLogger().info("FetchMail ...dispose end");
        }
    
public voidinitialize()

see
org.apache.avalon.framework.activity.Initializable#initialize()

        enabled = conf.getAttributeAsBoolean("enabled", false);
        if (enabled)
        {
            scheduler = (TimeScheduler) m_manager.lookup(TimeScheduler.ROLE);
            Configuration[] fetchConfs = conf.getChildren("fetch");
            for (int i = 0; i < fetchConfs.length; i++)
            {
                FetchMail fetcher = new FetchMail();
                Configuration fetchConf = fetchConfs[i];
                String fetchTaskName = fetchConf.getAttribute("name");
                ContainerUtil.enableLogging(fetcher,getLogger().getChildLogger(fetchTaskName));
                ContainerUtil.service(fetcher,m_manager);
                ContainerUtil.configure(fetcher,fetchConf);
                Integer interval =
                    new Integer(fetchConf.getChild("interval").getValue());
                PeriodicTimeTrigger fetchTrigger =
                    new PeriodicTimeTrigger(0, interval.intValue());

                scheduler.addTrigger(fetchTaskName, fetchTrigger, fetcher);
                theFetchTaskNames.add(fetchTaskName);
            }

            if (getLogger().isInfoEnabled())
                getLogger().info("FetchMail Started");
            System.out.println("FetchMail Started");
        }
        else
        {
            if (getLogger().isInfoEnabled())
                getLogger().info("FetchMail Disabled");
            System.out.println("FetchMail Disabled");
        }
    
public final booleanisEnabled()
Describes whether this service is enabled by configuration.

return
is the service enabled.

        return enabled;
    
public voidservice(org.apache.avalon.framework.service.ServiceManager comp)

see
org.apache.avalon.framework.service.Serviceable#service( ServiceManager )


             
         
    
        m_manager = comp;