String robotname = "";
if (message.isNetmail()) {
if (MainHandler.getCurrentInstance().getInfo().getAddressList()
.contains(message.getToAddr())) {
// TODO: optiomize
IRobot oRobot = robotMaps
.get(message.getToName().toLowerCase());
if (oRobot == null) {
try {
Robot robot = ORMManager.get(Robot.class).getById(
message.getToName().toLowerCase());
if (robot != null) {
robotname = robot.getRobot();
Class<?> clazz = Class
.forName(robot.getClassName());
oRobot = (IRobot) clazz.newInstance();
robotMaps.put(robotname, oRobot);
logger.l4("Message " + message.getMsgid()
+ " sent to robot " + robotname);
}
} catch (ClassNotFoundException e) {
logger.l2("Robot class not found (INIT) " + robotname,
e);
} catch (Exception e) {
logger.l2(
"Robot excception " + robotname + " (INIT) ",
e);
}
}
if (oRobot != null) {
isRobot = true;
try {
oRobot.execute(message);
} catch (Exception e) {
logger.l2("Robot excception " + robotname
+ " (PROCCESS) ", e);
}
}