|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
de.unikassel.android.sdcframework.util.AbstractWorkerThread
de.unikassel.android.sdcframework.util.AbstractAsynchrounousSampleObserver
de.unikassel.android.sdcframework.persistence.PersistentStorageManagerImpl
public final class PersistentStorageManagerImpl
The persistent storage manager does provide the persistent storage feature
for the framework.
It does extend the AbstractAsynchrounousSampleObserver to cache
observed samples for further asynchronous processing.
ServiceManagerImpl
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private InsertSamplesCommand |
currentCommand
The last not finished database command |
private DatabaseFullStrategy |
dbFullStrategy
The strategy to use in case of SQLiteFullException |
private DatabaseManager |
dbManager
The database manager used for database access |
private AtomicLong |
savedRecordCount
The actual count of records stored to database in the actual work period |
private Class<? extends SDCService> |
serviceClass
The service class |
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 | |
---|---|
PersistentStorageManagerImpl(Context applicationContext,
ServiceConfiguration config,
DatabaseManager dbManager,
Class<? extends SDCService> serviceClass,
Class<? extends Activity> controlActivityClass)
Constructor |
Method Summary | ||
---|---|---|
private Collection<DatabaseSample> |
convertSamplesToDBSamples(SampleCollection samples)
Conversion of samples to database samples |
|
long |
doDeleteOldestSamplesInDatabase(long count,
boolean lowestPriorityFirst)
Method to delete the oldest "count" samples in the database This method is used to delete samples for deletion in case of database size maximum reached. |
|
|
doExecuteCommand(DatabaseCommand<T> command)
Does execute a database command |
|
boolean |
doExecuteCurrentCommand()
Does execute the current outstanding database command |
|
private void |
doHandleDatabaseSizeLimitExceeded()
Handler for the SQL database full exception |
|
protected void |
doWork()
The working method executed in the running loop if started |
|
long |
getMaximumDatabaseSize()
Getter for the maximum database size in kilobytes |
|
long |
getRecordCountInDatabase()
Getter for the current sample record count stored in database |
|
long |
getSavedRecordCount()
Getter for the savedRecordCount |
|
void |
onPause(Context applicationContext)
Pause method |
|
void |
onResume(Context applicationContext)
Resume method |
|
long |
setMaximumDatabaseSize(long size)
Setter for the maximum database size in kilobytes |
|
void |
updateDatabaseFullStrategy(Context context,
ServiceConfiguration config,
Class<? extends Activity> controlActivityClass)
Method to update internal database full strategy chain by configuration of the service |
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 |
---|
private final AtomicLong savedRecordCount
private final DatabaseManager dbManager
private DatabaseFullStrategy dbFullStrategy
private InsertSamplesCommand currentCommand
private final Class<? extends SDCService> serviceClass
Constructor Detail |
---|
public PersistentStorageManagerImpl(Context applicationContext, ServiceConfiguration config, DatabaseManager dbManager, Class<? extends SDCService> serviceClass, Class<? extends Activity> controlActivityClass)
applicationContext
- the application contextconfig
- the service configurationdbManager
- the database manager to useserviceClass
- the service classcontrolActivityClass
- the control activity class or nullMethod Detail |
---|
public final void updateDatabaseFullStrategy(Context context, ServiceConfiguration config, Class<? extends Activity> controlActivityClass)
PersistentStorageManager
updateDatabaseFullStrategy
in interface PersistentStorageManager
context
- the application contextconfig
- the current service configuration to update fromcontrolActivityClass
- the control activity class or nullprotected final void doWork()
AbstractWorkerThread
doWork
in class AbstractWorkerThread
private final Collection<DatabaseSample> convertSamplesToDBSamples(SampleCollection samples)
samples
- the sample collection to convert to a database sample collection
public final boolean doExecuteCurrentCommand()
PersistentStorageManager
doExecuteCurrentCommand
in interface PersistentStorageManager
public final long doDeleteOldestSamplesInDatabase(long count, boolean lowestPriorityFirst)
DatabaseManager
doDeleteOldestSamplesInDatabase
in interface DatabaseManager
count
- the sample count to delete in databaselowestPriorityFirst
- if true the samples will be selected ordered by priority and time
stamp, otherwise just by time stamp
private final void doHandleDatabaseSizeLimitExceeded()
public final void onResume(Context applicationContext)
LifeCycleObject
onResume
in interface LifeCycleObject
onResume
in class AbstractAsynchrounousSampleObserver
applicationContext
- the application contextpublic final void onPause(Context applicationContext)
LifeCycleObject
onPause
in interface LifeCycleObject
onPause
in class AbstractAsynchrounousSampleObserver
applicationContext
- the application contextpublic final long getSavedRecordCount()
PersistentStorageManager
getSavedRecordCount
in interface PersistentStorageManager
public final long getRecordCountInDatabase()
DatabaseManager
getRecordCountInDatabase
in interface DatabaseManager
public final long getMaximumDatabaseSize()
DatabaseManager
getMaximumDatabaseSize
in interface DatabaseManager
public final long setMaximumDatabaseSize(long size)
DatabaseManager
setMaximumDatabaseSize
in interface DatabaseManager
size
- the maximum database size
public <T> T doExecuteCommand(DatabaseCommand<T> command)
DatabaseManager
doExecuteCommand
in interface DatabaseManager
T
- the result type of the commandcommand
- the command to execute
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |