// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
//     public void fileChanged(FileUpdateEvent event);
// }
// 
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//     
//     public FileUpdateEvent(final Object source) {
//         super(source);
//     }
// }
// 
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcher.java
// public interface FileWatcher {
//     public void watchFile(Path file);
//     public void removeFileListener(FileListener listener);
//     public void addFileListener(FileListener listener);
// }
// 
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcherFactory.java
// public class FileWatcherFactory {
//     public static FileWatcher getFileWatcher() {
//         return new WatchServiceFileWatcher();
//     }
// }


import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.FileWatcher;
import com.thinksincode.tailstreamer.watch.FileWatcherFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import java.nio.file.Path;
package com.thinksincode.tailstreamer;



/**
 * Watches a file for changes, and notifies observers when the file is updated.
 */
@Service("fileWatcher")
public class FileWatcherService implements ApplicationEventPublisherAware, FileListener {
    private Logger logger = LoggerFactory.getLogger(FileWatcherService.class);
    
    private ApplicationEventPublisher eventPublisher;
    
    /** Flag that indicates whether the watch service should continue. */
    private boolean watch = true;
    
    /**
     * Starts watching a file.
     */
    public void watchFile(final Path watchedFile) {
        FileWatcher watcher = FileWatcherFactory.getFileWatcher();
        watcher.addFileListener(this);
        watcher.watchFile(watchedFile);
    }

    /**
     * Called when changes have been detected to the file.
     */
    @Override
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
//     public void fileChanged(FileUpdateEvent event);
// }
// 
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//     
//     public FileUpdateEvent(final Object source) {
//         super(source);
//     }
// }
// 
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcher.java
// public interface FileWatcher {
//     public void watchFile(Path file);
//     public void removeFileListener(FileListener listener);
//     public void addFileListener(FileListener listener);
// }
// 
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcherFactory.java
// public class FileWatcherFactory {
//     public static FileWatcher getFileWatcher() {
//         return new WatchServiceFileWatcher();
//     }
// }


// Path: src/main/java/com/thinksincode/tailstreamer/FileWatcherService.java
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.FileWatcher;
import com.thinksincode.tailstreamer.watch.FileWatcherFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import java.nio.file.Path;

package com.thinksincode.tailstreamer;



/**
 * Watches a file for changes, and notifies observers when the file is updated.
 */
@Service("fileWatcher")
public class FileWatcherService implements ApplicationEventPublisherAware, FileListener {
    private Logger logger = LoggerFactory.getLogger(FileWatcherService.class);
    
    private ApplicationEventPublisher eventPublisher;
    
    /** Flag that indicates whether the watch service should continue. */
    private boolean watch = true;
    
    /**
     * Starts watching a file.
     */
    public void watchFile(final Path watchedFile) {
        FileWatcher watcher = FileWatcherFactory.getFileWatcher();
        watcher.addFileListener(this);
        watcher.watchFile(watchedFile);
    }

    /**
     * Called when changes have been detected to the file.
     */
    @Override
    public void fileChanged(FileUpdateEvent event) {