|
||||||||||
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.LogfileManager
public final class LogfileManager
A worker thread to realize a the global log file handling.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private ObservableAlarm |
alarm
The observable wake up alarm |
private ConnectionStrategy |
connectionStrategy
The connection strategy |
private Context |
context
The context |
private static String |
FILE_NAME
The log file name |
private static LogfileManager |
instance
The singleton instance |
private ConcurrentLinkedQueue<LogEvent> |
logEvents
The queue for log messages |
protected ProtocolStrategy |
protocolStrategy
The strategy implementing the protocol |
static String |
RELATIVE_PATH
Relative file path on the external storage media |
private static String |
STORAGE_DIR
The environmental storage directory |
private static long |
TERMINATION_DELAY
The delay for the automatic instance release ( to allow final log information be still logged) |
private ConcurrentLinkedQueue<String> |
transferFiles
The queue for files to transfer |
private UUID |
uuid
The uuid of the device |
private WakeLockHolder |
wakeLockHolder
The wake lock holder instance |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
private |
LogfileManager(Context context,
UUID uuid)
Constructor |
Method Summary | |
---|---|
void |
addLogEvent(LogEvent event)
Method to add a log event |
static void |
clearAllLogs()
Static method to clear any available log file on the external storage media |
static void |
createInstance(Context context,
UUID uuid)
Method to create the global instance |
protected void |
doCleanUp()
The clean up method executed on termination |
protected void |
doWork()
The working method executed in the running loop if started |
static LogfileManager |
getInstance()
Getter for the instance |
protected File |
getLogFile(long ts)
Getter for the actual log file |
protected boolean |
isConfigured()
Method to test for a valid configuration |
private boolean |
isExternalStorageAvailable()
Test method for availability of the external storage device |
void |
onEvent(ObservableEventSource<? extends AlarmEvent> eventSource,
AlarmEvent observedEvent)
This method is called whenever the observed object does create an observed event |
static void |
prepareReleaseInstance()
Method to prepare delayed instance release |
private static void |
releaseInstance()
Method to destroy the global instance |
private boolean |
saveLogEvent(LogEvent event)
Me6thod to save a log event |
void |
updateConfiguration(Context context,
TransmissionProtocolConfiguration config)
Method to update the component by a configuration |
private boolean |
uploadFile(String fileName)
Does upload a file to the configured remote server using the given authentication data |
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 |
Field Detail |
---|
private static final long TERMINATION_DELAY
private static final String FILE_NAME
public static final String RELATIVE_PATH
private static final String STORAGE_DIR
private final ConcurrentLinkedQueue<LogEvent> logEvents
private final ConcurrentLinkedQueue<String> transferFiles
protected ProtocolStrategy protocolStrategy
private ConnectionStrategy connectionStrategy
private final WakeLockHolder wakeLockHolder
private final UUID uuid
private final ObservableAlarm alarm
private final Context context
private static LogfileManager instance
Constructor Detail |
---|
private LogfileManager(Context context, UUID uuid)
context
- the contextuuid
- the unique SDC installation identifier for this deviceMethod Detail |
---|
public static final LogfileManager getInstance()
public static final void createInstance(Context context, UUID uuid)
context
- the contextuuid
- the unique SDC installation identifier for this deviceprivate static final void releaseInstance()
public static void prepareReleaseInstance()
protected final boolean isConfigured()
public final void addLogEvent(LogEvent event)
event
- the log event to add to the queueprotected final void doCleanUp()
AbstractWorkerThread
doCleanUp
in class AbstractWorkerThread
protected final void doWork()
AbstractWorkerThread
doWork
in class AbstractWorkerThread
private boolean saveLogEvent(LogEvent event)
event
- the log event to save to file
protected final File getLogFile(long ts) throws IOException
ts
- the time stamp
IOException
private boolean isExternalStorageAvailable()
private final boolean uploadFile(String fileName)
fileName
- the file to upload
public final void updateConfiguration(Context context, TransmissionProtocolConfiguration config)
UpdatableTransmissionComponent
updateConfiguration
in interface UpdatableTransmissionComponent<TransmissionProtocolConfiguration>
context
- the application contextconfig
- the configuration to update frompublic static final void clearAllLogs()
public void onEvent(ObservableEventSource<? extends AlarmEvent> eventSource, AlarmEvent observedEvent)
EventObserver
onEvent
in interface EventObserver<AlarmEvent>
eventSource
- the event generatorobservedEvent
- the event created by the observed object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |