org.wso2.carbon.registry.core.utils
Class LogWriter

java.lang.Object
  extended by java.lang.Thread
      extended by org.wso2.carbon.registry.core.utils.LogWriter
All Implemented Interfaces:
Runnable

public class LogWriter
extends Thread

Writes log records to the database on a separate thread


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LogWriter(LogQueue logQueue, DataAccessManager dataAccessManager)
          Constructor accepting a queue of logs.
 
Method Summary
 void addLog(String resourcePath, String userName, int action, String actionData)
          Adds log record to queue
 LogQueue getLogQueue()
          Obtains the queue for holding and retrieving logs.
 boolean isCanWriteLogs()
           
 void logWrite()
           
 void run()
          The main business logic.
 void setCanWriteLogs(boolean canWriteLogs)
           
 void setLogQueue(LogQueue logQueue)
          Sets the queue for holding and retrieving logs.
 void start()
          Starts writing logs.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LogWriter

public LogWriter(LogQueue logQueue,
                 DataAccessManager dataAccessManager)
Constructor accepting a queue of logs.

Parameters:
logQueue - the queue of logs.
dataAccessManager - the manager class that can be used to obtain access to the back-end database.
Method Detail

isCanWriteLogs

public boolean isCanWriteLogs()

setCanWriteLogs

public void setCanWriteLogs(boolean canWriteLogs)

setLogQueue

public void setLogQueue(LogQueue logQueue)
Sets the queue for holding and retrieving logs.

Parameters:
logQueue - the queue for holding and retrieving logs.

getLogQueue

public LogQueue getLogQueue()
Obtains the queue for holding and retrieving logs.

Returns:
queue for holding and retrieving logs.

start

public void start()
Starts writing logs.

Overrides:
start in class Thread

run

public void run()
The main business logic.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

logWrite

public void logWrite()

addLog

public void addLog(String resourcePath,
                   String userName,
                   int action,
                   String actionData)
            throws RegistryException
Adds log record to queue

Parameters:
resourcePath - the resource path.
userName - the name of the user who performed the action on the resource.
action - an identifier of the action that happened.
actionData - the data for further information.
Throws:
RegistryException - if the operation failed.


Copyright © 2013 WSO2 Inc. All Rights Reserved.