CommandFileWatcher

class CommandFileWatcher
extends Thread

java.lang.Object
   ↳ java.lang.Thread
     ↳ com.android.tradefed.command.CommandFileWatcher


A simple class to watch a set of command files for changes, and to trigger a reload of _all_ manually-loaded command files when such a change happens.

Summary

Nested classes

class CommandFileWatcher.CommandFile

A simple struct to store a command file as well as its extra args  

interface CommandFileWatcher.ICommandFileListener

 

Fields

boolean mCancelled

Public constructors

CommandFileWatcher(CommandFileWatcher.ICommandFileListener listener)

Public methods

void addCmdFile(File cmdFile, List<String> extraArgs, Collection<String> includedFiles)

Add a command file to watch, as well as its dependencies.

void cancel()

Terminate the watcher thread

List<String> getExtraArgsForFile(String cmdPath)

Retrieves the extra arguments associated with given file being watched.

boolean isCancelled()

Check if the thread has been signalled to stop.

boolean isFileWatched(File cmdFile)

Returns true if given command gile path is currently being watched

void removeAllFiles()

Remove all files from the watched list

void run()

Fields

mCancelled

boolean mCancelled

Public constructors

CommandFileWatcher

CommandFileWatcher (CommandFileWatcher.ICommandFileListener listener)

Parameters
listener CommandFileWatcher.ICommandFileListener

Public methods

addCmdFile

void addCmdFile (File cmdFile, 
                List<String> extraArgs, 
                Collection<String> includedFiles)

Add a command file to watch, as well as its dependencies. When either the command file itself or any of its dependencies changes, notify the registered CommandFileWatcher.ICommandFileListener

if the cmdFile is already being watching, this call will replace the current entry

Parameters
cmdFile File

extraArgs List

includedFiles Collection

cancel

void cancel ()

Terminate the watcher thread

getExtraArgsForFile

List<String> getExtraArgsForFile (String cmdPath)

Retrieves the extra arguments associated with given file being watched.

TODO: extra args list should likely be stored elsewhere, and have this class just operate as a generic file watcher with dependencies

Parameters
cmdPath String

Returns
List<String> the list of extra arguments associated with command file. Returns empty list if command path is not recognized

isCancelled

boolean isCancelled ()

Check if the thread has been signalled to stop.

Returns
boolean

isFileWatched

boolean isFileWatched (File cmdFile)

Returns true if given command gile path is currently being watched

Parameters
cmdFile File

Returns
boolean

removeAllFiles

void removeAllFiles ()

Remove all files from the watched list

run

void run ()