org.apache.wicket.markup.html
Class CompressedPackageResource

java.lang.Object
  extended by org.apache.wicket.Resource
      extended by org.apache.wicket.markup.html.WebResource
          extended by org.apache.wicket.markup.html.PackageResource
              extended by org.apache.wicket.markup.html.CompressedPackageResource
All Implemented Interfaces:
Serializable, IClusterable, IRequestListener, IResourceListener, IPackageResourceGuard, IModifiable
Direct Known Subclasses:
JavascriptPackageResource

public class CompressedPackageResource
extends PackageResource

Identical to PackageResource, but supports gzip compression of data See PackageResource and CompressedResourceReference

Author:
Janne Hietamäki
See Also:
Serialized Form

Nested Class Summary
protected  class CompressedPackageResource.CompressingResourceStream
          IResourceStream implementation which compresses the data with gzip if the requests header Accept-Encoding contains string gzip
 
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.PackageResource
PackageResource.PackageResourceBlockedException
 
Field Summary
 
Fields inherited from class org.apache.wicket.markup.html.PackageResource
EXTENSION_CSS, EXTENSION_JS
 
Fields inherited from interface org.apache.wicket.IResourceListener
INTERFACE
 
Constructor Summary
protected CompressedPackageResource(Class<?> scope, String path, Locale locale, String style)
          Hidden constructor.
 
Method Summary
protected  IResourceStream getPackageResourceStream()
          Returns the resource stream of package resource
 IResourceStream getResourceStream()
          IResourceStream implementation which compresses the data with gzip if the requests header Accept-Encoding contains string gzip
static PackageResource newPackageResource(Class<?> scope, String path, Locale locale, String style)
          Create a new PackageResource
protected  IResourceStream newResourceStream()
          Factory method for creating resource stream instance
protected  void setHeaders(WebResponse response)
          Subclasses can override this to set there headers when the resource is being served.
 
Methods inherited from class org.apache.wicket.markup.html.PackageResource
accept, bind, bind, bind, bind, bind, exists, get, get, get, get, getAbsolutePath, getLocale, getPath, getResourceStream, getScope, getStyle, lastModifiedTime, toString
 
Methods inherited from class org.apache.wicket.markup.html.WebResource
configureResponse, getCacheDuration
 
Methods inherited from class org.apache.wicket.Resource
getParameters, invalidate, isCacheable, onResourceRequested, setCacheable, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompressedPackageResource

protected CompressedPackageResource(Class<?> scope,
                                    String path,
                                    Locale locale,
                                    String style)
Hidden constructor.

Parameters:
scope - This argument will be used to get the class loader for loading the package resource, and to determine what package it is in
path - The path to the resource
locale - The locale of the resource
style - The style of the resource
Method Detail

newPackageResource

public static PackageResource newPackageResource(Class<?> scope,
                                                 String path,
                                                 Locale locale,
                                                 String style)
Create a new PackageResource

Parameters:
scope - This argument will be used to get the class loader for loading the package resource, and to determine what package it is in. Typically this is the class in which you call this method
path - The path to the resource
locale - The locale of the resource
style - The style of the resource (see Session)
Returns:
The resource

newResourceStream

protected IResourceStream newResourceStream()
Factory method for creating resource stream instance

Returns:
new stream instance

getPackageResourceStream

protected IResourceStream getPackageResourceStream()
Returns the resource stream of package resource

Returns:
resource stream

getResourceStream

public IResourceStream getResourceStream()
IResourceStream implementation which compresses the data with gzip if the requests header Accept-Encoding contains string gzip

Overrides:
getResourceStream in class PackageResource
Returns:
Gets the resource for the component.
See Also:
PackageResource.getResourceStream()

setHeaders

protected void setHeaders(WebResponse response)
Description copied from class: WebResource
Subclasses can override this to set there headers when the resource is being served. By default 2 headers will be set if the Resource is cacheable
 response.setDateHeader("Expires", System.currentTimeMillis() + (3600 * 1000));
 response.setHeader("Cache-Control", "max-age=" + 3600);
 
So if a resource wants to control this or doesn't want to set this info it should override this method and don't call super.

Overrides:
setHeaders in class WebResource
Parameters:
response - The WebResponse where set(Date)Header can be called on.
See Also:
WebResource.setHeaders(org.apache.wicket.protocol.http.WebResponse)


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.