Listening for file changes

i have a properties file. I need to monitor for the changes to the file and send intimation to all the files using the properties file. How shall i do it with out modifying the files which are executing it. i.e i need to suspend the execution of the threads and reload the values.

set up a File object that represents the props file.
   File f = new File ("propsFile");   On start up, note the lastModified() time
In a low priority thread, keep polling the lastModified() method to check if the file has been reloaded.
Set up an event handler mechanism to notify and call all interested objects that would want to take some action if and when the file's been modified.
ram.

Similar Messages

  • [svn:fx-trunk] 12481: Because of the Change/Changing changes in VideoPlayer , we need to also listen for a CHANGE as well as the CHANGE_END, CHANGE_START, THUMB_PRESS, and THUMB_RELEASE events.

    Revision: 12481
    Revision: 12481
    Author:   [email protected]
    Date:     2009-12-03 18:48:17 -0800 (Thu, 03 Dec 2009)
    Log Message:
    Because of the Change/Changing changes in VideoPlayer, we need to also listen for a CHANGE as well as the CHANGE_END, CHANGE_START, THUMB_PRESS, and THUMB_RELEASE events.
    Also, when clicking on the track and animating, the scrubbar's playedArea should move along with the thumb.  We do this by using pendingValue, rather than value in updateSkinDisplayList().
    QE notes: -
    Doc notes: -
    Bugs: SDK-24528
    Reviewer: Kevin
    Tests run: checkintests
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24528
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/VideoPlayer.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/mediaClasses/ScrubBar.as

    My first observation is that you don't reraise the error in the CATCH handler. That is bad, because it makes the proceedure fail silently which may be very difficult to troubleshoot.
    The version numbers for Change Tracking are indeed database-global. MIN_VALID_VERSION can be different for different tables, if they have different retention periods. But if they all have the same retention period, it seems likely that MIN_VALID_VERSION
    would increase as the database moves on.
    I'm not sure about your question Can we use the CHANGE_TRACKING_CURRENT_VERSION even though we want to download subset of data from the table (only records matching for one data_source_key at a time). Where would you use it? How would you use
    it?
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Event handling to listen directory file changes?

    I want to write a Java program that watches directories for changes. If there are any new files, or files are deleted in a directory, notify the user. I think this is a multi-thread program that watches files changes in specific directories. But I don't know what listener that the program should implements. please help!!

    There are no events that do what you ask (actually, there are native OS events in Win32 that do this, but I suspect that isn't what you are going for).
    You'll need to write your own event source for this (and hey, if you are feeling crazy, you could even create your own event type - FolderChangedEvent or such).
    Start a thread that wakes up periodically and checks the contents of a specified folder for changes. If there is a change, fire your event to any listeners.
    Now, how you actually define a change in a folder is an entirely different matter. It may be sufficient to calculate a CRC (or Adler32) on the modified date of all files in the folder, then compare that to a previous version to see if there has been a change.
    If you have to drop into sub-folders, you'll need to create a recursive call to do that.
    - K

  • Listener for Files?

    Hi
    is there a (kind of) Listener I can use to get notified when a File gets changed, i.e. when it's content is changed?
    Thanks for your help.

    I found an implementaion for such a kind of "File Listener" on the web. It's based on an interface and a class with inner class. Here's the linsting:
    public interface FileChangeListener
    public void fileChanged(String Filename);
    import java.io.*;
    import java.util.*;
    import java.net.*;
    public class FileMonitor
    private static final FileMonitor instance = new FileMonitor();
    private Timer timer;
    private Hashtable timerEntries;
    protected FileMonitor()
    // Create timer, run timer thread as daemon.
         timer = new Timer(true);
         timerEntries = new Hashtable();
    public static FileMonitor getInstance()
    return instance;
    /** Add a monitored file with a FileChangeListener.
    * @param listener listener to notify when the file changed.
    * @param fileName name of the file to monitor.
    * @param period polling period in milliseconds.
    public void addFileChangeListener(FileChangeListener listener, String fileName, long period) throws FileNotFoundException
    removeFileChangeListener(listener, fileName);
         FileMonitorTask task = new FileMonitorTask(listener, fileName);
         timerEntries.put(fileName + listener.hashCode(), task);
         timer.schedule(task, period, period);
    /** Remove the listener from the notification list.
    * @param listener the listener to be removed.
    public void removeFileChangeListener(FileChangeListener listener, String fileName)
    FileMonitorTask task = (FileMonitorTask) timerEntries.remove(fileName + listener.hashCode());
         if (task != null)
         task.cancel();
    protected void fireFileChangeEvent(FileChangeListener listener, String fileName)
         listener.fileChanged(fileName);
    class FileMonitorTask extends TimerTask
    FileChangeListener listener;
    String fileName;
    File monitoredFile;
         long lastModified;
    public FileMonitorTask(FileChangeListener listener, String fileName) throws FileNotFoundException
         this.listener = listener;
         this.fileName = fileName;
         this.lastModified = 0;
    monitoredFile = new File(fileName);
         if (!monitoredFile.exists())
    // but is it on CLASSPATH?
         URL fileURL = listener.getClass().getClassLoader().getResource(fileName);
              if (fileURL != null)
              monitoredFile = new File(fileURL.getFile());
              else
              throw new FileNotFoundException("File Not Found: " + fileName);
         this.lastModified = monitoredFile.lastModified();
    public void run()
         long lastModified = monitoredFile.lastModified();
         if (lastModified != this.lastModified)
         this.lastModified = lastModified;
              fireFileChangeEvent(this.listener, this.fileName);

  • Listen for Layer Changes?

    Hi
    I am looking at subscribing to network events and working out event ids and things and so far haven't been able to work out this. Fairly simple question, hopefully the answer is just as simple.
    Can I subscribe to an event which lets lets me listen for any layer changes (in my iOS app)? The docs suggest any actionable event can be listened for, but I am yet to work out how to do this.
    Thanks.

    If you're using a web front end I don't see how that's possible unless you have persistent connections and "push" technology. HTTP is a request/response protocol, which doesn't lend itself to this problem.
    If you're writing a Swing client you have a bit more control.
    Maybe one way to do it would be to use JMS publish/subscribe. When a client connects to the server, it subscribes to the database change topic. Whenever one of the registers clients makes a database change, the DAO puts a message on the topic, which is then broadcast out to all registered subscribers. They can update themselves in their onMessage() listener implementation.
    Could be a network traffic nightmare if you have a lot of clients. And what about transactions? Will you make the topic and the database transaction a single unit of work?
    Might be more complicated than it's worth, but that seems to be your requirement. Not a trivial problem.
    %

  • How to add a listener for frame change

    hello
    Im quite new to jmf, and im writing a code which uses the webcam, but im stuck at a point where i want a listener which is called whenever the frame changes in the visualcomponent. so basically im looking for a frame changed listener to be added to the visual component instead of using a loop or a timer or something.
    i just need a method to be called constantly along the stream coming from the webcam but which is consistent with the changing of the frames.
    i would really appreciate any kind of help.
    thank you

    i thought there would be a listener or something ready to do thisThere is. It's the Rendered interface, which has a callback everytime data is received. If you want to create a custom renderer that is triggered everytime data is available, you set a processor to use your renderer and when data is available, your process command will be called. Same as an event listener...but it's very advanced stuff to implement the renderer interface.
    for example if u want to record a video ull need to capture every frame as soon as it comesNo, the video doesn't come to you a frame at a time. The video is already encoded somehow when you get it, so it's coming in as a stream just like it'll be going out to the file... It's a stream of bytes, not a stream of images... You're not digitizing here, you're transcoding.

  • How to listen for a change in a JTextArea?

    well ..... the subject says it all :)

    The JavaDoc says it all :)
    The java.awt.TextArea could be monitored for changes by adding a TextListener for TextEvents. In the JTextComponent based components, changes are broadcasted from the model via a DocumentEvent to DocumentListeners. The DocumentEvent gives the location of the change and the kind of change if desired. The code fragment might look something like:
    DocumentListener myListener = ??;
    JTextArea myArea = ??;
    myArea.getDocument().addDocumentListener(myListener);http://java.sun.com/j2se/1.4/docs/api/javax/swing/JTextArea.html
    Col

  • Event to listen for nearID change

    Hello,
    it appears that Stratus NetConnection nearID changes pretty frequently for me while connected to Stratus (at least lately).
    I couldn't find where I can be notified when nearID changes. Could you help? Thanks in advance.
    -Kirill

    Thank you Michael.
    It just seems odd - and probably related to recent Stratus downtime/bandwidth experience - but my application takes several multi-second tries to connect to a server. Maybe it's just slow.
    Another problem I've been experiencing lately (definitely related to something on Stratus servers) is netConnection being dropped randomly. It simply disconnects after a minute or two about 90% of the time. I'm glad I can at least test my application, hoping these problems will go away soon.
    I think it's great what you guys at Adobe are doing with Flash and Stratus. If you had a Stratus logo designed, I'd definitely put that in my game's title screen.
    -Kirill

  • Listen for change in JTextField

    I would like to write an event listener to listen for any changes made to a JTextField. Normally I would think that keyListeners would do the trick except that the contents of this field can be altered by the application itself, and I would like to trap those changes too.
    Does anyone know of an event listener that listens for any changes made in the text of a JTextField, regardless of how those changes are made?

    use DocumentListener
    for more info see http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#doclisteners

  • URLconnection.getLastModified cannot identify file changes after connection

    In my code, I am using URLconnection.getLastModified to watch for file changes. Unfortunately, when the file changes after the URLconnection is made, it does not recognize the file changes. Any ideas on how to make this work?
    Thanks
    public FileChangeMonitor(URL fileURL) throws IOException {
    targetURLconnection = fileURL.openConnection();
    targetURLconnection.setUseCaches(false);// This didn't seem to help - can be deleted.
    public static void main(String[] args) throws InterruptedException {
    FileChangeMonitor testFileChangeMonitor = null;
    try {
    URL MyDataFile = new URL("http://localhost/MyDataFile.xml");
    testFileChangeMonitor = new FileChangeMonitor(MyDataFile);
    } catch (IOException i) {
    testFileChangeMonitor.start();
    @Override
    public void run() {
    long lm = targetURLconnection.getLastModified();
    long lm2 = 0;
    try {
    while (true) {
    Thread.sleep(POLL_INTERVAL);
    lm2 = targetURLconnection.getLastModified();
    if (lm2 != lm) {
    flag = FLAG_CHANGED;
    lm = lm2;
    fireStateChanged();
    System.out.println("MyDataFile Changed!!!");
    } catch (InterruptedException e) {
    e.printStackTrace();
    }

    If (hypothetically speaking) you had an HTTP URL (which of course points to a resource in general but it might happen to be a file in your case), then a common way to examine its last-modified date is to send an HTTP HEAD request and examine the headers in the response.

  • Lisetening for Property change

    I have created a MC to be used as a button. It is generic and
    I customize it per instance. It contains an onRelease event
    handler.
    I am confused as to what approach I can take within the MC's
    onRelease statement that would allow the parent to 1> know the
    MC has been clicked & 2> know which instance of the MC has
    been clicked (without putting onRelase code for each instance at
    the parent level).
    I was trying the following...
    myMC.onRelease = function() {
    _parent.clickedButton = myMC._name;
    ...but I couldn't figure how to make the parent listen for a
    change to clickedButton.
    How can I listent for a variable change? Is there a better
    approach?
    thx,
    Nathan

    Looks like I can answer my own question. In case anyone else
    is confused as to how to do this, I used the Object.watch method.
    After doing the above in the MC, I included the following in
    the parent...
    var btnWatcher:Function = function(prop, oldVal, newVal,
    userData) {
    trace(newVal);
    this.watch("clickedButton", btnWatcher);

  • Listener name in the listener.ora file is getting change from GPROD to %s_

    Dear Experts,
    Please note that after doing the R12.1 upgrade, When i bounce the database i have noted that my database listener name in the listener.ora file is getting change from GPROD to %s_db_listener%. Again every time after changeing the listener log file i am able to start the listener.
    Please advise.
    [oracle@upgrade 11.2.2]$ lsnrctl start GPROD
    LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 07-OCT-2011 10:07:33
    Copyright (c) 1991, 2010, Oracle. All rights reserved.
    Starting /u04/d01/tech_st/11.2.2/bin/tnslsnr: please wait...
    TNSLSNR for Linux: Version 11.2.0.2.0 - Production
    System parameter file is /u04/d01/tech_st/11.2.2/network/admin/GPROD_upgrade/listener.ora
    Log messages written to /u04/d01/tech_st/11.2.2/log/diag/tnslsnr/upgrade/gprod/alert/log.xml
    TNS-01151: Missing listener name, GPROD, in LISTENER.ORA
    Listener failed to start. See the error message(s) above...
    [oracle@upgrade 11.2.2]$ vi /u04/d01/tech_st/11.2.2/log/diag/tnslsnr/upgrade/gprod/alert/log.xml
    [oracle@upgrade 11.2.2]$ cd network/admin/GPROD_upgrade/
    [oracle@upgrade GPROD_upgrade]$ ls
    listener_ifile.ora listener.ora listener.ora_bkpaug2911 sqlnet_ifile.ora sqlnet.ora tnsnames.ora
    [oracle@upgrade GPROD_upgrade]$ vi listener.ora
    (SID_DESC =
    (ORACLE_HOME= /u04/d01/tech_st/11.2.2)
    (SID_NAME = GPROD)
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = /u04/d01/tech_st/11.2.2)
    (PROGRAM = extproc)
    STARTUP_WAIT_TIME_%s_db_listener% = 0
    CONNECT_TIMEOUT_%s_db_listener% = 10
    TRACE_LEVEL_%s_db_listener% = OFF
    LOG_DIRECTORY_%s_db_listener% = /u04/d01/tech_st/11.2.2/network/admin
    LOG_FILE_%s_db_listener% = %s_db_listener%
    TRACE_DIRECTORY_%s_db_listener% = /u04/d01/tech_st/11.2.2/network/admin
    TRACE_FILE_%s_db_listener% = %s_db_listener%
    ADMIN_RESTRICTIONS_%s_db_listener% = OFF
    IFILE=/u04/d01/tech_st/11.2.2/network/admin/GPROD_upgrade/listener_ifile.ora

    Step 1- Run the autoconfig on the db tier.
    Step -2 Automatically it is changing the setting in the database listener log file and it is showing 4 database listeners are up .
    [oracle@upgrade 11.2.2]$ ps -ef |grep inh
    oracle 756 1 0 11:01 ? 00:00:00 /u04/d01/tech_st/11.2.2/bin/tnslsnr GPROD -inherit
    oracle 757 756 0 11:01 ? 00:00:00 /u04/d01/tech_st/11.2.2/bin/tnslsnr GPROD -inherit
    oracle 758 757 0 11:01 ? 00:00:00 /u04/d01/tech_st/11.2.2/bin/tnslsnr GPROD -inherit
    oracle 759 757 0 11:01 ? 00:00:00 /u04/d01/tech_st/11.2.2/bin/tnslsnr GPROD -inherit
    oracle 1721 31038 0 11:02 pts/2 00:00:00 grep inh
    applmgr 31380 1 0 10:53 ? 00:00:00 /u04/d02/apps/tech_st/10.1.2/bin/tnslsnr APPS_GPROD -inherit
    Step - 3
    Again down the apps tier services.
    Step -4
    Reset the listener.ora file in the database tier
    Please advise.
    Regards
    Mohammed.

  • How can I Listen to the File changes?

    Hi all,
    I am confused in this problem.
    How can I make my program listen to the changes in a file. File is not opened in java program, but it is a outside file.
    User is not concerned with java program. User opens a file by double clicking and changes something in file. I want to make my java program listen to the file.So program keeps running. So whenever user changes data in that file, my java program should be notified.
    Please help me.
    Thanks

    I guess there are a couple of options.
    The full-java version is writing an application that opens said file every n seconds on a timer, and compares it against a cache for changes.
    Option two is jni.

  • File change listener

    Hi !
    My java app runs in an endless polling loop (by design) interrogating approx. 100 external devices via a comm port.
    This endless loop is interrupted when any keyboard entry is made, processed, then loop is again allowed to resume.
    I now need to interrupt my app if a certain file is changed(ie: a new line record is added).
    .... then to copy this file into my app for processing, then continue my normal loop polling.
    I think I need to add a "file listener" to this target file , but I'm new to Java.
    Can some one suggest a code snip to get me started?
    Thanks!

    I now need to interrupt my app if a certain file is changed(ie: a new line record is added)..... then to copy this file into my app for processing, then continue my normal loop polling.
    Java doen't provide a file change notifier. Read the "certain file" for a file parameter (maybe last modified) and if it's different from the previous read, do what is wanted. Depending on the specifics of your situation, you may want to do this in a separate thread from your polling.

  • Connection string in listener log file for loading balance/failover

    Hi Experts,
    I have 4 node RAC for oracle 10g2 in rad hate 5.0
    We creaed service dbsale ( sale1,2 as pr imary and sale3/4 as available) with loading balance/failover.
    The remote user created a local TNS as
    localmarket =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 155.206.xxx.xx)(PORT = 1521))
    (LOAD_BALANCE = OFF)
    (CONNECT_DATA = (SERVICE_NAME = dbsale))
    From server side, I saw that user send two request connection string. one fail and another is OK.
    It seems that fail connecting come from failover/loading balance from dbsale3?
    Why do we get two connection string in listener log file?
    Which difference is between two connection string?
    Where does system change these connection string?
    Thanks for your explaining.
    Jim
    ==============listener.log message
    [oracle@sale log]$ cat listener_sale.log|grep pmason
    15-SEP-2009 13:52:24 * (CONNECT_DATA=(SERVICE_NAME=dbsale)(CID=(PROGRAM=oracle)(HOST=rock)(USER=test ))) * (ADDRESS=(PROTOCOL=tcp)(HOST=161.55.xxx.xx)(PORT=54326)) * establish * dbsale * 0
    15-SEP-2009 13:52:25 * (CONNECT_DATA=(SERVICE_NAME=dbsale)(CID=(PROGRAM=oracle)(HOST=rock)(USER=test ))(SERVER=dedicated)(INSTANCE_NAME=sale3)) * (ADDRESS=(PROTOCOL=tcp)(HOST=161.55.xxx.xx)(PORT=54327)) * establish * dbsale * 12520
    15-SEP-2009 13:52:30 * (CONNECT_DATA=(SERVICE_NAME=dbsale)(CID=(PROGRAM=oracle)(HOST=rock)(USER=test ))) * (ADDRESS=(PROTOCOL=tcp)(HOST=161.55.xxx.xx)(PORT=54329)) * establish * dbsale* 0
    15-SEP-2009 13:52:47 * (CONNECT_DATA=(SERVICE_NAME=dbsale)(CID=(PROGRAM=oracle)(HOST=rock)(USER=test ))) * (ADDRESS=(PROTOCOL=tcp)(HOST=161.55.xxx.xx)(PORT=54332)) * establish * dbsale * 0
    15-SEP-2009 13:52:47 * (CONNECT_DATA=(SERVICE_NAME=dbsale)(CID=(PROGRAM=oracle)(HOST=rock)(USER=test ))(SERVER=dedicated)(INSTANCE_NAME=sale3)) * (ADDRESS=(PROTOCOL=tcp)(HOST=161.55.xxx.xx)(PORT=54333)) * establish dbsale 12520
    15-SEP-2009 13:52:49 * (CONNECT_DATA=(SERVICE_NAME=dbsale)(CID=(PROGRAM=oracle)(HOST=rock)(USER=test ))) * (ADDRESS=(PROTOCOL=tcp)(HOST=161.55.xxx.xx)(PORT=54334)) * establish * dbsale * 0
    Edited by: user589812 on Sep 16, 2009 7:21 AM

    Hi Jim,
    I think the best way on this case is create one service with one instance as primary and another 3 as available.
    Or use the connect string with two vip addresses, cause the service has two instances and the tnsnames.ora entry has only one.
    Cheers,
    Rodrigo Mufalani
    http://mufalani.blogspot.com

Maybe you are looking for

  • Poor Service the whole nine yards

    On Saturday, March 29, 2014, I purchased a "Deal of the Day," a Samsung Gear Watch and selected a pick up from Best Buy on Monroe Street in Toledo, OH.  I live 28.1 miles from this location, but I happened to be passing it later that day.  I got a co

  • SOAP request to XI.  error:  "Channel stopped by administrative task"

    Hi , We are working on SOAP --> XI --> Idoc scenario. The webservice call is an Asynchronous one. I done the design and configuration and provided the WSDL to the webservice applicant. When they tried to send the message they are getting the followin

  • Time Machine or third party???

    I have just started backing up and I am using Time Machine to back up 60 gigs to a 500 gig external HD through USB 1 cable. Time Machine is incredibly slow. Is it because the program is slow or is it a hardware issue? In other words, should I be stay

  • SCXI-1127 and Reset NISwitch VI

    I have a question with regard to resetting the SCXI-1127 Card. I wrote a test VI that performs the following in sequence to verify the -1127 operation: 1) Initialize the SCXI-1127 Card (using a Instrument Descriptor of SCXI1::5::INDEP) 2) Control a s

  • Patching doubts

    I am performing patching. The patching is going fine and there is nothing wrong in that. Actually we are patching the rac environment so all the environment has got min four nodes. Actually in the instructions we are asked to patch in each and every