log.info("EC1 Listeners: " + ec.getListeners());
log.info("EC1 Broadcasters: " + ec.getBroadcasters());
// lookup EventNetRouter for our name
EventNetRouter router = ec.getEventNetRouter(initorID);
// Thread t = null;
log.info("=== processid: " + getProcess().getID());
// if exists take over : tell it to stop, get Connector from it and set Buffers on it, then tell EventNetRouter to start
if(router!=null) {
log.info("router != null checkCon: " + checkCon + ", conID: " + conID + ", existing conID: " + router.getConID());
if(checkCon && !conID.equals(router.getConID())) {
try {
error("Agent (" + conID + ") has been taken over by another agent (" + router.getConID() + ")");
} catch(Exception e) {
throw new TakenOverException(e.getMessage());
}
return;
}
router.setConID(conID);
log.info("Stopping current router ...");
router.stop(true);
log.info("ok. getting connector and replacing buffers ...");
EventNetShellAgentConnector con = (EventNetShellAgentConnector) router.getConnector();
con.setOutput(new BufferObjectWriter(getStdOut()));
con.setInput(new BufferObjectReader(getStdIn()));
log.info("ok. Creating new ProcessorThread");
router.start();
log.info("### YAK! This shouldn'0t happen :(.");
return;
// (this will take over our thread and our job is done)
} else {
// if it doesn't exist then we need to instanciate a new EventNetRouter and register it with EventCentral
// Then do same things as with taking over which eventually takes executable's thread inside the last method we call.
if(hostLabel == null) {
error("Host not specified");
return;
}
if(app==null) app = shell.getEnvProperty("PROJECT");
router = new EventNetRouterImpl(ec, initorID, hostLabel, app, keepEvents);
router.setConID(conID);
//ec.registerEventNetRouter(initorID, router);
EventNetShellAgentConnector con = new EventNetShellAgentConnector();
con.setOutput(new BufferObjectWriter(getStdOut()));
con.setInput(new BufferObjectReader(getStdIn()));
router.setConnector(con);
router.start();
// t = new ProcessorThread(router);
// t.start();
}