亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? directorypoller.java

?? 一個簡易的輪訓小程序 哈哈哈哈哈哈后 嘿嘿嘿嘿黑誒
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
package org.sadun.util.polling;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.sadun.util.BidirectionalComparator;
import org.sadun.util.PathNormalizer;
import org.sadun.util.Terminable;

import com.deltax.util.listener.BaseSignalSourceThread;
import com.deltax.util.listener.ExceptionSignal;

/**
 * A Thread class to periodically poll the contents of one or more directories.
 * External asynchronous processes may put some files in one of the controlled directories,
 * and the poller can be used to detect their arrival.
 * <p>
 * Once started, this thread polls one or more directories every <i>x</i> milliseconds,
 * (see {@link DirectoryPoller#setPollInterval(long) setPollInterval()} and
 * {@link DirectoryPoller#getPollInterval() getPollInterval()}), looking for new files
 * satisfying a  given filter.
 * <br>Optionally, the thread may start by going to sleep (if
 * {@link DirectoryPoller#setStartBySleeping(boolean) setStartBySleeping()} is invoked).
 * <p>
 * To communicate results, the thread notifies events to any registered listener (see
 * below). Notably, if any files are "found", a {@link FileSetFoundEvent FileSetFoundEvent}
 * event is notified.
 * <p>
 * A {@link java.io.FilenameFilter java.io.FilenameFilter} can be provided at construction to identify the files to
 * look for. Besides, the poller can be set to run in two different time-based filtering modes (disabled by
 * default), which select only files satisfying the user-given filter and
 * <p>
 * <ul>
 * <li> whose <i>last modification time</i><a href="#note"><sup>*</sup></a> (<b>LMF</b>) is greater
 * than the time of the last polling <i>(default)</i>
 * <p><font size=-1>(Only files added to the directory after the last polling pass are selected)</font>
 * <p><i>or</i><p>
 * <li> whose <b>LMF</b> is greater than the higher <b>LMF</b> rilevated in
 * the file set selected in the last polling pass (or 0 for the first pass).
 * <p><font size=-1>(Only files which are newer than the newer file already polled are selected)</font>
 * </ul>
 * <p>
 * Use {@link DirectoryPoller#setTimeBased(boolean) setTimeBased()} and {@link
 * DirectoryPoller#isTimeBased() isTimeBased()} to enable the time-based mode and
 * {@link DirectoryPoller#setPollingTimeBased(boolean) setPollingTimeBased()}
 * and {@link DirectoryPoller#isPollingTimeBased() isPollingTimeBased()} to
 * select the specific subtype of time-based mode.
 * <p>
 * Without time-based mode, on every pass the poller will select <i>all</i> the files
 * in a controlled directory that match the filter, so it's client code responsability
 * to phisically move the files already processed somewhere else (see also the
 * <a href="#automove">automove</a> mode below).
 * <p>
 * The poller always notifies an event for a set of file discovered in a particular
 * directory. It may optionally notify a separate event for each file (see {@link
 * DirectoryPoller#setSendSingleFileEvent(boolean) setSendSingleFileEvent()} and
 * {@link DirectoryPoller#isSendSingleFileEvent() isSendSingleFileEvent()}).
 * <p>
 * The following events (all time-stamped) are produced:
 * <ul>
 * <li> {@link CycleStartEvent CycleStartEvent}
 * <br> The poller has awaken, and is starting to look in the directory set
 * <li> {@link DirectoryLookupStartEvent DirectoryLookupStartEvent}
 * <br> The poller is starting to look into a specific directory
 * <li> {@link FileSetFoundEvent FileSetFoundEvent}
 * <br> The poller has found some files in a directory, which match the polling criteria
 * <li> {@link FileFoundEvent FileFoundEvent} (<i>optional</i>)
 * <br> The poller has found one file in a directory, which match the polling criteria
 * <li> {@link DirectoryLookupEndEvent DirectoryLookupStartEvent}
 * <br> The poller has finished to look a specific directory
 * <li> {@link CycleEndEvent CycleEndEvent}
 * <br> The poller has finished to look in the directory set, and is going to sleep
 * </ul>
 * <p>
 * Any object implementing the {@link com.deltax.util.lf.Listener com.deltax.Listener} interface
 * can be registered and be notified of these events. However, a predefined listener,
 * {@link DefaultListener DefaultListener} is provided, which dispatches events to an object
 * implementing the {@link PollManager PollManager} interface, and a base
 * implementation of {@link PollManager PollManager}, {@link BasePollManager
 * BasePollManager} is provided as well.
 * <p>
 * The simplest way to receive events from the poller is therefore to create a class
 * extending {@link BasePollManager BasePollManager} overriding the proper
 * method(s) and register it to the directory poller by using
 * {@link DirectoryPoller#addPollManager(PollManager) addPollManager()}.
 * <p>
 * The order in which file events are received can be controlled by providing a
 * {@link java.util.Comparator} object which assigns an order to the file sets
 * read on each cycle and assigning it by {@link #setFilesSortComparator(Comparator)}.
 * By default, no order is imposed, i.e. the file events will be fired in an arbitrary 
 * order, depending on the operating system. (Two pre-packaged comparators 
 * {@link DirectoryPoller.ModificationTimeComparator} 
 * and {@link DirectoryPoller.FileSizeComparator} are provided by this class). 
 * <p>
 * <i>Note</i>: listeners will receive events <b><i>asynchronously</i></b> with respect
 * to the poller thread.
 * Therefore, if file processing is performed without moving the file out of the polled
 * directory, the polling interval should be big enough to allow such processing to
 * complete, or the same file may be notified more than once (expecially if time-based
 * polling is disabled).
 * <a name="automove"><p>
 * The version 1.2 of the class adds a new runtime mode - the <b>autoMove</b> mode.
 * When running in this mode, the poller automatically moves all the files found
 * in a controlled directory to an associated directory (which is <i>not</i> polled)
 * <i>before</i> notifying the listeners and/or the pollmanager. The events notified will
 * refer to the <i>new</i> location of the file.
 * <p>
 * This allows the user to set very short polling periods while ensuring that even slow
 * file processing will not cause the same file to be polled more than once (even if the
 * time-based polling mode is disabled).
 * <p>
 * If any exception occurs during the move operation, the relevant methods
 * of {@link PollManager PollManager} are invoked (as a consequence of the notification
 * of an underlying {@link com.deltax.util.listener.ExceptionSignal
 * com.deltax.util.listener.ExceptionSignal}).
 * <p>
 * If autoMove mode is enabled (see {@link DirectoryPoller#setAutoMove(boolean) setAutoMove()})
 * an arbitary directory may be explicitly associated to one of the controlled directories
 * by using {@link DirectoryPoller#setAutoMoveDirectory(java.io.File, java.io.File)
 * setAutoMoveDirectory()}.
 * <p>
 * If autoMove mode is enabled and the byPassLockedFiles property is true (defaults to false), 
 * locked files will be ignored. Otherwise, an exception signal will be raised if any file found in 
 * the controlled directory is locked.
 * <p>
 * If not, the poller will automatically associate to each
 * controlled directory a subdirectory whose name is defined by the public constant
 * {@link DirectoryPoller#DEFAULT_AUTOMOVE_DIRECTORY
 * DirectoryPoller.DEFAULT_AUTOMOVE_DIRECTORY}. The poller will attempt to create
 * the associated directory, if necessary - and on failure, an ExceptionSignal is
 * sent to the listeners, and the poller shuts down.
 * <p>
 * Note that ExceptionSignals are sent only when the auto-move mode is enabled.
 * </a>
 * <p>
 * <a name="note">(*) as returned by <tt>File.lastModified()</tt>.</a>
 *
 * @author C. Sadun (patched by Doug.Liao@fnf.com)
 * @version 1.4.4
 */
public class DirectoryPoller extends BaseSignalSourceThread implements Terminable {


    /**
     * An exception raised by the poller when auto-move mode is enabled,
     * but the move operation failed.
     */
    public class AutomoveException extends Exception {

        private File origin;
        private File dest;

        AutomoveException(File origin, File dest, String msg) {
            super(msg);
            this.origin=origin;
            this.dest=dest;
            if (verbose)
                System.out.println("[Automove] Exception: "+msg);
        }

        /**
         * Return the poller associated to this exception.
         * @return the poller associated to this exception.
         */
        public DirectoryPoller getPoller() { return DirectoryPoller.this; }

        /**
         * Return the file to be moved
         * @return the file to be moved
         */
        public File getOrigin() { return origin; }

        /**
         * Return the destination file
         * @return the destination file
         */
        public File getDestination() { return dest; }
    }

    /**
     * An exception raised by the poller when auto-move mode is enabled,
     * but the target file of the move operation exists and cannot be
     * deleted.
     */
    public class AutomoveDeleteException extends AutomoveException {
        AutomoveDeleteException(File origin, File dest, String msg) {
            super(origin, dest, msg);
        }
    }

    /**
     * The name of subdirectory automatically associated by the poller to any controlled
     * directory for the autoMode mode, unless {@link DirectoryPoller#setAutoMoveDirectory(java.io.File,
     * java.io.File) setAutoMoveDirectory()} is explicitly called before starting
     * the poller.
     * <p>
     * The current value is &quot;<b><tt>received</tt></b>&quot;
     */
    public static final String DEFAULT_AUTOMOVE_DIRECTORY = "received";

    private static int counter=0;
    private volatile boolean  shutdownRequested = false;
    private FilenameFilter filter;
    private File[]dirs;
    private long[] baseTime;

    private boolean verbose=( System.getProperty("org.sadun.verbose") != null);
    private boolean timeBasedOnLastLookup=true;

	protected List pollManagersList = new ArrayList();

    private boolean autoMove=false;
    private Map autoMoveDirs = new HashMap();

    private FilenameFilter originalFilter;
    private long pollInterval = 10000;
    private boolean startBySleeping=false;
    private boolean sendSingleFileEvent=false;

    private int currentDir=-1;

    private Comparator filesSortComparator = null;

    private boolean bypassLockedFiles = false;

    private volatile boolean sleeping=false;

    private volatile boolean debugExceptions;
      
    private static class DirectoryFilter implements FilenameFilter {

        FilenameFilter additionalFilter;

        DirectoryFilter(FilenameFilter additionalFilter) {
            this.additionalFilter=additionalFilter;
        }


        public boolean accept(File dir, String name) {
            if (new File(dir, name).isDirectory()) return false;
            return additionalFilter.accept(dir, name);
        }

        public String toString() {
            return "Directory filter over a "+additionalFilter;
        }
        
        FilenameFilter getAdditionalFilter() { return additionalFilter; }

    }

    private class TimeFilter implements FilenameFilter {

        private FilenameFilter additionalFilter;

        public TimeFilter(FilenameFilter additionalFilter) {
            this.additionalFilter=additionalFilter;
        }

        public boolean accept(File dir, String name) {
            File f = new File(dir,name);
            if (f.isDirectory()) return false;
            if (f.lastModified() <= baseTime[currentDir]) {
                if (verbose)
                    System.out.println(name+"("+f.lastModified()+"): out of base time ("+baseTime[currentDir]+"), ignoring");
                return false;
            } else {
                if (verbose)
                    System.out.println(name+"("+f.lastModified()+"): older than base time ("+baseTime[currentDir]+"), accepted");
            }

            return additionalFilter.accept(dir, name);
        }
    }

    public static final class NullFilenameFilter implements FilenameFilter {
        public boolean accept(File dir, String name) { return true; }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲美女偷拍久久| 久久99热这里只有精品| 国产午夜亚洲精品不卡| 欧美国产激情一区二区三区蜜月| 国产精品久久久久久久裸模 | 亚洲成人av电影| 国产麻豆精品视频| www.亚洲在线| 欧美日韩午夜影院| 26uuu亚洲综合色| 亚洲小少妇裸体bbw| 久久精品久久99精品久久| 黑人巨大精品欧美一区| 欧美日韩在线亚洲一区蜜芽| 久久久久国色av免费看影院| 天天色综合成人网| 99re这里只有精品首页| 91精品国产欧美一区二区| 亚洲色图欧美激情| 99视频在线观看一区三区| 亚洲精品在线三区| 美日韩黄色大片| 欧美三区在线视频| 国产一区二区三区在线观看精品 | 欧美日韩视频在线第一区| 国产色91在线| 国产露脸91国语对白| 日韩手机在线导航| 日精品一区二区三区| 日韩午夜在线观看视频| 日韩专区中文字幕一区二区| 欧美日韩精品一区二区在线播放| 亚洲狠狠丁香婷婷综合久久久| 福利一区福利二区| 国产精品久久久久久久久搜平片 | 欧美久久久久久久久久 | 日韩欧美电影在线| 精品一区二区三区蜜桃| 国产精品国产三级国产aⅴ入口| 国产日产欧美一区二区三区| 蜜乳av一区二区三区| 亚洲欧美一区二区三区国产精品| 韩国欧美一区二区| 欧美mv日韩mv国产| 偷拍日韩校园综合在线| 国产精品国产三级国产有无不卡| 国产激情视频一区二区在线观看| 日韩中文欧美在线| 亚洲一区二区三区四区在线| 亚洲高清免费观看高清完整版在线观看| 国产农村妇女毛片精品久久麻豆 | 亚洲午夜视频在线观看| 欧美性受xxxx黑人xyx性爽| 亚洲一区免费视频| 日韩一级大片在线观看| 国产成人午夜片在线观看高清观看| 26uuu国产电影一区二区| 国产一区二区按摩在线观看| 中文字幕精品一区二区精品绿巨人| 国产福利精品导航| 一个色综合网站| 国产免费观看久久| 欧美一区二区三区思思人| 成人天堂资源www在线| 亚洲一区二区三区激情| 精品一区二区久久| 日韩欧美成人一区| 一本色道**综合亚洲精品蜜桃冫| 1区2区3区精品视频| 亚洲日本一区二区| 久久久精品一品道一区| 在线观看视频91| 欧美视频日韩视频在线观看| caoporen国产精品视频| 久久99久久久欧美国产| 久久99精品国产.久久久久| 亚洲高清中文字幕| 亚洲激情综合网| 午夜伊人狠狠久久| 亚洲国产欧美另类丝袜| 亚洲一区在线电影| 日韩高清一区在线| 亚洲超碰97人人做人人爱| 亚洲一区二区三区四区五区中文| 亚洲制服丝袜一区| 日韩成人免费电影| 麻豆91在线播放免费| 国产成人精品亚洲日本在线桃色 | 国产成人一级电影| 欧美日韩成人一区二区| 337p亚洲精品色噜噜狠狠| 成人网页在线观看| 国产成人啪午夜精品网站男同| 国产精品久久久久久久久晋中 | 欧美精三区欧美精三区| 精品乱人伦一区二区三区| 国产欧美日韩麻豆91| 首页国产欧美久久| 在线免费观看成人短视频| 国产性做久久久久久| 免费欧美日韩国产三级电影| 91一区二区在线| 国产视频一区不卡| 久久国内精品自在自线400部| jlzzjlzz亚洲日本少妇| 久久综合久久综合亚洲| 国产精品一卡二卡| 国产色一区二区| www.色精品| 亚洲女爱视频在线| 在线视频一区二区三| 亚洲福利国产精品| 精品黑人一区二区三区久久| 开心九九激情九九欧美日韩精美视频电影 | 国产片一区二区| 国产经典欧美精品| 亚洲人成网站在线| 日韩欧美一区二区不卡| 国产91精品精华液一区二区三区| 亚洲视频中文字幕| 91精品国产美女浴室洗澡无遮挡| 精品一区二区三区久久| 亚洲黄一区二区三区| 日韩欧美一级二级三级久久久| 国产91在线观看丝袜| 亚洲gay无套男同| 国产精品久久久一本精品| 日韩色在线观看| 精品视频一区三区九区| www.爱久久.com| 成人爽a毛片一区二区免费| 婷婷成人激情在线网| 一区二区三区中文字幕在线观看| 91精品蜜臀在线一区尤物| 91亚洲精品乱码久久久久久蜜桃 | 欧美国产日韩一二三区| 国产一区二区三区四区五区美女 | 91久久人澡人人添人人爽欧美| 一区二区视频免费在线观看| av一区二区久久| 亚洲免费观看高清完整版在线| 欧美又粗又大又爽| 粉嫩av亚洲一区二区图片| 亚洲一线二线三线视频| 国产三级久久久| 国产亚洲成年网址在线观看| 久久久久久久久久久久久女国产乱| 欧美日韩美少妇| 欧美日韩一二区| 亚洲精品一区二区三区影院| 欧美v国产在线一区二区三区| 欧美一区二区三区视频免费| 26uuu国产电影一区二区| 国产精品私房写真福利视频| 国产精品丝袜一区| 一区二区三区中文在线观看| 亚洲在线观看免费视频| 看片的网站亚洲| 99r国产精品| 精品日韩av一区二区| 欧美国产视频在线| 亚洲一区二区三区爽爽爽爽爽| 麻豆国产91在线播放| 99国产欧美久久久精品| 9191国产精品| 中文字幕一区av| 欧美96一区二区免费视频| 成人在线视频首页| 精品美女在线观看| 日韩欧美国产一二三区| 国产精品理伦片| 久草这里只有精品视频| 色先锋资源久久综合| 久久久久一区二区三区四区| 亚洲午夜在线视频| 99久久久久久| 国产精品伦理在线| 国产精品18久久久久久vr| 欧美日韩激情在线| 亚洲激情男女视频| 欧美日韩aaaaa| 2020国产成人综合网| 国产精品一卡二卡| 欧美国产激情一区二区三区蜜月| 久久精工是国产品牌吗| 在线91免费看| 久久se精品一区精品二区| 精品卡一卡二卡三卡四在线| 麻豆视频观看网址久久| 欧美zozo另类异族| 久久狠狠亚洲综合| 精品国产3级a| 91在线观看视频| 日韩国产一区二| 久久精品欧美日韩精品| 成人影视亚洲图片在线| 一区二区三区视频在线看| 在线日韩av片| 国产一区二区免费看| 国产精品白丝在线|