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

📄 jahiafilewatcherbaseservice.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .////////  JahiaFileWatcherBaseService////  NK      12.01.2001////package org.jahia.services.deamons.filewatcher;import java.io.*;import java.text.*;import java.util.*;import org.jahia.tools.files.*;       // FileWatcherimport org.jahia.exceptions.*;  // JahiaExceptionimport org.jahia.utils.*;       // JahiaConsoleimport org.jahia.services.*;    // JahiaService/** * This Service hold a pool of instance of jahia.tools.FileWatcher Class.  * Each Thread are identified by a name and accessible through this name. * Threads are added in an Hashtable registry. *  * @author Khue ng * @version 1.0 */public class JahiaFileWatcherBaseService extends JahiaFileWatcherService {   /** The singelton instance of this class **/   private static JahiaFileWatcherBaseService m_Instance = null;      /** The Pool of Threads *    * @associates FileWatcher*/   private Hashtable m_Registry;   /**     * Protected Constructor    *    */    protected JahiaFileWatcherBaseService(){      JahiaConsole.println( "JahiaFileWatcherBaseService",       						"***** Starting the Jahia File Watcher Base Service *****" );      m_Registry = new Hashtable();    }   /**    * Use this method to get an instance of this class    *    */      public static synchronized JahiaFileWatcherBaseService getInstance(){         if ( m_Instance == null ){         m_Instance = new JahiaFileWatcherBaseService();      }      return m_Instance;   }      /**    * addFileWatcher    *    * @param (String) threadName, the Name to identify this thread    * @param (String) fullFolderPath, the real path to the folder to watch    * @param (boolean) checkDate, check new file by last modif date or not    * @param (long) interval, the interval in millis    */   public synchronized void addFileWatcher(	String threadName,                                			String fullFolderPath,                                 			boolean checkDate,                                           			long interval,                                			boolean fileOnly                              				) throws JahiaException {         try {                        FileWatcher fw = new FileWatcher( fullFolderPath,                                           checkDate,                                           interval,                                           fileOnly );            m_Registry.put(threadName,fw);            //fw.start();         } catch ( IOException e ) {            JahiaConsole.println("JahiaFileWatcherBaseService","addFileWatcher:: " + e.getMessage() );            throw new JahiaException ("JahiaFileWatcherBaseService", "failed adding File Watcher",                                    JahiaException.SERVICE_ERROR, JahiaException.WARNING);         }     }      /**    * Call the start method of the thread    * @param (String) threadName, the Name to identify this thread    */   public void startFileWatcher(  String threadName ) throws JahiaException{            try {                  synchronized(this){                     getFileWatcher(threadName).start();         }                  } catch ( IOException e ) {         JahiaConsole.println("JahiaFileWatcherBaseService","startFileWatcher:: " + e.getMessage() );         throw new JahiaException ("JahiaFileWatcherBaseService", "failed starting File Watcher",                                    JahiaException.SERVICE_ERROR, JahiaException.WARNING);      }   }   /**    * Register an Observer Thread with an Observable Thread    *    * @param (String) threadName, the Name of Observable object     * @param (Observer) the observer object    */   public void registerObserver( String threadName,                                 Observer obs                                 ){      synchronized(this){         getFileWatcher(threadName).addObserver(obs);               }   }   /**    * getFileWatcher    *    * @param (String) threadName, the Name to identify this thread    * @return (FileWatcher) return the FileWatcher Thread or null if    *                       not in registry    */   protected synchronized FileWatcher getFileWatcher(String threadName){            return (FileWatcher)m_Registry.get(threadName);               }   } // end JahiaFileWatcherBaseService

⌨️ 快捷键说明

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