Search in sources :

Example 1 with IResourceVersion

use of org.apache.wicket.request.resource.caching.version.IResourceVersion in project wicket by apache.

the class ContextRelativeResourceCachingTest method init.

private void init(ContextRelativeResource resource, String mountPath) {
    final IResourceVersion resourceVersion = new StaticResourceVersion("123");
    final IResourceCachingStrategy strategy = new FilenameWithVersionResourceCachingStrategy("-version-", resourceVersion);
    tester.getApplication().getSharedResources().add(SHARED_NAME, resource);
    tester.getApplication().getResourceSettings().setCachingStrategy(strategy);
    final ResourceReference resourceReference = new SharedResourceReference(SHARED_NAME);
    tester.getApplication().mountResource(mountPath, resourceReference);
}
Also used : SharedResourceReference(org.apache.wicket.request.resource.SharedResourceReference) StaticResourceVersion(org.apache.wicket.request.resource.caching.version.StaticResourceVersion) IResourceVersion(org.apache.wicket.request.resource.caching.version.IResourceVersion) SharedResourceReference(org.apache.wicket.request.resource.SharedResourceReference) ResourceReference(org.apache.wicket.request.resource.ResourceReference)

Example 2 with IResourceVersion

use of org.apache.wicket.request.resource.caching.version.IResourceVersion in project wicket by apache.

the class ResourceSettings method getCachingStrategy.

/**
 * gets the resource caching strategy
 *
 * @return strategy
 */
public IResourceCachingStrategy getCachingStrategy() {
    if (resourceCachingStrategy == null) {
        final IResourceVersion resourceVersion;
        if (application.usesDevelopmentConfig()) {
            // development mode:
            // use last-modified timestamp of packaged resource for resource caching
            // cache the version information for the lifetime of the current http request
            resourceVersion = new RequestCycleCachedResourceVersion(new LastModifiedResourceVersion());
        } else {
            // deployment mode:
            // use message digest over resource content for resource caching
            // cache the version information for the lifetime of the application
            resourceVersion = new CachingResourceVersion(new MessageDigestResourceVersion());
        }
        // cache resource with a version string in the filename
        resourceCachingStrategy = new FilenameWithVersionResourceCachingStrategy(resourceVersion);
    }
    return resourceCachingStrategy;
}
Also used : FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy) RequestCycleCachedResourceVersion(org.apache.wicket.request.resource.caching.version.RequestCycleCachedResourceVersion) IResourceVersion(org.apache.wicket.request.resource.caching.version.IResourceVersion) LastModifiedResourceVersion(org.apache.wicket.request.resource.caching.version.LastModifiedResourceVersion) CachingResourceVersion(org.apache.wicket.request.resource.caching.version.CachingResourceVersion) MessageDigestResourceVersion(org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion)

Aggregations

IResourceVersion (org.apache.wicket.request.resource.caching.version.IResourceVersion)2 ResourceReference (org.apache.wicket.request.resource.ResourceReference)1 SharedResourceReference (org.apache.wicket.request.resource.SharedResourceReference)1 FilenameWithVersionResourceCachingStrategy (org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy)1 CachingResourceVersion (org.apache.wicket.request.resource.caching.version.CachingResourceVersion)1 LastModifiedResourceVersion (org.apache.wicket.request.resource.caching.version.LastModifiedResourceVersion)1 MessageDigestResourceVersion (org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion)1 RequestCycleCachedResourceVersion (org.apache.wicket.request.resource.caching.version.RequestCycleCachedResourceVersion)1 StaticResourceVersion (org.apache.wicket.request.resource.caching.version.StaticResourceVersion)1