Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

jreceiver.server.scanner
Class ScannerDaemon  view ScannerDaemon download ScannerDaemon.java

java.lang.Object
  extended byjreceiver.util.Daemon
      extended byjreceiver.util.ScheduledDaemon
          extended byjreceiver.server.scanner.ScannerDaemon

public final class ScannerDaemon
extends jreceiver.util.ScheduledDaemon

Daemon to scan the root folders for audio files and update the database. Report status to listeners. synchronize database with audio files on disk

For each dir in path:

  • get list of files from db
  • get list of files from disk
  • update records where file exists and where date is newer
  • delete records where file is missing
  • add records for new files

    Runs as a background worker thread.

    Provides progress messages via XML-RPC.

    Version:
    $Revision: 1.23 $ $Date: 2003/05/16 08:40:01 $

    Field Summary
    (package private) static org.apache.commons.logging.Log log
              logging object
    (package private)  jreceiver.server.bus.FolderBus m_fldr_bus
               
    (package private)  FolderFileFilter m_folder_filter
               
    (package private)  jreceiver.server.bus.MfileBus m_mfile_bus
               
    (package private)  jreceiver.server.bus.MimeBus m_mime_bus
               
    (package private)  jreceiver.server.bus.PlaylistBus m_pl_bus
               
    (package private)  PlaylistFileFilter m_playlist_filter
               
    (package private)  jreceiver.server.bus.RootBus m_root_bus
               
    (package private)  jreceiver.server.util.builder.SourceBuilder m_source_builder
               
    (package private)  jreceiver.server.bus.SourceBus m_src_bus
               
    (package private)  jreceiver.server.bus.TuneBus m_tune_bus
               
    (package private)  TuneFileFilter m_tune_filter
               
    (package private) static ScannerDaemon singleton
              this class is implemented as a singleton
    (package private)  java.lang.String state
              the present state of the scanner
     
    Fields inherited from class jreceiver.util.ScheduledDaemon
    next_execution_time, schedule_period, timer
     
    Fields inherited from class jreceiver.util.Daemon
    thread_name, worker_thread
     
    Constructor Summary
    (package private) ScannerDaemon()
              ctor
     
    Method Summary
    (package private)  void abortIfIntolerant()
              throw a BusException if the user has configured the scanner as 'Intolerant' of errors.
    protected  void doWork()
              the work done in the worker thread
    static ScannerDaemon getInstance()
              Obtain the instance of the ScannerDaemon singleton
     java.lang.String getState()
              obtain the current state of the scanner
    (package private)  void refreshPlaylistStats()
              assign a fresh tunecount and duration to each playlist
    (package private)  void scanCurrent(java.io.File root_folder, java.io.File current_folder, int src_type)
              search for tunes in the specified folder and add them to the database
    (package private)  int scanFile(int folder_id, java.io.File child, java.util.Map referenced)
              add file if not present in database; otherwise update if changed
    (package private)  void scanFilesForCurrent(java.io.File current_folder, int folder_id, int src_type)
              scan tunes (or playlists) for the current folder
    (package private)  void scanFoldersForCurrent(java.io.File root_folder, java.io.File current_folder, int folder_id, int src_type)
              scan subfolders for the current folder
    (package private)  void scanForMode(int src_type)
              Scan for tunes or playlists.
     
    Methods inherited from class jreceiver.util.ScheduledDaemon
    getSchedule, scheduleAtFixedRate, scheduleCancel
     
    Methods inherited from class jreceiver.util.Daemon
    makeThread, sleep, start, stop, stopping
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    m_fldr_bus

    jreceiver.server.bus.FolderBus m_fldr_bus

    m_mfile_bus

    jreceiver.server.bus.MfileBus m_mfile_bus

    m_mime_bus

    jreceiver.server.bus.MimeBus m_mime_bus

    m_pl_bus

    jreceiver.server.bus.PlaylistBus m_pl_bus

    m_root_bus

    jreceiver.server.bus.RootBus m_root_bus

    m_src_bus

    jreceiver.server.bus.SourceBus m_src_bus

    m_tune_bus

    jreceiver.server.bus.TuneBus m_tune_bus

    m_source_builder

    jreceiver.server.util.builder.SourceBuilder m_source_builder

    m_tune_filter

    TuneFileFilter m_tune_filter

    m_playlist_filter

    PlaylistFileFilter m_playlist_filter

    m_folder_filter

    FolderFileFilter m_folder_filter

    state

    java.lang.String state
    the present state of the scanner


    singleton

    static ScannerDaemon singleton
    this class is implemented as a singleton


    log

    static org.apache.commons.logging.Log log
    logging object

    Constructor Detail

    ScannerDaemon

    ScannerDaemon()
    ctor

    Method Detail

    getInstance

    public static ScannerDaemon getInstance()
    Obtain the instance of the ScannerDaemon singleton

    Note that this uses the questionable DCL pattern (search on DoubleCheckedLockingIsBroken for more info)

    Note that the instance method must be called once with a valid status port before the singleton is created.


    getState

    public java.lang.String getState()
    obtain the current state of the scanner


    doWork

    protected void doWork()
    the work done in the worker thread

    search for tunes starting at the specified root and add them to the database

    examine a file or recurse a directory, adding tunes and playlists and some of their metadata to the database

    set up a callback to enumerate all root folders and scan each one.


    scanForMode

    void scanForMode(int src_type)
               throws java.io.IOException,
                      jreceiver.server.bus.BusException
    Scan for tunes or playlists.


    scanCurrent

    void scanCurrent(java.io.File root_folder,
                     java.io.File current_folder,
                     int src_type)
               throws jreceiver.server.bus.BusException,
                      java.io.IOException
    search for tunes in the specified folder and add them to the database

    examine a file or recurse a directory, adding tunes and playlists and some of their metadata to the database


    scanFoldersForCurrent

    void scanFoldersForCurrent(java.io.File root_folder,
                               java.io.File current_folder,
                               int folder_id,
                               int src_type)
                         throws java.io.IOException,
                                jreceiver.server.bus.BusException
    scan subfolders for the current folder


    scanFilesForCurrent

    void scanFilesForCurrent(java.io.File current_folder,
                             int folder_id,
                             int src_type)
                       throws java.io.IOException,
                              jreceiver.server.bus.BusException
    scan tunes (or playlists) for the current folder


    scanFile

    int scanFile(int folder_id,
                 java.io.File child,
                 java.util.Map referenced)
           throws jreceiver.server.bus.BusException
    add file if not present in database; otherwise update if changed


    abortIfIntolerant

    void abortIfIntolerant()
                     throws jreceiver.server.bus.BusException
    throw a BusException if the user has configured the scanner as 'Intolerant' of errors.


    refreshPlaylistStats

    void refreshPlaylistStats()
                        throws jreceiver.server.bus.BusException
    assign a fresh tunecount and duration to each playlist