001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     bstefanescu
018 *
019 * $Id$
020 */
021
022package org.nuxeo.runtime.deploy;
023
024// FIXME: interface has changed and this example is no more appropriate.
025/**
026 * An example of listener implementation:
027 *
028 * <pre>
029 * public class MyListener implements FileChangeListener {
030 *     long lastNotif = 0;
031 *
032 *     public void fileChanged(File file, long since, long now) {
033 *         if (now == lastNotifFlush)
034 *             return;
035 *         if (isIntersetedInFile(file)) {
036 *             lastNotif = now;
037 *             flushCache(); // flush internal cache because file on disk changed
038 *         }
039 *     }
040 * }
041 * </pre>
042 *
043 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
044 */
045public interface FileChangeListener {
046
047    /**
048     * Notifies that the given file changed.
049     *
050     * @param entry
051     * @param now the time stamp when the change was detected. This value can be used as a notification ID by listeners
052     *            to avoid multiple processing for notification that will send multiple events
053     */
054    void fileChanged(FileChangeNotifier.FileEntry entry, long now);
055
056}