Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.util

public final Enum ShutdownHook

extends Enum<ShutdownHook>
Class Inheritance
Annotations
@SuppressWarnings:ImmutableEnumChecker
Imports
java.text.MessageFormat, java.util.Set, java.util.concurrent.ConcurrentHashMap, .ExecutionException, .ExecutorService, .Executors, .TimeUnit, .TimeoutException, java.util.concurrent.atomic.AtomicBoolean, org.eclipse.jgit.internal.JGitText, org.slf4j.Logger, .LoggerFactory

The singleton ShutdownHook provides a means to register Listeners that are run when JGit is uninstalled, either

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ShutdownHook.Listener

Object that needs to cleanup on shutdown.

Field Summary

Modifier and TypeField and Description
public static final ShutdownHook
INSTANCE

Singleton

private final Set<ShutdownHook.Listener>
private static final Logger
private final AtomicBoolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
private void
public boolean

Returns:

true if a JGit shutdown is in progress
isShutdownInProgress
()

Whether a JGit shutdown is in progress

private void
public boolean

Returns:

true if this object has been registered
register
(ShutdownHook.Listener
the object to call Listener#onShutdown on when JGit shuts down
l
)

Register object that needs cleanup during JGit shutdown if it is not already registered.

public boolean

Returns:

true if this object is no longer registered
unregister
(ShutdownHook.Listener
the object registered to be notified for cleanup when the JVM shuts down
l
)

Unregister object that no longer needs cleanup during JGit shutdown if it is still registered.

public static ShutdownHook
public static ShutdownHook[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final ShutdownHook INSTANCE

Singleton

listenersback to summary
private final Set<ShutdownHook.Listener> listeners
LOGback to summary
private static final Logger LOG
shutdownInProgressback to summary
private final AtomicBoolean shutdownInProgress

Constructor Detail

ShutdownHookback to summary
private ShutdownHook()

Method Detail

cleanupback to summary
private void cleanup()
doCleanupback to summary
private void doCleanup()
isShutdownInProgressback to summary
public boolean isShutdownInProgress()

Whether a JGit shutdown is in progress

Returns:boolean

true if a JGit shutdown is in progress

notifyback to summary
private void notify(ShutdownHook.Listener l)
registerback to summary
public boolean register(ShutdownHook.Listener l)

Register object that needs cleanup during JGit shutdown if it is not already registered. Registration is disabled when JGit shutdown is already in progress.

Parameters
l:ShutdownHook.Listener

the object to call Listener#onShutdown on when JGit shuts down

Returns:boolean

true if this object has been registered

unregisterback to summary
public boolean unregister(ShutdownHook.Listener l)

Unregister object that no longer needs cleanup during JGit shutdown if it is still registered. Unregistration is disabled when JGit shutdown is already in progress.

Parameters
l:ShutdownHook.Listener

the object registered to be notified for cleanup when the JVM shuts down

Returns:boolean

true if this object is no longer registered

valueOfback to summary
public static ShutdownHook valueOf(String name)
valuesback to summary
public static ShutdownHook[] values()
org.eclipse.jgit.internal.util back to summary

public Interface ShutdownHook.Listener


Object that needs to cleanup on shutdown.

Method Summary

Modifier and TypeMethod and Description
public void
onShutdown()

Cleanup resources when JGit is shut down.

Method Detail

onShutdownback to summary
public void onShutdown()

Cleanup resources when JGit is shut down.

Implementations should be coded defensively

  • they should finish their work quickly
  • they should be written to be thread-safe and to avoid deadlocks insofar as possible
  • they should not rely blindly upon services that may have registered their own shutdown hooks and therefore may themselves be in the process of shutting down
  • attempts to use other thread-based services may lead to deadlocks.
See Runtime#addShutdownHook for more details.