commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Gillen" <paul.d.gil...@gmail.com>
Subject [VFS] How-to? FileListener
Date Sat, 09 Jun 2007 17:32:31 GMT
Trying to use FileListener in an initialization servlet without success.

 

        File                configurationFile       = new
File(configurationFileUrl.getFile());

        FileSystemManager   fsMgr                   = VFS.getManager();

        FileObject          fileObject              =
fsMgr.toFileObject(configurationFile);

        FileSystem          fileSystem              =
fileObject.getFileSystem();

        FileListener        fileListener            = new fListener();

        

        fileSystem.addListener(fileObject, fileListener);

        

        log.info("Add listener for file: "+fileObject.getName());

        log.info("\ttype: "+fileObject.getType());

        log.info("\texists:"+fileObject.exists());

 
log.info("\tLastModTimeAccuracy:"+fileSystem.getLastModTimeAccuracy());

        

        // testing listener only

        configurationFile.delete();

 

fListener is pretty dumb:

 

    public class fListener

    implements FileListener

    {

        private Log flLog = null;

        

        fListener()

        {

            flLog     = LogFactory.getLog(this.getClass());

            flLog.info("created: "+this.getClass());

        }

        public void fileChanged(FileChangeEvent fcEvt)

        throws Exception

        {

            flLog.info("fileChanged: "+fcEvt.getFile().getName());

            initParameters();

        }

        public void fileDeleted(FileChangeEvent fcEvt)

        throws Exception

        {

            flLog.info("fileDeleted: "+fcEvt.getFile().getName());

            // ignore

        }

        public void fileCreated(FileChangeEvent fcEvt)

        throws Exception

        {

            flLog.info("fileCreated: "+fcEvt.getFile().getName());

            initParameters();

        }

    }

 

The output from "fileObject.exists())" shows the file exists.  I'm getting
the message out of fListener constructor but not from "fileDeleted()" when
"configurationFile.delete()" is invoked.

 

Also at various points a tutorial and samples for VFS have been discussed;
haven't been able to find 'em.

 

=Paul=

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message