コード例 #1
0
ファイル: GatewayEngineImpl.java プロジェクト: Fusegrid/railo
  public void remove(GatewayEntry ge) throws GatewayException {
    String id = ge.getId().toLowerCase().trim();
    GatewayEntry existing = (GatewayEntry) entries.remove(id);
    Gateway g = null;

    // does not exist
    if (existing != null) {
      g = existing.getGateway();
      if (g.getState() == Gateway.RUNNING) g.doStop();
    }
  }
コード例 #2
0
ファイル: GatewayEngineImpl.java プロジェクト: Fusegrid/railo
  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;
  }
コード例 #3
0
ファイル: GatewayEngineImpl.java プロジェクト: Fusegrid/railo
  public void addEntry(Config config, GatewayEntry ge)
      throws ClassException, PageException, GatewayException {
    String id = ge.getId().toLowerCase().trim();
    GatewayEntry existing = (GatewayEntry) entries.get(id);
    Gateway g = null;

    // does not exist
    if (existing == null) {
      entries.put(id, load(config, ge));
    }
    // exist but changed
    else if (!existing.equals(ge)) {
      g = existing.getGateway();
      if (g.getState() == Gateway.RUNNING) g.doStop();
      entries.put(id, load(config, ge));
    }
    // not changed
    // else print.out("untouched:"+id);
  }
コード例 #4
0
ファイル: GatewayEngineImpl.java プロジェクト: Fusegrid/railo
 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);
 }
コード例 #5
0
ファイル: GatewayEngineImpl.java プロジェクト: Fusegrid/railo
 private GatewayEntry getGatewayEntry(Gateway gateway) {
   String gatewayId = gateway.getId();
   // it must exist, because it only can come from here
   return (GatewayEntry) entries.get(gatewayId);
 }
コード例 #6
0
ファイル: GatewayEngineImpl.java プロジェクト: Fusegrid/railo
 /**
  * send the message to the gateway
  *
  * @param gatewayId
  * @param data
  * @return
  * @throws PageException
  */
 public String sendMessage(String gatewayId, Struct data) throws PageException, GatewayException {
   Gateway g = getGateway(gatewayId);
   if (g.getState() != Gateway.RUNNING)
     throw new GatewayException("Gateway [" + gatewayId + "] is not running");
   return g.sendMessage(data);
 }