|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.placelab.spotter.AbstractSpotter
org.placelab.spotter.AsyncSpotter
This convenience class provides all the groundwork for Spotters whose implementations are most naturally asynchronous. Subclasses provide their own startOneScan and cancelScan implementations, and AsyncSpotter then builds the continuous scanning methods based on those.
| Constructor Summary | |
AsyncSpotter()
|
|
| Method Summary | |
protected abstract void |
cancelScan()
Stops the scan that was started in startOneScan(EventSystem) |
void |
errorInBackgroundThreadAndThreadDeath(java.lang.Throwable t)
|
Measurement |
getMeasurement()
A blocking call to get a new Measurement. |
protected abstract Measurement |
getMeasurementImpl()
Collect Measurements with a blocking implementation and return them. |
protected abstract long |
nextScanInterval()
|
protected void |
scanDone()
|
void |
scanOnce()
Performs a single background scan for Measurements and returns the result to registered SpotterListeners' SpotterListener.gotMeasurement(Spotter, Measurement) method. |
void |
scanOnce(EventSystem evs)
Like scanOnce() but instead uses the given EventSystem to deliver the
callback to hide the background thread from the application. |
protected void |
scanUsingBackgroundThread(EventSystem evs)
|
protected void |
scanUsingEventSystem(EventSystem evs)
|
protected abstract void |
startOneScan(EventSystem evs)
This performs a single scan of the environment that should call AbstractSpotter.notifyGotMeasurement(EventSystem, Measurement) upon
collecting the Measurement. |
void |
startScanning()
Start scanning for Measurements in the background and return the Measurements by notifying SpotterListeners with the SpotterListener.gotMeasurement(Spotter, Measurement) method. |
void |
startScanning(EventSystem evs)
Start scanning for Measurements. |
void |
stopScanning()
Stops a currently running background scan started from either scanOnce or startScanning. |
| Methods inherited from class org.placelab.spotter.AbstractSpotter |
addListener, notifyEndOfScan, notifyEndOfScan, notifyGotException, notifyGotException, notifyGotMeasurement, notifyGotMeasurement, removeListener, waitForThread |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.placelab.spotter.Spotter |
close, open |
| Constructor Detail |
public AsyncSpotter()
| Method Detail |
protected abstract long nextScanInterval()
protected abstract void startOneScan(EventSystem evs)
AbstractSpotter.notifyGotMeasurement(EventSystem, Measurement) upon
collecting the Measurement.
evs - the EventSystem to pass through to notifyGotMeasurementprotected abstract void cancelScan()
startOneScan(EventSystem)
protected abstract Measurement getMeasurementImpl()
throws SpotterException
SpotterException
public Measurement getMeasurement()
throws SpotterException
Spotter
SpotterExceptionpublic void scanOnce()
SpotterSpotterListener.gotMeasurement(Spotter, Measurement) method.
This may start a new thread and deliver the callback in that new thread.
Registered SpotterListeners that also implement the ScanOnceListener interface
will also receive ScanOnceListener.endOfScan(Spotter) notifications.
scanOnce in interface SpotterscanOnce in class AbstractSpotterpublic void scanOnce(EventSystem evs)
SpotterSpotter.scanOnce() but instead uses the given EventSystem to deliver the
callback to hide the background thread from the application.
scanOnce in interface SpotterscanOnce in class AbstractSpotterpublic void startScanning()
SpotterSpotterListener.gotMeasurement(Spotter, Measurement) method.
Depending on the Spotter implementation this
may start up a new background thread. Callbacks to the SpotterListener are
not guaranteed to (and probably won't) be in the the same thread as
startScanning was called in.
startScanning in interface SpotterstartScanning in class AbstractSpotterpublic void startScanning(EventSystem evs)
Spotter
startScanning in interface SpotterstartScanning in class AbstractSpotterpublic void stopScanning()
Spotter
stopScanning in interface SpotterstopScanning in class AbstractSpotterprotected void scanUsingBackgroundThread(EventSystem evs)
protected void scanUsingEventSystem(EventSystem evs)
protected void scanDone()
public void errorInBackgroundThreadAndThreadDeath(java.lang.Throwable t)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||