Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2019

AssetPathConverter is not called for javascript stacks

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Incomplete
    • 5.3.4
    • None
    • tapestry-core

    Description

      (related thread: http://tapestry.1045711.n5.nabble.com/Why-is-AssetPathConverter-not-called-for-javascript-stacks-td5716629.html)

      We use assetpathconverter in order to get assets from CDN(cloudfront).
      However it looks like it's not working for stack assets (but it is for other assets).

      Module:
      binder.bind(AssetPathConverter.class, CDNAssetPathConverter.class).withId("CDNAssetPathConverter");

      public static void contributeServiceOverride(MappedConfiguration<Class,Object> configuration,
      @Local AssetPathConverter assetPathConverter) {
      configuration.add(AssetPathConverter.class, assetPathConverter);
      }

      CDNAssetPathConverter:
      public class CDNAssetPathConverter implements AssetPathConverter {
      private IParameter ip;
      private String applicationVersion;

      public CDNAssetPathConverter(@Inject @Symbol(SymbolConstants.APPLICATION_VERSION) String applicationVersion,
      @Inject IParameter ip)

      { this.applicationVersion = applicationVersion; this.ip = ip; }


      String getCDNDomain()

      { return ip.getString(PKey.DOMAIN_CDN_VERSIONED, null); }


      @Override
      public String convertAssetPath(String assetPath)

      { String domain = getCDNDomain(); if(domain==null) return assetPath; String result = convertToCDN(assetPath, domain); return result; }

      private String convertToCDN(String path, String domain)

      { String _path = path.replaceFirst("^/+", ""); return String.format("http://%s/%s", domain, _path); }

      @Override
      public boolean isInvariant()

      { return false; }

      }

      Howard thought it might be an oversight

      Attachments

        Activity

          People

            Unassigned Unassigned
            magnus@kvalheim.dk Magnus Kvalheim
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: