Class Worker

  • Direct Known Subclasses:
    Job, Task

    public abstract class Worker
    extends Object
    Base class for asynchronous
    Author:
    M. Togna, S. Ricci
    • Constructor Detail

      • Worker

        public Worker()
    • Method Detail

      • initialize

        public void initialize()
      • createInternalVariables

        protected void createInternalVariables()
                                        throws Throwable
        Throws:
        Throwable
      • initializeInternalVariables

        protected void initializeInternalVariables()
                                            throws Throwable
        Throws:
        Throwable
      • beforeExecute

        protected void beforeExecute()
      • beforeExecuteInternal

        protected void beforeExecuteInternal()
                                      throws Throwable
        Throws:
        Throwable
      • afterExecute

        protected void afterExecute()
      • afterExecuteInternal

        protected void afterExecuteInternal()
      • getName

        public String getName()
      • run

        protected void run()
      • abort

        public void abort()
      • changeStatus

        protected void changeStatus​(Worker.Status newStatus)
      • onEnd

        protected void onEnd()
      • onCompleted

        protected void onCompleted()
      • onFailed

        protected void onFailed()
      • onAborted

        protected void onAborted()
      • destroy

        public void destroy()
      • release

        protected void release()
        Releases the resource used during the execution
      • notifyAllStatusChangeListeners

        protected void notifyAllStatusChangeListeners​(WorkerStatusChangeEvent event)
      • getDuration

        public long getDuration()
      • isPending

        public boolean isPending()
      • isRunning

        public boolean isRunning()
      • isFailed

        public boolean isFailed()
      • isAborted

        public boolean isAborted()
      • isCompleted

        public boolean isCompleted()
      • getProgressPercent

        public abstract int getProgressPercent()
      • isEnded

        public boolean isEnded()
        If task was run and finished, aborted or failed
        Returns:
      • getStartTime

        public long getStartTime()
      • getEndTime

        public long getEndTime()
      • getLastException

        public Throwable getLastException()
      • getId

        public UUID getId()
      • logDebug

        protected void logDebug​(String message)
      • logInfo

        protected void logInfo​(String message)
      • logWarning

        protected void logWarning​(String message)
      • logError

        protected void logError​(String message,
                                Throwable throwable)
      • getErrorMessage

        public String getErrorMessage()
      • setErrorMessage

        protected void setErrorMessage​(String errorMessage)
      • getErrorMessageArgs

        public String[] getErrorMessageArgs()
      • getWeight

        public int getWeight()
      • setWeight

        public void setWeight​(int weight)
      • setErrorMessageArgs

        protected void setErrorMessageArgs​(String[] errorMessageArgs)
      • setLastException

        protected void setLastException​(Throwable lastException)
      • waitFor

        public boolean waitFor​(int timeoutMillis)