MinaLoginMessageListener login = new MinaLoginMessageListener();
login.setGateway(gateway);
login.setLoginHandler(new SystemLoginHandler());
gateway.addMessageListener(login);
MinaConnectStateListener connect = new MinaConnectStateListener();
connect.setGateway(gateway);
gateway.addMessageListener(connect);
MinaHeartbeatListener heartbeat = new MinaHeartbeatListener();
heartbeat.setHeartbeatContainer(heartbeatContainer);
heartbeat.setGateway(gateway);