Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.caucho.util
Class Exit

    java.lang.Object
      |
      +--com.caucho.util.Exit

public class Exit
extends java.lang.Object
implements AlarmListener

The exit class is used to automatically clean state. For example, Resin JavaScript will close open files when the script exits. Here's a sample use:

       boolean isExit = addExit();
       try {
         ...
       } finally {
         if (isExit)
           exit();
       }

Objects register for the exit callback by calling `addExit(listener, object)`.

Exits are intrinsically tied to a thread.

Method Summary
`static boolean` | `addExit()` Starts a protection scope.
`static void` | `addExit(ExitListener listener, java.lang.Object object)` Registers the object and listener.
`static void` | `exit()` Calls all registered listeners.
`void` | `handleAlarm(Alarm alarm)` A paranoid callback to clean up exits for threads which have died for some reason.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### addExit

    public static void addExit(ExitListener listener,
                               java.lang.Object object)

  Registers the object and listener. The listener will be called when the thread exits the scope.

  If there is no protection scope, i.e. addExit() hasn't been called, then this function does nothing.

  Parameters:
    `listener` - the exit handler
    `object` - the object which needs cleanup

### addExit

    public static boolean addExit()

  Starts a protection scope. Only the outermost scope is important, so protecting routines must check the return value to see if they are the outermost scope.
  Returns:
    true if this is the outermost scope.

### exit

    public static void exit()

  Calls all registered listeners.

### handleAlarm

    public void handleAlarm(Alarm alarm)

  A paranoid callback to clean up exits for threads which have died for some reason.
  Specified by:
    handleAlarm in interface AlarmListener

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD