Exemplo n.º 1
0
  protected void prepare(IResourceUrn urn) {
    String path = urn.getResourceId();
    int pos = path.indexOf('/', 1);

    if (pos > 0) {
      String warName = path.substring(1, pos);
      ResourceRuntimeConfig config = ResourceRuntime.INSTANCE.findConfigByWarName(warName);

      if (config == null) {
        String contextPath = path.substring(0, pos);

        config = ResourceRuntime.INSTANCE.getConfig(contextPath);
      }

      if (config != null) {
        m_contextPath = config.getContextPath();
        m_jsBase = config.getContainer().getAttribute(String.class, ResourceConstant.Js.Base);
      } else {
        throw new ResourceException(
            String.format("Js(%s) not found, please make sure war(%s) configured!", urn, warName));
      }
    } else {
      throw new RuntimeException(String.format("Invalid resource urn(%s) found!", urn));
    }
  }