java.lang.Object
com.atlassian.plugin.webresource.impl.config.Config

public class Config extends Object
Unites all the configurations in one place. Not exposed as API, so it is possible to change it and store settings that should not be exposed publicly.
Since:
3.3
  • Field Details

  • Constructor Details

  • Method Details

    • isContextKey

      public static boolean isContextKey(String key)
      If the key is context or web resource key.
    • virtualContextKeyToWebResourceKey

      public static String virtualContextKeyToWebResourceKey(String virtualContextKey)
      Convert virtual context key to web resource key.
    • getResourceLocations

      protected static List<com.atlassian.plugin.elements.ResourceLocation> getResourceLocations(WebResourceModuleDescriptor webResourceModuleDescriptor, boolean compiledResourcesEnabled)
    • isStaticContextOrderEnabled

      public static boolean isStaticContextOrderEnabled()
      Determines if batch URLs contexts' are sorted to ensure that the same URL is generated no matter what order the contexts are required in.
      Since:
      3.6.0
    • getPluginVersionOrInstallTime

      public static String getPluginVersionOrInstallTime(com.atlassian.plugin.Plugin plugin, boolean usePluginInstallTimeInsteadOfTheVersionForSnapshotPlugins)
      For SNAPSHOT plugins will return install time instead of the version. Needed to simplify working with SNAPSHOT plugins and flushing cache when new SNAPSHOT plugin installed with same version but different content.
    • setContentTypeResolver

      public void setContentTypeResolver(com.atlassian.plugin.servlet.ContentTypeResolver contentTypeResolver)
      Needed because `contentTypeResolver` isn't available at the time Config is created and set up a bit later.
    • isContentCacheEnabled

      public boolean isContentCacheEnabled()
      Returns:
      if cache should be enabled.
    • getContentCacheSize

      public int getContentCacheSize()
      Returns:
      amount of files to be stored in cache.
    • getIncrementalCacheSize

      public int getIncrementalCacheSize()
      Returns:
      amount of files to be stored in cache.
    • getCacheDirectory

      public File getCacheDirectory()
      Returns:
      directory where cache content would be stored as files.
    • getDependencyGraph

      @Nonnull public static DependencyGraph<Requestable> getDependencyGraph()
    • isSourceMapEnabledFor

      public boolean isSourceMapEnabledFor(String typeOrContentType)
      Parameters:
      typeOrContentType - type or content type.
      Returns:
      if source map enabled for this type or content type.
    • isSourceMapEnabled

      public boolean isSourceMapEnabled()
      Returns:
      if source map enabled.
    • isCdnEnabled

      public boolean isCdnEnabled()
      Returns:
      if CDN is globally enabled.
    • getBaseUrl

      public String getBaseUrl()
      Returns:
      base url, where web resources is mounted to.
    • getBaseUrl

      public String getBaseUrl(boolean isAbsolute)
      Parameters:
      isAbsolute - if url should be absolute or relative.
      Returns:
      base url, where web resources is mounted to.
    • getResourceUrlPrefix

      public String getResourceUrlPrefix(String hash, String bundleHash, boolean isAbsolute)
      Returns:
      url prefix for resource, including base url.
    • getResourceCdnPrefix

      public String getResourceCdnPrefix(String url)
      Returns:
      url prefixed with CDN prefix.
    • getContentType

      public String getContentType(String path)
      Returns:
      content type for given path.
    • getContentAnnotator

      public ResourceContentAnnotator getContentAnnotator(String type)
      Returns:
      content annotators for given type.
    • getStaticTransformers

      public StaticTransformers getStaticTransformers()
      Returns:
      static transformers.
    • setStaticTransformers

      public void setStaticTransformers(StaticTransformers staticTransformers)
    • isSyncContextCreated

      public boolean isSyncContextCreated()
      Returns:
      true if sync context has been created (is not empty)
      Throws:
      RuntimeException - if called before getWebResourcesWithoutCache().
      Since:
      3.5.27
    • isSuperbatchCreated

      public boolean isSuperbatchCreated()
      Returns:
      true if superbatch context has been created (is not empty)
      Throws:
      RuntimeException - if called before getWebResourcesWithoutCache().
      Since:
      5.5.0
    • getWebResourcesWithoutCache

      public Snapshot getWebResourcesWithoutCache()
      Analyzes current state of the plugin system and return web resources.
    • getResourcesWithoutCache

      public LinkedHashMap<String,Resource> getResourcesWithoutCache(Bundle bundle)
      Queries the plugin system and return list of Resources for Web Resource.
    • getWebResourceData

      public LinkedHashMap<String,com.atlassian.json.marshal.Jsonable> getWebResourceData(String key)
      Get data resources for web resource.
    • isMinificationEnabled

      public boolean isMinificationEnabled()
      If minification enabled.
    • buildResource

      protected Resource buildResource(Bundle bundle, com.atlassian.plugin.elements.ResourceLocation resourceLocation)
      Helper to hide bunch of integration code and simplify resource creation.
    • getModuleResource

      public Resource getModuleResource(String completeKey, String name)
      Get not declared Resource.
    • getPluginResource

      public Resource getPluginResource(String pluginKey, String name)
      Get Resource for Plugin.
    • optimiseSourceMapsForDevelopment

      public boolean optimiseSourceMapsForDevelopment()
    • isSyncBatchingEnabled

      public boolean isSyncBatchingEnabled()
    • isSuperBatchingEnabled

      public boolean isSuperBatchingEnabled()
    • isBatchContentTrackingEnabled

      public boolean isBatchContentTrackingEnabled()
    • isContextBatchingEnabled

      public boolean isContextBatchingEnabled()
    • isWebResourceBatchingEnabled

      public boolean isWebResourceBatchingEnabled()
    • isIncrementalCacheEnabled

      public boolean isIncrementalCacheEnabled()
      If incremental cache enabled.
    • partialHashCode

      public int partialHashCode()
      Hash code representing the state of config. State of the system could change not only on plugin system changes but also some properties of config could change too. In such cases the cache additionally checked against the version of config it's build for.

      Strictly speaking this hash should include the full state of config, but it would be too slow, so instead we check only for some of its properties.

    • getIntegration

      @Deprecated public WebResourceIntegration getIntegration()
      Deprecated.
      since 3.3.2
    • getTransformerCache

      @Deprecated public TransformerCache getTransformerCache()
      Deprecated.
      since 3.3.2
    • getUrlCacheSize

      public int getUrlCacheSize()
    • getBatchingConfiguration

      @Deprecated public ResourceBatchingConfiguration getBatchingConfiguration()
      Deprecated.
    • isDeferJsAttributeEnabled

      @Deprecated public boolean isDeferJsAttributeEnabled()
      Deprecated.
      since 5.0.0, use ResourcePriority.DEFER instead
    • computeGlobalStateHash

      public String computeGlobalStateHash()
      Represents product state considering everything that contributes to content of resources.
      Since:
      v3.5.0
    • getBeforeAllResources

      public List<String> getBeforeAllResources()
    • getCdnResourceUrlTransformer

      public CdnResourceUrlTransformer getCdnResourceUrlTransformer()
      Returns a URL transformer to allow clients to map resource URLs as in getResourceCdnPrefix(String).
      Since:
      v3.5.0
    • isBundleHashValidationEnabled

      public static boolean isBundleHashValidationEnabled()
      Determines if bundle hash validation for batch resources should be disabled.
      Since:
      4.3.5
    • isJavaScriptTryCatchWrappingEnabled

      public boolean isJavaScriptTryCatchWrappingEnabled()
    • isUrlCachingEnabled

      public boolean isUrlCachingEnabled()
      Returns:
      true if URL caching should be used.
    • getResourceFactory

      public ResourceFactory getResourceFactory()
    • isPerformanceTrackingEnabled

      public boolean isPerformanceTrackingEnabled()
      Returns:
      true if it should track performance/caching stats
    • getBooleanFromDarkFeatureManagerThenSystemProperty

      protected boolean getBooleanFromDarkFeatureManagerThenSystemProperty(String name)
      Will do its best to return a result from DarkFeatureManager, but will fallback to System properties

      Exists to de-couple the WRM from how products manage properties without having to add extra integration work during adoption to the WebResourceIntegration SPI

      Parameters:
      name - of the system property
      Returns:
      true if flag is on