コード例 #1
0
  @SuppressWarnings("unchecked")
  public void deploy(VFSDeploymentUnit unit) throws DeploymentException {
    TorqueBoxMetaData globalMetaData = unit.getAttachment(TorqueBoxMetaData.class);

    log.debug("Global torquebox.yml: " + globalMetaData);

    Object data = null;

    if (globalMetaData != null) {
      data = globalMetaData.getSection(getSectionName());
      log.debug("Global data section for " + getSectionName() + ": " + data);
    }

    if (data == null && isSupportsStandalone()) {
      VirtualFile metaDataFile = getMetaDataFile(unit, getFileName());

      if ((metaDataFile != null) && metaDataFile.exists()) {
        log.warn("Usage of " + getFileName() + " is deprecated.  Please use torquebox.yml.");
        InputStream in = null;
        try {
          in = metaDataFile.openStream();
          Yaml yaml = new Yaml();
          data = (Map<String, ?>) yaml.load(in);
        } catch (YAMLException e) {
          log.warn("Error parsing: " + metaDataFile + ": " + e.getMessage());
          data = null;
        } catch (IOException e) {
          throw new DeploymentException(e);
        } finally {
          if (in != null) {
            try {
              in.close();
            } catch (IOException e) {
              throw new DeploymentException(e);
            }
          }
        }
      }
    }

    if (data == null) {
      return;
    }

    try {
      parse(unit, data);
    } catch (DeploymentException e) {
      throw e;
    } catch (Exception e) {
      throw new DeploymentException(e);
    }
  }
コード例 #2
0
  public void deploy(VFSDeploymentUnit unit) throws DeploymentException {
    VirtualFile file = unit.getMetaDataFile("ruby.yml");

    if (file != null) {
      try {
        RubyRuntimeMetaData runtimeMetaData = unit.getAttachment(RubyRuntimeMetaData.class);
        if (runtimeMetaData != null) {
          parse(unit, file, runtimeMetaData);
        }
      } catch (Exception e) {
        throw new DeploymentException(e);
      }
    }
  }
コード例 #3
0
  @SuppressWarnings("unchecked")
  public void parse(VFSDeploymentUnit unit, Object dataObj) throws Exception {
    log.debug("Deploying ruby application: " + unit);
    log.info("UNIT.root: " + unit.getRoot());
    log.info("UNIT.root.uri: " + unit.getRoot().toURI());
    log.info("UNIT.root.uri.url: " + unit.getRoot().toURI().toURL());
    log.info("UNIT.root.uri.url.ext: " + unit.getRoot().toURI().toURL().toExternalForm());

    RubyApplicationMetaData appMetaData = unit.getAttachment(RubyApplicationMetaData.class);

    if (appMetaData == null) {
      log.debug("Configuring ruby application: " + unit);
      appMetaData = new RubyApplicationMetaData();
      appMetaData.setApplicationName(unit.getSimpleName());
      unit.addAttachment(RubyApplicationMetaData.class, appMetaData);
    } else {
      log.debug("Configuring pre-existing ruby application: " + unit + "\n  " + appMetaData);
    }

    Map<String, String> app = (Map<String, String>) dataObj;

    if (appMetaData.getRoot() == null) {
      String root = getOneOf(app, "root", "RAILS_ROOT", "RACK_ROOT");

      if (root != null && !root.trim().equals("")) {
        appMetaData.setRoot(root.trim());
      }
    }

    if (appMetaData.getEnvironmentName() == null) {
      String env = getOneOf(app, "env", "RAILS_ENV", "RACK_ENV");

      if (env != null && !env.trim().equals("")) {
        appMetaData.setEnvironmentName(env.trim());
      }
    }
    log.debug("Configured ruby application: " + unit + "\n  " + appMetaData);
  }