Class Controller
java.lang.Object
com.appiancorp.suiteapi.process.test.Controller
- Direct Known Subclasses:
ProcessController
Controller is the root of the controller objects that allow the
automatic control of processes and their tasks.
For most purposes, use the TaskController directly.
Controller itself only provides logging abilities available at the object level, rather than just the system level. It only retains the logs generated within the Controllers themselves, not the general logging done by other objects in the system.
This allows not only logging the control information, but also retrieving it for use by the controlling Java code. The information may then be displayed in its own manner.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
ControllerException This exception is thrown for controller errors.static class
LogElement The object log is composed of LogElements.static enum
LogLevel enumeration supported by Controller logging. -
Field Summary
Modifier and TypeFieldDescriptionprotected long
protected TimeUnit
protected List<Controller.LogElement>
protected static final org.apache.log4j.Logger
protected Controller.LogLevel
protected boolean
protected final com.appiancorp.common.performance.Performance
protected ServiceContext
-
Constructor Summary
ConstructorDescriptionConstruct an Controller for the given ServiceContext. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clearLog()
Clear the retrievable log.void
enableLogToLogger
(boolean state) Set whether logging should be done to the logger (Log4J) as well as recorded.void
enablePerformanceLogging
(boolean state) Enable or disable performance logging, regardless of logging settings.getLog()
Get a textual performance summary.protected void
log
(Controller.LogLevel logLevel, String message) Record the log messages in this Controller's log and send it to the external (e.g., log4j) logger.void
setLogLevel
(Controller.LogLevel logLevel) Set desired logging level.void
setTimeout
(long duration, TimeUnit timeUnit) Set default timeout duration for Controller methods, if explicit duration and timeUnit parameters are not passed to a method.protected void
yieldWithLog
(long duration, TimeUnit timeUnit, String message) Yield for the given time, logging a delay message at LogLevel.INFO.
-
Field Details
-
LOG
protected static final org.apache.log4j.Logger LOG -
performance
protected final com.appiancorp.common.performance.Performance performance -
sc
-
log
-
logLevel
-
logToLogger
protected boolean logToLogger -
defaultDuration
protected long defaultDuration -
defaultTimeUnit
-
-
Constructor Details
-
Controller
Construct an Controller for the given ServiceContext.- Parameters:
sc
-activityId
-
-
-
Method Details
-
setTimeout
Set default timeout duration for Controller methods, if explicit duration and timeUnit parameters are not passed to a method. Methods that use the timeout will have a variation with explicit timeout and with implicit default timeout. If always running on a slow or fast system, then modifying the Controller's default timeout using this method may be appropriate. If controlling a slow or fast process or task, then passing the explicit duration and timeUnit parameters may be most appropriate. The default for Controller is 5000 of TimeUnit.MILLISECONDS.- Parameters:
duration
-timeUnit
-
-
setLogLevel
Set desired logging level. The log levels of the Controller defaults to LogLevel.INFO.- Parameters:
logLevel
-
-
enableLogToLogger
public void enableLogToLogger(boolean state) Set whether logging should be done to the logger (Log4J) as well as recorded. Note: this controls only logging from the Controller classes.- Parameters:
state
- true to log controller messages to logger; true by default
-
clearLog
public void clearLog()Clear the retrievable log. -
log
Record the log messages in this Controller's log and send it to the external (e.g., log4j) logger. If a log message is done at LogLevel.DISABLED, then it is sent to the external logger at DEBUG level; this is never done by the Appian Controller objects.- Parameters:
logLevel
- of the message; this is compared against the Controller's log level to see if the log should be done.message
- the textual log message
-
getLog
- Returns:
- log recorded by this Controller session
-
getPerformanceSummary
Get a textual performance summary. Performance logging must be enabled for this to return data.- Returns:
- human readable performance summary collected by the controller, including timings and iterations of calls made by the Controller
-
enablePerformanceLogging
public void enablePerformanceLogging(boolean state) Enable or disable performance logging, regardless of logging settings. Performance logging is enabled by the logger's (log4j's) perf.controller attribute in log4j.properties by default. This method override the logger's property setting.- Parameters:
state
- true to enable, false to disable
-
yieldWithLog
Yield for the given time, logging a delay message at LogLevel.INFO.- Parameters:
duration
- time in timeUnitstimeUnit
- meaning of timeUnitmessage
- to include in log message
-