* The main run method. This handles the normal thread processing.
*/
public void run() {
boolean interrupted = false;
try {
ServerSocket controlSocket = null;
if (this.controlPort > 0) {
controlSocket = new ServerSocket(this.controlPort);
controlSocket.setSoTimeout(CONTROL_TIMEOUT);
}
Logger.log(Logger.INFO, RESOURCES, "Launcher.StartupOK",
new String[] {RESOURCES.getString("ServerVersion"),
(this.controlPort > 0 ? "" + this.controlPort
: RESOURCES.getString("Launcher.ControlDisabled"))});
// Enter the main loop
while (!interrupted) {
// this.objectPool.removeUnusedRequestHandlers();
// this.hostGroup.invalidateExpiredSessions();
// Check for control request
Socket accepted = null;
try {
if (controlSocket != null) {
accepted = controlSocket.accept();
if (accepted != null) {
handleControlRequest(accepted);
}
} else {
Thread.sleep(CONTROL_TIMEOUT);
}
} catch (InterruptedIOException err) {
} catch (InterruptedException err) {
interrupted = true;
} catch (Throwable err) {
Logger.log(Logger.ERROR, RESOURCES,
"Launcher.ShutdownError", err);
} finally {
if (accepted != null) {
try {accepted.close();} catch (IOException err) {}
}
if (Thread.interrupted()) {
interrupted = true;
}
}
}
// Close server socket
if (controlSocket != null) {
controlSocket.close();
}
} catch (Throwable err) {
Logger.log(Logger.ERROR, RESOURCES, "Launcher.ShutdownError", err);
}
Logger.log(Logger.INFO, RESOURCES, "Launcher.ControlThreadShutdownOK");