@Override
  public String build(IResourceContext ctx, AggregatedJs js) {
    StringBuilder sb = new StringBuilder(128);

    if (m_contextPath != null) {
      sb.append(m_contextPath);
    }

    if (m_servletPath != null) {
      sb.append(m_servletPath);
    }

    IResourceUrn urn = js.getMeta().getUrn();

    sb.append('/').append(urn.getResourceTypeName());
    sb.append('/').append(urn.getNamespace());
    sb.append(urn.getPathInfo());

    sb.append("?urns=");
    sb.append(
        Joiners.by('|')
            .join(
                js.getRef().getRefs(),
                new IBuilder<IJsRef>() {
                  @Override
                  public String asString(IJsRef ref) {
                    return ref.getUrn().toString();
                  }
                }));

    return sb.toString();
  }
Esempio n. 2
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));
    }
  }