/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ShutdownManager.java,v 1.7 2008/10/04 00:36:44 veiming Exp $
*
* Portions Copyrighted 2011-2015 ForgeRock AS.
*/
/**
* ShutdownManager is a static instance which is used to trigger all the
* ShutdownListener to call shutdown function.
*/
protected volatile boolean shutdownCalled;
/**
* Constructor of ShutdownManager.
*/
private ShutdownManager() {
shutdownCalled = false;
for (int i = 0; i < size; i++) {
}
if (hooksEnabled) {
// add the trigger for stand alone application to shutdown.
new Runnable() {
public void run() {
shutdown();
}
}, "ShutdownThread"));
}
}
/**
* Acquire the lock of this ShutdownManager. The function will block if
* other thread is holding the lock or return false if shutdown is called.
*
* @return a boolean to indicate whether it success.
*/
private boolean acquireValidLock() {
if (shutdownCalled) {
return false;
} else {
}
return true;
}
/**
* Release the lock of this ShutdownManager. IllegalMonitorStateException
* will be thrown if the current thread is not holding the lock.
*/
private void releaseLockAndNotify() throws
}
/**
* Returns the static instance of ShutdownManager in the VM.
*
* @return The static instance of ShutdownManager
*/
instance = new ShutdownManager();
}
return instance;
}
/**
* Adds a ShutdownListener to this ShutdownManager.
*
* @param listener The listener to be added
*/
}
/**
* Adds a ShutdownListener to this ShutdownManager with indicated level.
*
* @param listener The listener to be added
* @param priority The priority to shutdown for the shutdown listener
*/
throws IllegalMonitorStateException {
if (acquireValidLock()) {
try {
} finally {
}
} else {
throw new IllegalMonitorStateException("Failed to acquire lock registering the ShutdownListener");
}
}
/**
* Replaces an existing ShutdownListener with the new ShutdownListener.
*
* @param oldListener To be replaced.
* @param newListener The replacement.
* @param priority Replacement listeners priority. If null default addShutdownListener method will be used.
*/
if (acquireValidLock()) {
try {
} else {
}
} finally {
}
} else {
throw new IllegalMonitorStateException("Failed to acquire lock replacing the ShutdownListener");
}
}
/**
* Removes a ShutdownListener from this ShutdownManager.
*
* @param listener The listener to be removed
*/
if (acquireValidLock()) {
try {
break;
}
}
} finally {
}
} else {
throw new IllegalMonitorStateException("Failed to acquire lock unregistering with ShutdownListener");
}
}
/**
* Shuts down all the listeners in this ShutdownManager.
*/
if (acquireValidLock()) {
try {
shutdownCalled = true;
for (ShutdownPriority i : priorities) {
// remove the components which have been shutdown to avoid
// problem when the shutdown function is called twice.
j.remove();
}
}
if (appSSOTokenDestroyer != null) {
}
} catch (RuntimeException t) {
throw t;
} finally {
}
} else {
throw new IllegalMonitorStateException("Failed to acquire lock during shutdown.");
}
}
/**
* Adds application single-sign-on token destroyer.
*
* @param listener Listener object.
*/
}
}