⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fetchscheduler.java

📁 java 开发的邮件服务器平台。支持以下协议。 协议可以修改为自己的专门标识
💻 JAVA
字号:
/*********************************************************************** * Copyright (c) 2000-2004 The Apache Software Foundation.             * * All rights reserved.                                                * * ------------------------------------------------------------------- * * Licensed under the Apache License, Version 2.0 (the "License"); you * * may not use this file except in compliance with the License. You    * * may obtain a copy of the License at:                                * *                                                                     * *     http://www.apache.org/licenses/LICENSE-2.0                      * *                                                                     * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS,   * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     * * implied.  See the License for the specific language governing       * * permissions and limitations under the License.                      * ***********************************************************************/package org.apache.james.fetchpop;import org.apache.avalon.cornerstone.services.scheduler.PeriodicTimeTrigger;import org.apache.avalon.cornerstone.services.scheduler.TimeScheduler;import org.apache.avalon.framework.activity.Disposable;import org.apache.avalon.framework.activity.Initializable;import org.apache.avalon.framework.component.Component;import org.apache.avalon.framework.component.ComponentException;import org.apache.avalon.framework.component.ComponentManager;import org.apache.avalon.framework.component.Composable;import org.apache.avalon.framework.component.DefaultComponentManager;import org.apache.avalon.framework.configuration.Configurable;import org.apache.avalon.framework.configuration.Configuration;import org.apache.avalon.framework.configuration.ConfigurationException;import org.apache.avalon.framework.logger.AbstractLogEnabled;import org.apache.james.services.MailServer;import java.util.ArrayList;import java.util.Iterator;/** *  A class to instantiate and schedule a set of POP mail fetching tasks<br> * <br>$Id: FetchScheduler.java,v 1.4.4.4 2004/03/15 03:54:16 noel Exp $ *  @see org.apache.james.fetchpop.FetchPOP#configure(Configuration) FetchPOP *   */public class FetchScheduler    extends AbstractLogEnabled    implements Component, Composable, Configurable, Initializable, Disposable, FetchSchedulerMBean {    /**     * Configuration object for this service     */    private Configuration conf;    /**     * The component manager that allows access to the system services     */    private ComponentManager compMgr;    /**     * The scheduler service that is used to trigger fetch tasks.     */    private TimeScheduler scheduler;    /**     * Whether this service is enabled.     */    private volatile boolean enabled = false;    private ArrayList theFetchTaskNames = new ArrayList();    /**     * @see org.apache.avalon.framework.component.Composable#compose(ComponentManager)     */    public void compose(ComponentManager comp) throws ComponentException {        compMgr = comp;    }    /**     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)     */    public void configure(Configuration conf) throws ConfigurationException {        this.conf = conf;    }    /**     * @see org.apache.avalon.framework.activity.Initializable#initialize()     */    public void initialize() throws Exception {        enabled = conf.getAttributeAsBoolean("enabled", false);        if (enabled) {            scheduler = (TimeScheduler) compMgr.lookup(TimeScheduler.ROLE);            Configuration[] fetchConfs = conf.getChildren("fetch");            for (int i = 0; i < fetchConfs.length; i++) {                FetchPOP fp = new FetchPOP();                Configuration fetchConf = fetchConfs[i];                String fetchTaskName = fetchConf.getAttribute("name");                fp.enableLogging(getLogger().getChildLogger(fetchTaskName));                fp.compose(compMgr);                fp.configure(fetchConf);                Integer interval = new Integer(fetchConf.getChild("interval").getValue());                PeriodicTimeTrigger fetchTrigger = new PeriodicTimeTrigger(0, interval.intValue());                scheduler.addTrigger(fetchTaskName, fetchTrigger, fp);                theFetchTaskNames.add(fetchTaskName);            }            getLogger().info("Fetch POP Started");            System.out.println("Fetch POP Started ");        } else {            getLogger().info("Fetch POP Disabled");            System.out.println("Fetch POP Disabled");        }    }    /**     * @see org.apache.avalon.framework.activity.Disposable#dispose()     */    public void dispose() {        if (enabled) {            getLogger().info( "Fetch POP dispose..." );            Iterator nameIterator = theFetchTaskNames.iterator();            while (nameIterator.hasNext()) {                scheduler.removeTrigger((String)nameIterator.next());            }            getLogger().info( "Fetch POP ...dispose end" );        }    }    /**     * Describes whether this service is enabled by configuration.     *     * @return is the service enabled.     */    public final boolean isEnabled() {        return enabled;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -