org.eclipse.net4j.util.concurrent

## Class Worker

- java.lang.Object
- - org.eclipse.net4j.util.event.Notifier
  - - org.eclipse.net4j.util.lifecycle.Lifecycle
    - - org.eclipse.net4j.util.concurrent.Worker

- All Implemented Interfaces:
    INotifier, IDeactivateable, ILifecycle, ILifecycle.DeferrableActivation
  Direct Known Subclasses:
    Cache, CacheMonitor, QueueWorker, ReferenceQueueWorker, RollingLog

      public abstract class Worker
      extends Lifecycle

  Since:
    2.0
  Author:
    Eike Stepper

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `Worker.WorkContext`

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

      `ILifecycle.DeferrableActivation`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static IErrorHandler` | `DEFAULT_ERROR_HANDLER`
    `static int` | `DEFAULT_TIMEOUT`

    - ### Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `USE_LABEL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Worker()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doActivate()`
    `protected void` | `doDeactivate()`
    `long` | `getActivationTimeout()`
    `long` | `getDeactivationTimeout()`
    `static IErrorHandler` | `getGlobalErrorHandler()`
    `protected java.lang.String` | `getThreadName()`
    `org.eclipse.net4j.util.concurrent.Worker.WorkerThread` | `getWorkerThread()`
    `protected void` | `handleError(java.lang.Exception ex)`
    `boolean` | `isDaemon()`
    `void` | `setActivationTimeout(long activationTimeout)`
    `void` | `setDaemon(boolean daemon)`
    `void` | `setDeactivationTimeout(long deactivationTimeout)`
    `static IErrorHandler` | `setGlobalErrorHandler(IErrorHandler globalErrorHandler)`
    `protected abstract void` | `work(Worker.WorkContext context)`

    - ### Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeActivate, doBeforeDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString`

    - ### Methods inherited from class org.eclipse.net4j.util.event.Notifier

      `addListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListeners, lastListenerRemoved, removeListener`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.net4j.util.event.INotifier

      `addListener, getListeners, hasListeners, removeListener`

- - ### Field Detail

    - #### DEFAULT_TIMEOUT

          public static final int DEFAULT_TIMEOUT

      See Also:
        Constant Field Values

    - #### DEFAULT_ERROR_HANDLER

          public static final IErrorHandler DEFAULT_ERROR_HANDLER

      Since:
        3.0

  - ### Constructor Detail

    - #### Worker

          public Worker()

  - ### Method Detail

    - #### isDaemon

          public boolean isDaemon()

    - #### setDaemon

          public void setDaemon(boolean daemon)

    - #### getActivationTimeout

          public long getActivationTimeout()

    - #### setActivationTimeout

          public void setActivationTimeout(long activationTimeout)

    - #### getDeactivationTimeout

          public long getDeactivationTimeout()

    - #### setDeactivationTimeout

          public void setDeactivationTimeout(long deactivationTimeout)

    - #### getWorkerThread

          public org.eclipse.net4j.util.concurrent.Worker.WorkerThread getWorkerThread()

      Since:
        3.6

    - #### doActivate

          protected void doActivate()
                             throws java.lang.Exception

      Overrides:
        `doActivate` in class `Lifecycle`
      Throws:
        `java.lang.Exception`

    - #### doDeactivate

          protected void doDeactivate()
                               throws java.lang.Exception

      Overrides:
        `doDeactivate` in class `Lifecycle`
      Throws:
        `java.lang.Exception`

    - #### getThreadName

          protected java.lang.String getThreadName()

    - #### handleError

          protected void handleError(java.lang.Exception ex)

      Since:
        3.1

    - #### work

          protected abstract void work(Worker.WorkContext context)
                                throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### getGlobalErrorHandler

          public static IErrorHandler getGlobalErrorHandler()

      Since:
        3.0

    - #### setGlobalErrorHandler

          public static IErrorHandler setGlobalErrorHandler(IErrorHandler globalErrorHandler)

      Since:
        3.0

Copyright (c) 2004-2019 Eike Stepper (Loehne, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html