Class Controller

java.lang.Object
com.appiancorp.suiteapi.process.test.Controller
Direct Known Subclasses:
ProcessController

public class Controller extends Object
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:
  • Field Details

    • LOG

      protected static final org.apache.log4j.Logger LOG
    • performance

      protected final com.appiancorp.common.performance.Performance performance
    • sc

      protected ServiceContext sc
    • log

      protected List<Controller.LogElement> log
    • logLevel

      protected Controller.LogLevel logLevel
    • logToLogger

      protected boolean logToLogger
    • defaultDuration

      protected long defaultDuration
    • defaultTimeUnit

      protected TimeUnit defaultTimeUnit
  • Constructor Details

    • Controller

      public Controller(ServiceContext sc)
      Construct an Controller for the given ServiceContext.
      Parameters:
      sc -
      activityId -
  • Method Details

    • setTimeout

      public 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. 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

      public void setLogLevel(Controller.LogLevel logLevel)
      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

      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. 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

      public Controller.LogElement[] getLog()
      Returns:
      log recorded by this Controller session
    • getPerformanceSummary

      public String 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

      protected void yieldWithLog(long duration, TimeUnit timeUnit, String message)
      Yield for the given time, logging a delay message at LogLevel.INFO.
      Parameters:
      duration - time in timeUnits
      timeUnit - meaning of timeUnit
      message - to include in log message