use of com.swiftmq.impl.routing.single.manager.po.PORemoveAllObject in project swiftmq-ce by iitsoftware.
the class RoutingSwiftletImpl method shutdown.
protected void shutdown() throws SwiftletException {
// true when shutdown while standby
if (ctx == null)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "shutdown ...");
removeAllRoutes();
removeAllRoutingListeners();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopping connectors ...");
EntityList connectorList = (EntityList) root.getEntity("connectors");
String[] outboundNames = connectorList.getEntityNames();
if (outboundNames != null) {
for (int i = 0; i < outboundNames.length; i++) {
Entity entity = connectorList.getEntity(outboundNames[i]);
if (((Boolean) entity.getProperty("enabled").getValue()).booleanValue()) {
ConnectorMetaData meta = (ConnectorMetaData) entity.getUserObject();
ctx.networkSwiftlet.removeTCPConnector(meta);
}
}
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopping listeners ...");
EntityList listenerList = (EntityList) root.getEntity("listeners");
String[] inboundNames = listenerList.getEntityNames();
if (inboundNames != null) {
for (int i = 0; i < inboundNames.length; i++) {
ListenerMetaData meta = (ListenerMetaData) listenerList.getEntity(inboundNames[i]).getUserObject();
ctx.networkSwiftlet.removeTCPListener(meta);
}
}
Connection[] c = (Connection[]) connections.toArray(new Connection[connections.size()]);
if (c.length > 0)
shutdownSem = new Semaphore();
for (int i = 0; i < c.length; i++) {
ctx.networkSwiftlet.getConnectionManager().removeConnection(c[i]);
}
if (shutdownSem != null) {
System.out.println("+++ Waiting for Connection Termination ...");
shutdownSem.waitHere();
shutdownSem = null;
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopping connection manager ...");
Semaphore sem = new Semaphore();
ctx.connectionManager.enqueue(new PORemoveAllObject(null, sem));
sem.waitHere(60000);
ctx.connectionManager.close();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "stopping schedulers ...");
ctx.schedulerRegistry.close();
passwords = null;
connectionEntities = null;
connections = null;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "shutdown done");
ctx = null;
}
Aggregations