@Override
public void execute(Message message) {
if (subscribers.containsKey(message.getTopic())) {
for (Class subscriberClass : subscribers.get(message.getTopic())) {
try {
Subscriber subscriber = (Subscriber)
subscriberClass.newInstance();
subscriber.onMessage(message);
}
catch (IllegalAccessException e) {
logger.error(e.getMessage());
}
catch (InstantiationException e) {
logger.error(e.getMessage());
}
}
}
if (!StringUtils.isEmpty(message.getCommandClassName())) {
try {
Class clazz = loadClass(message.getCommandClassName());
if (clazz != null) {
Subscriber subscriber = (Subscriber)clazz.newInstance();
subscriber.onMessage(message);
}
else {
logger.error("Command class not found: "
+ message.getCommandClassName());
}