}
);
clientThread.start();
// Now that we are up and running, register any MBeans
ManagementService mgmtService = ((ManagementService)
Monitor.getSystemModule(Module.JMX));
final Object versionMBean = mgmtService.registerMBean(
new Version(
getNetProductVersionHolder(),
SystemPermission.SERVER),
VersionMBean.class,
"type=Version,jar=derbynet.jar");
final Object networkServerMBean = mgmtService.registerMBean(
new NetworkServerMBeanImpl(this),
NetworkServerMBean.class,
"type=NetworkServer");
try {
// wait until we are told to shutdown or someone sends an InterruptedException
synchronized(shutdownSync) {
try {
shutdownSync.wait();
}
catch (InterruptedException e)
{
shutdown = true;
}
}
try {
AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
// Need to interrupt the memcheck thread if it is sleeping.
if (mc != null)
mc.interrupt();
//interrupt client thread
clientThread.interrupt();
return null;
}
});
} catch (Exception exception) {
consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
}
// Close out the sessions
synchronized(sessionTable) {
for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
{
Session session = (Session) e.nextElement();
try {
session.close();
} catch (Exception exception) {
consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
}
}
}
synchronized (threadList)
{
//interupt any connection threads still active
for (int i = 0; i < threadList.size(); i++)
{
try {
final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
threadi.close();
AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
threadi.interrupt();
return null;
}
});
} catch (Exception exception) {
consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
}
}
threadList.clear();
}
// close the listener socket
try{
serverSocket.close();
}catch(IOException e){
consolePropertyMessage("DRDA_ListenerClose.S", true);
} catch (Exception exception) {
consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
}
// Wake up those waiting on sessions, so
// they can close down
try{
synchronized (runQueue) {
runQueue.notifyAll();
}
} catch (Exception exception) {
consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
}
// And now unregister any MBeans.
try {
mgmtService.unregisterMBean(versionMBean);
mgmtService.unregisterMBean(networkServerMBean);
} catch (Exception exception) {
consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
}
if (shutdownDatabasesOnShutdown) {