public boolean invokeListener(Gateway gateway, String method, Map data) { data = GatewayUtil.toCFML(data); GatewayEntry entry = getGatewayEntry(gateway); String cfcPath = entry.getListenerCfcPath(); if (!Util.isEmpty(cfcPath, true)) { try { if (!callOneWay( cfcPath, gateway.getId(), method, Caster.toStruct(data, null, false), false)) log( gateway, LOGLEVEL_ERROR, "function [" + method + "] does not exist in cfc [" + getCFCDirectory() + toRequestURI(cfcPath) + "]"); else return true; } catch (PageException e) { e.printStackTrace(); log(gateway, LOGLEVEL_ERROR, e.getMessage()); } } else log(gateway, LOGLEVEL_ERROR, "there is no listener cfc defined"); return false; }
public void log(Gateway gateway, int level, String message) { int l = level; switch (level) { case LOGLEVEL_INFO: l = Log.LEVEL_INFO; break; case LOGLEVEL_DEBUG: l = Log.LEVEL_DEBUG; break; case LOGLEVEL_ERROR: l = Log.LEVEL_ERROR; break; case LOGLEVEL_FATAL: l = Log.LEVEL_FATAL; break; case LOGLEVEL_WARN: l = Log.LEVEL_WARN; break; } log.log(l, "Gateway:" + gateway.getId(), message); }
private GatewayEntry getGatewayEntry(Gateway gateway) { String gatewayId = gateway.getId(); // it must exist, because it only can come from here return (GatewayEntry) entries.get(gatewayId); }