de.unikassel.android.sdcframework.broadcast
Class SampleBroadcastServiceImpl

Package class diagram package SampleBroadcastServiceImpl
java.lang.Object
  extended by java.lang.Thread
      extended by de.unikassel.android.sdcframework.util.AbstractWorkerThread
          extended by de.unikassel.android.sdcframework.util.AbstractAsynchrounousSampleObserver
              extended by de.unikassel.android.sdcframework.broadcast.SampleBroadcastServiceImpl
All Implemented Interfaces:
SampleBroadcastService, AsynchrounousSampleObserver, DelegatingSampleObserver, LifeCycleObject, WorkerThread, Runnable

public class SampleBroadcastServiceImpl
extends AbstractAsynchrounousSampleObserver
implements SampleBroadcastService

Implementation of the sample broadcast service interface.

This service can observe a sample event source, like the device manager, and is broadcasting observed samples with the configured frequency to the system.

See Also:
SampleBroadcastService, AbstractAsynchrounousSampleObserver

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  Context applicationContext
          The application context for broadcasts
private  AtomicLong frequency
          The broadcast frequency in milliseconds
private  Object frequencyWaitLock
          The frequency wait lock
private  AtomicLong lastExecutionTimeStamp
          The timestamp of the last execution
 
Fields inherited from class de.unikassel.android.sdcframework.util.AbstractAsynchrounousSampleObserver
collector
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SampleBroadcastServiceImpl(Context applicationContext, long frequency)
          Constructor
 
Method Summary
private  void broadcastCachedSamples()
          Method to broadcast all cached samples
protected  void doSignalFrequencyChange()
          Method to signal frequency changes
protected  void doWork()
          The working method executed in the running loop if started
 void onPause(Context applicationContext)
          Pause method
 void onResume(Context applicationContext)
          Resume method
 void updateFrequency(long frequency)
          Method to update the frequency of broadcasts in milliseconds (>= 0 ms).
 
Methods inherited from class de.unikassel.android.sdcframework.util.AbstractAsynchrounousSampleObserver
doCleanUp, getObserver, onCreate, onDestroy
 
Methods inherited from class de.unikassel.android.sdcframework.util.AbstractWorkerThread
doTerminate, hasTerminated, isLogging, isWorking, logMessage, run, setLogging, start, startWork, stopWork
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.WorkerThread
doTerminate, hasTerminated, isLogging, isWorking, setLogging, startWork, stopWork
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.LifeCycleObject
onCreate, onDestroy
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.DelegatingSampleObserver
getObserver
 

Field Detail

applicationContext

private final Context applicationContext
The application context for broadcasts


frequency

private final AtomicLong frequency
The broadcast frequency in milliseconds


frequencyWaitLock

private final Object frequencyWaitLock
The frequency wait lock


lastExecutionTimeStamp

private final AtomicLong lastExecutionTimeStamp
The timestamp of the last execution

Constructor Detail

SampleBroadcastServiceImpl

public SampleBroadcastServiceImpl(Context applicationContext,
                                  long frequency)
Constructor

Parameters:
applicationContext - the application context
frequency - the frequency
Method Detail

onResume

public void onResume(Context applicationContext)
Description copied from interface: LifeCycleObject
Resume method

Specified by:
onResume in interface LifeCycleObject
Overrides:
onResume in class AbstractAsynchrounousSampleObserver
Parameters:
applicationContext - the application context

onPause

public void onPause(Context applicationContext)
Description copied from interface: LifeCycleObject
Pause method

Specified by:
onPause in interface LifeCycleObject
Overrides:
onPause in class AbstractAsynchrounousSampleObserver
Parameters:
applicationContext - the application context

doWork

protected void doWork()
Description copied from class: AbstractWorkerThread
The working method executed in the running loop if started

Specified by:
doWork in class AbstractWorkerThread

broadcastCachedSamples

private void broadcastCachedSamples()
Method to broadcast all cached samples


updateFrequency

public void updateFrequency(long frequency)
Description copied from interface: SampleBroadcastService
Method to update the frequency of broadcasts in milliseconds (>= 0 ms).

Specified by:
updateFrequency in interface SampleBroadcastService
Parameters:
frequency - the new frequency value

doSignalFrequencyChange

protected void doSignalFrequencyChange()
Method to signal frequency changes