Repository: wicket Updated Branches: refs/heads/master 548bcbe66 -> 4468ef935
WICKET-5819 Improvements - readBuffered, javadoc Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/4468ef93 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/4468ef93 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/4468ef93 Branch: refs/heads/master Commit: 4468ef93508f1413daf42167bff2e2b648baf9ef Parents: 548bcbe Author: Tobias Soloschenko <[email protected]> Authored: Sat May 23 15:51:55 2015 +0200 Committer: Tobias Soloschenko <[email protected]> Committed: Wed May 27 19:55:08 2015 +0200 ---------------------------------------------------------------------- .../apache/wicket/markup/html/image/Image.java | 50 ++++++-- .../apache/wicket/markup/html/image/Source.java | 45 ++++++- .../markup/html/media/MediaComponent.java | 122 +++++++++++++++--- .../apache/wicket/markup/html/media/Source.java | 83 +++++++++++- .../apache/wicket/markup/html/media/Track.java | 102 ++++++++++++++- .../wicket/markup/html/media/audio/Audio.java | 100 ++++++++++++++- .../wicket/markup/html/media/video/Video.java | 100 ++++++++++++++- .../request/resource/AbstractResource.java | 5 +- .../request/resource/PackageResource.java | 128 ++++++++++++++----- .../resource/PackageResourceReference.java | 79 ++++++++---- .../request/resource/PartWriterCallback.java | 48 ++++++- .../org/apache/wicket/examples/media/Home.html | 2 +- .../org/apache/wicket/examples/media/Home.java | 4 +- .../org/apache/wicket/examples/media/video.mp4 | Bin 2757913 -> 0 bytes .../org/apache/wicket/examples/media/video1.mp4 | Bin 0 -> 2757913 bytes .../org/apache/wicket/examples/media/video2.mp4 | Bin 0 -> 2757913 bytes .../src/docs/guide/resources/resources_3.gdoc | 4 +- 17 files changed, 755 insertions(+), 117 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java index fdf1f76..7504a53 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java @@ -59,17 +59,33 @@ public class Image extends WebComponent implements IResourceListener * @see {@link #setCrossOrigin(Cors)} */ public enum Cors { + /** + * no authentication required + */ ANONYMOUS("anonymous"), + /** + * user credentials required + */ USE_CREDENTIALS("user-credentials"), + /** + * no cross origin + */ NO_CORS(""); private final String realName; - private Cors(String realName) { + private Cors(String realName) + { this.realName = realName; } - public String getRealName() { + /** + * Gets the real name for the cors option + * + * @return the real name + */ + public String getRealName() + { return realName; } } @@ -247,8 +263,11 @@ public class Image extends WebComponent implements IResourceListener /** * @param resourceReference * The resource reference to set. + * @param parameters + * the parameters to be applied to the localized image resource */ - public void setImageResourceReference(final ResourceReference resourceReference, final PageParameters parameters) + public void setImageResourceReference(final ResourceReference resourceReference, + final PageParameters parameters) { if (localizedImageResource != null) { @@ -385,7 +404,8 @@ public class Image extends WebComponent implements IResourceListener buildSizesAttribute(tag); Cors crossOrigin = getCrossOrigin(); - if (crossOrigin != null && Cors.NO_CORS != crossOrigin) { + if (crossOrigin != null && Cors.NO_CORS != crossOrigin) + { tag.put("crossOrigin", crossOrigin.getRealName()); } } @@ -414,9 +434,8 @@ public class Image extends WebComponent implements IResourceListener // If there are xValues set process them in the applied order to the srcset attribute. if (xValues != null) { - xValue = xValues.size() > srcSetPosition && - xValues.get(srcSetPosition) != null ? " " + - xValues.get(srcSetPosition) : ""; + xValue = xValues.size() > srcSetPosition && xValues.get(srcSetPosition) != null + ? " " + xValues.get(srcSetPosition) : ""; } tag.put("srcset", (srcset != null ? srcset + ", " : "") + tag.getAttribute("src") + xValue); @@ -561,7 +580,8 @@ public class Image extends WebComponent implements IResourceListener * * @return the cross origins settings */ - public Cors getCrossOrigin() { + public Cors getCrossOrigin() + { return crossOrigin; } @@ -569,17 +589,21 @@ public class Image extends WebComponent implements IResourceListener * Sets the cross origin settings<br> * <br> * - * <b>ANONYMOUS</b>: Cross-origin CORS requests for the element will not have the credentials flag set.<br> + * <b>ANONYMOUS</b>: Cross-origin CORS requests for the element will not have the credentials + * flag set.<br> * <br> - * <b>USE_CREDENTIALS</b>: Cross-origin CORS requests for the element will have the credentials flag set.<br> + * <b>USE_CREDENTIALS</b>: Cross-origin CORS requests for the element will have the credentials + * flag set.<br> * <br> - * <b>no_cores</b>: The empty string is also a valid keyword, and maps to the Anonymous state. The attribute's invalid value default is the - * Anonymous state. The missing value default, used when the attribute is omitted, is the No CORS state + * <b>NO_CORS</b>: The empty string is also a valid keyword, and maps to the Anonymous state. + * The attribute's invalid value default is the Anonymous state. The missing value default, used + * when the attribute is omitted, is the No CORS state * * @param crossOrigin * the cross origins settings to set */ - public void setCrossOrigin(Cors crossOrigin) { + public void setCrossOrigin(Cors crossOrigin) + { this.crossOrigin = crossOrigin; } http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Source.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Source.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Source.java index 76ea0de..713309a 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Source.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Source.java @@ -40,6 +40,10 @@ public class Source extends Image private String media = null; /** + * Creates a source for a picture + * + * @param id + * the component id * @see org.apache.wicket.markup.html.image.Image */ protected Source(final String id) @@ -48,6 +52,12 @@ public class Source extends Image } /** + * Creates a source for a picture + * + * @param id + * the component id + * @param resourceReferences + * the resource references applied to the source in the given order * @see org.apache.wicket.markup.html.image.Image */ public Source(final String id, final ResourceReference... resourceReferences) @@ -56,6 +66,14 @@ public class Source extends Image } /** + * Creates a source for a picture + * + * @param id + * the component id + * @param resourceParameters + * the resource parameters applied to the localized image resource + * @param resourceReferences + * the resource references applied to the source in the given order * @see org.apache.wicket.markup.html.image.Image */ public Source(final String id, PageParameters resourceParameters, @@ -65,6 +83,12 @@ public class Source extends Image } /** + * Creates a source for a picture + * + * @param id + * the component id + * @param imageResources + * the image resources applied to the source in the given order * @see org.apache.wicket.markup.html.image.Image */ public Source(final String id, final IResource... imageResources) @@ -73,6 +97,12 @@ public class Source extends Image } /** + * Creates a source for a picture + * + * @param id + * the component id + * @param model + * the internally used model * @see org.apache.wicket.Component#Component(String, IModel) */ public Source(final String id, final IModel<?> model) @@ -81,6 +111,12 @@ public class Source extends Image } /** + * Creates a source for a picture + * + * @param id + * the component id + * @param string + * the string used as model * @see org.apache.wicket.markup.html.image.Image */ public Source(final String id, final String string) @@ -124,15 +160,18 @@ public class Source extends Image * Unsupported for source tag */ @Override - public void setCrossOrigin(Cors crossorigin) { - throw new UnsupportedOperationException("It is not allowed to set the crossorigin attribute for source tag"); + public void setCrossOrigin(Cors crossorigin) + { + throw new UnsupportedOperationException( + "It is not allowed to set the crossorigin attribute for source tag"); } /** * Unsupported for source tag */ @Override - public final Cors getCrossOrigin() { + public final Cors getCrossOrigin() + { return null; } } http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/markup/html/media/MediaComponent.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/MediaComponent.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/MediaComponent.java index a6ef048..96d757b 100755 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/MediaComponent.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/MediaComponent.java @@ -43,9 +43,19 @@ public abstract class MediaComponent extends WebMarkupContainer * * @see {@link #setCrossOrigin(Cors)} */ - public enum Cors - { - ANONYMOUS("anonymous"), USER_CREDENTIALS("user-credentials"), NO_CORS(""); + public enum Cors { + /** + * no authentication required + */ + ANONYMOUS("anonymous"), + /** + * user credentials required + */ + USER_CREDENTIALS("user-credentials"), + /** + * no cross origin + */ + NO_CORS(""); private final String realName; @@ -54,6 +64,11 @@ public abstract class MediaComponent extends WebMarkupContainer this.realName = realName; } + /** + * Gets the real name for the cors option + * + * @return the real name + */ public String getRealName() { return realName; @@ -65,17 +80,32 @@ public abstract class MediaComponent extends WebMarkupContainer * * @see {@link #setPreload(Preload)} */ - public enum Preload - { - NONE("none"), METADATA("metadata"), AUTO("auto"); + public enum Preload { + /** + * preloads nothing + */ + NONE("none"), + /** + * preloads only meta data like first picture, etc. + */ + METADATA("metadata"), + /** + * auto detection what is going to be preload + */ + AUTO("auto"); - public final String realName; + private final String realName; private Preload(String realname) { realName = realname; } + /** + * Gets the real name for the preload option + * + * @return the real name + */ public String getRealName() { return realName; @@ -131,47 +161,107 @@ public abstract class MediaComponent extends WebMarkupContainer } /** - * Constructor. + * Creates a media component * * @param id * The component id * @param resourceReference + * the package resource reference of the media file */ public MediaComponent(String id, PackageResourceReference resourceReference) { this(id, null, null, null, resourceReference); } - public MediaComponent(String id, IModel<?> model, - PackageResourceReference resourceReference) + /** + * Creates a media component + * + * @param id + * The component id + * @param model + * the internally used model + * @param resourceReference + * the package resource reference of the media file + */ + public MediaComponent(String id, IModel<?> model, PackageResourceReference resourceReference) { this(id, model, null, null, resourceReference); } - public MediaComponent(String id, - PackageResourceReference resourceReference, + /** + * Creates a media component + * + * @param id + * The component id + * @param resourceReference + * the package resource reference of the media file + * @param pageParameters + * the page parameters to be used to be prepended to the media URL + */ + public MediaComponent(String id, PackageResourceReference resourceReference, PageParameters pageParameters) { this(id, null, null, pageParameters, resourceReference); } - public MediaComponent(String id, IModel<?> model, - PackageResourceReference resourceReference, + /** + * Creates a media component + * + * @param id + * The component id + * @param model + * the internally used model + * @param resourceReference + * the package resource reference of the media file + * @param pageParameters + * the page parameters to be used to be prepended to the media URL + */ + public MediaComponent(String id, IModel<?> model, PackageResourceReference resourceReference, PageParameters pageParameters) { this(id, model, null, pageParameters, resourceReference); } + /** + * Creates a media component + * + * @param id + * The component id + * @param url + * an external URL to be used for the media component + */ public MediaComponent(String id, String url) { this(id, null, url, null, null); } + /** + * Creates a media component + * + * @param id + * The component id + * @param model + * the internally used model + * @param url + * an external URL to be used for the media component + */ public MediaComponent(String id, IModel<?> model, String url) { this(id, model, url, null, null); } + /** + * Creates a media component + * + * @param id + * The component id + * @param model + * the internally used model + * @param url + * an external URL to be used for the media component + * @param pageParameters + * the page parameters to be used to be prepended to the media URL + */ public MediaComponent(String id, IModel<?> model, String url, PageParameters pageParameters) { this(id, model, url, pageParameters, null); @@ -201,8 +291,8 @@ public abstract class MediaComponent extends WebMarkupContainer if (resourceReference != null) { - CharSequence urlToMediaReference = RequestCycle.get().urlFor( - resourceReference, pageParameters); + CharSequence urlToMediaReference = RequestCycle.get().urlFor(resourceReference, + pageParameters); tag.put("src", urlToMediaReference + timeManagement); } else if (url != null) http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Source.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Source.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Source.java index fb2c467..4abdca9 100755 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Source.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Source.java @@ -48,52 +48,122 @@ public class Source extends WebMarkupContainer private final String url; + /** + * Creates a source + * + * @param id + * the component id + */ public Source(String id) { this(id, null, null, null, null); } + /** + * Creates a source + * + * @param id + * the component id + * @param model + * the internally used model + */ public Source(String id, IModel<?> model) { this(id, model, null, null, null); } + /** + * Creates a source + * + * @param id + * the component id + * @param resourceReference + * the resource reference to provide the source data + */ public Source(String id, PackageResourceReference resourceReference) { this(id, null, null, null, resourceReference); } - public Source(String id, IModel<?> model, - PackageResourceReference resourceReference) + /** + * Creates a source + * + * @param id + * the component id + * @param model + * the internally used model + * @param resourceReference + * the resource reference to provide the source data + */ + public Source(String id, IModel<?> model, PackageResourceReference resourceReference) { this(id, model, null, null, resourceReference); } + /** + * Creates a source + * + * @param id + * the component id + * @param pageParameters + * the the page parameters applied to the source URL + * @param resourceReference + * the resource reference to provide the source data + */ public Source(String id, PackageResourceReference resourceReference, PageParameters pageParameters) { this(id, null, null, pageParameters, resourceReference); } - public Source(String id, IModel<?> model, - PackageResourceReference resourceReference, + /** + * Creates a source + * + * @param id + * the component id + * @param model + * the internally used model + * @param resourceReference + * the resource reference to provide the source data + * @param pageParameters + * the the page parameters applied to the source URL + */ + public Source(String id, IModel<?> model, PackageResourceReference resourceReference, PageParameters pageParameters) { this(id, model, null, pageParameters, resourceReference); } + /** + * Creates a source + * + * @param id + * the component id + * @param url + * an external URL to provide the source information + */ public Source(String id, String url) { this(id, null, url, null, null); } + /** + * Creates a source + * + * @param id + * the component id + * @param model + * the internally used model + * @param url + * an external URL to provide the source information + */ public Source(String id, IModel<?> model, String url) { this(id, model, url, null, null); } private Source(String id, IModel<?> model, String url, PageParameters pageParameters, - PackageResourceReference resourceReference) + PackageResourceReference resourceReference) { super(id, model); this.url = url; @@ -111,7 +181,8 @@ public class Source extends WebMarkupContainer { CharSequence url = RequestCycle.get().urlFor(resourceReference, pageParameters); tag.put("src", url); - } else if (url != null) + } + else if (url != null) { tag.put("src", url); } http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Track.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Track.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Track.java index c41217a..9b053bf 100755 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Track.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/Track.java @@ -39,10 +39,27 @@ public class Track extends WebMarkupContainer /** * To be used for the kind attribute */ - public enum Kind - { - SUBTITLES("subtitles"), CAPTIONS("captions"), DESCRIPTIONS("descriptions"), CHAPTERS( - "chapters"), METADATA("metadata"); + public enum Kind { + /** + * the track is used for subtitles + */ + SUBTITLES("subtitles"), + /** + * the track is used for captions + */ + CAPTIONS("captions"), + /** + * the track is used for descriptions + */ + DESCRIPTIONS("descriptions"), + /** + * the track is used for chapters + */ + CHAPTERS("chapters"), + /** + * the track is used to provide metadata + */ + METADATA("metadata"); private String realName; @@ -51,6 +68,11 @@ public class Track extends WebMarkupContainer this.realName = realName; } + /** + * The real name of the kind + * + * @return the real name + */ public String getRealName() { return realName; @@ -71,42 +93,114 @@ public class Track extends WebMarkupContainer private final PageParameters pageParameters; + /** + * Creates a track + * + * @param id + * the component id + */ public Track(String id) { this(id, null, null, null, null); } + /** + * Creates a track + * + * @param id + * the component id + * @param model + * the internally used model + */ public Track(String id, IModel<?> model) { this(id, model, null, null, null); } + /** + * Creates a track + * + * @param id + * the component id + * @param resourceReference + * the resource reference to provide track information - like .vtt + */ public Track(String id, ResourceReference resourceReference) { this(id, null, null, null, resourceReference); } + /** + * Creates a track + * + * @param id + * the component id + * @param model + * the internally used model + * @param resourceReference + * the resource reference to provide track information - like .vtt + */ public Track(String id, IModel<?> model, ResourceReference resourceReference) { this(id, model, null, null, resourceReference); } + /** + * Creates a track + * + * @param id + * the component id + * @param resourceReference + * the resource reference to provide track information - like .vtt + * @param pageParameters + * the page parameters applied to the track URL + */ public Track(String id, ResourceReference resourceReference, PageParameters pageParameters) { this(id, null, null, pageParameters, resourceReference); } + /** + * Creates a track + * + * @param id + * the component id + * @param model + * the internally used model + * @param resourceReference + * the resource reference to provide track information - like .vtt + * @param pageParameters + * the page parameters applied to the track URL + */ public Track(String id, IModel<?> model, ResourceReference resourceReference, PageParameters pageParameters) { this(id, model, null, pageParameters, resourceReference); } + /** + * Creates a track + * + * @param id + * the component id + * @param url + * an external URL to provide the track information + */ public Track(String id, String url) { this(id, null, url, null, null); } + /** + * Creates a track + * + * @param id + * the component id + * @param model + * the internally used model + * @param url + * an external URL to provide the track information + */ public Track(String id, IModel<?> model, String url) { this(id, model, url, null, null); http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/markup/html/media/audio/Audio.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/audio/Audio.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/audio/Audio.java index aa6e782..2b7cb61 100755 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/audio/Audio.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/audio/Audio.java @@ -33,55 +33,147 @@ public class Audio extends MediaComponent { private static final long serialVersionUID = 1L; + /** + * Creates an audio component + * + * @param id + * the component id + */ public Audio(String id) { super(id); } + /** + * Creates an audio component + * + * @param id + * the component id + * @param model + * the internally used model + */ public Audio(String id, IModel<?> model) { super(id, model); } + /** + * Creates an audio component + * + * @param id + * the component id + * @param resourceReference + * the package resource reference of the audio file + */ public Audio(String id, PackageResourceReference resourceReference) { super(id, resourceReference); } - public Audio(String id, IModel<?> model, - PackageResourceReference resourceReference) + /** + * Creates an audio component + * + * @param id + * the component id + * @param model + * the internally used model + * @param resourceReference + * the package resource reference of the audio file + */ + public Audio(String id, IModel<?> model, PackageResourceReference resourceReference) { super(id, model, resourceReference); } + /** + * Creates an audio component + * + * @param id + * the component id + * @param resourceReference + * the package resource reference of the audio file + * @param pageParameters + * the page parameters to be used to be prepended to the audio URL + */ public Audio(String id, PackageResourceReference resourceReference, PageParameters pageParameters) { super(id, resourceReference, pageParameters); } - public Audio(String id, IModel<?> model, - PackageResourceReference resourceReference, + /** + * Creates an audio component + * + * @param id + * the component id + * @param model + * the internally used model + * @param resourceReference + * the package resource reference of the audio file + * @param pageParameters + * the page parameters to be used to be prepended to the audio URL + */ + public Audio(String id, IModel<?> model, PackageResourceReference resourceReference, PageParameters pageParameters) { super(id, model, resourceReference, pageParameters); } + /** + * Creates an audio component + * + * @param id + * the component id + * @param url + * an external URL to be used for the audio component + */ public Audio(String id, String url) { super(id, url); } + /** + * Creates an audio component + * + * @param id + * the component id + * @param model + * the internally used model + * @param url + * an external URL to be used for the audio component + */ public Audio(String id, IModel<?> model, String url) { super(id, model, url); } + /** + * Creates an audio component + * + * @param id + * the component id + * @param url + * an external URL to be used for the audio component + * @param pageParameters + * the page parameters to be used to be prepended to the audio URL + */ public Audio(String id, String url, PageParameters pageParameters) { super(id, null, url, pageParameters); } + /** + * Creates an audio component + * + * @param id + * the component id + * @param model + * the internally used model + * @param url + * an external URL to be used for the audio component + * @param pageParameters + * the page parameters to be used to be prepended to the audio URL + */ public Audio(String id, IModel<?> model, String url, PageParameters pageParameters) { super(id, model, url, pageParameters); http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/markup/html/media/video/Video.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/video/Video.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/video/Video.java index 7e685b9..c792356 100755 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/media/video/Video.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/media/video/Video.java @@ -43,55 +43,147 @@ public class Video extends MediaComponent private PageParameters posterPageParameters; + /** + * Creates a video component + * + * @param id + * the component id + */ public Video(String id) { super(id); } + /** + * Creates a video component + * + * @param id + * the component id + * @param model + * the internally used model + */ public Video(String id, IModel<?> model) { super(id, model); } + /** + * Creates a video component + * + * @param id + * the component id + * @param resourceReference + * the package resource reference of the video file + */ public Video(String id, PackageResourceReference resourceReference) { super(id, resourceReference); } - public Video(String id, IModel<?> model, - PackageResourceReference resourceReference) + /** + * Creates a video component + * + * @param id + * the component id + * @param model + * the internally used model + * @param resourceReference + * the package resource reference of the video file + */ + public Video(String id, IModel<?> model, PackageResourceReference resourceReference) { super(id, model, resourceReference); } + /** + * Creates a media component + * + * @param id + * the component id + * @param resourceReference + * the package resource reference of the video file + * @param pageParameters + * the page parameters to be used to be prepended to the video URL + */ public Video(String id, PackageResourceReference resourceReference, PageParameters pageParameters) { super(id, resourceReference, pageParameters); } - public Video(String id, IModel<?> model, - PackageResourceReference resourceReference, + /** + * Creates a video component + * + * @param id + * the component id + * @param model + * the internally used model + * @param resourceReference + * the package resource reference of the video file + * @param pageParameters + * the page parameters to be used to be prepended to the video URL + */ + public Video(String id, IModel<?> model, PackageResourceReference resourceReference, PageParameters pageParameters) { super(id, model, resourceReference, pageParameters); } + /** + * Creates a video component + * + * @param id + * the component id + * @param url + * an external URL to be used for the video component + */ public Video(String id, String url) { super(id, url); } + /** + * Creates a video component + * + * @param id + * the component id + * @param model + * the internally used model + * @param url + * an external URL to be used for the video component + */ public Video(String id, IModel<?> model, String url) { super(id, model, url); } + /** + * Creates a video component + * + * @param id + * the component id + * @param url + * an external URL to be used for the video component + * @param pageParameters + * the page parameters to be used to be prepended to the video URL + */ public Video(String id, String url, PageParameters pageParameters) { super(id, null, url, pageParameters); } + /** + * Creates a video component + * + * @param id + * the component id + * @param model + * the internally used model + * @param url + * an external URL to be used for the video component + * @param pageParameters + * the page parameters to be used to be prepended to the video URL + */ public Video(String id, IModel<?> model, String url, PageParameters pageParameters) { super(id, model, url, pageParameters); http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java index 18764d4..5e0798d 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java @@ -906,8 +906,9 @@ public abstract class AbstractResource implements IResource // currently only bytes are supported. webResponse.setContentRange(ContentRangeType.BYTES.getTypeName() + " " + startbyte + '-' + endbyte + '/' + contentLength); - // content length must be overridden by the recalculated one - webResponse.setContentLength((endbyte - startbyte) + 1); + // WARNING - DO NOT SET THE CONTENT LENGTH, even if it is calculated right - + // SAFARI / CHROME are causing issues otherwise! + // webResponse.setContentLength((endbyte - startbyte) + 1); // content range has been applied do not set the content length again! contentRangeApplied = true; http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java index ee8bfec..2253446 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java @@ -69,6 +69,7 @@ import org.slf4j.LoggerFactory; * @author Eelco Hillenius * @author Juergen Donnerstag * @author Matej Knopp + * @author Tobias Soloschenko */ public class PackageResource extends AbstractResource implements IStaticCacheableResource { @@ -79,7 +80,9 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl /** * Exception thrown when the creation of a package resource is not allowed. */ - public static final class PackageResourceBlockedException extends WicketRuntimeException implements IWicketInternalException + public static final class PackageResourceBlockedException extends WicketRuntimeException + implements + IWicketInternalException { private static final long serialVersionUID = 1L; @@ -126,9 +129,9 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl private final String variation; /** - * A flag indicating whether {@code ITextResourceCompressor} can be used to compress this resource. - * Default is {@code false} because this resource may be used for binary data (e.g. an image). - * Specializations of this class should change this flag appropriately. + * A flag indicating whether {@code ITextResourceCompressor} can be used to compress this + * resource. Default is {@code false} because this resource may be used for binary data (e.g. an + * image). Specializations of this class should change this flag appropriately. */ private boolean compress = false; @@ -144,6 +147,11 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl private String textEncoding = null; /** + * Reads the resource buffered - the content is copied into memory + */ + private boolean readBuffered = true; + + /** * Hidden constructor. * * @param scope @@ -201,12 +209,23 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl return style; } + /** + * Returns true if the caching for this resource is enabled + * + * @return if the caching is enabled + */ @Override public boolean isCachingEnabled() { return cachingEnabled; } + /** + * Sets the caching for this resource to be enabled + * + * @param enabled + * if the cacheing should be enabled + */ public void setCachingEnabled(final boolean enabled) { this.cachingEnabled = enabled; @@ -286,7 +305,7 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl if (resourceStream == null) { return sendResourceError(resourceResponse, HttpServletResponse.SC_NOT_FOUND, - "Unable to find resource"); + "Unable to find resource"); } // add Last-Modified header (to support HEAD requests and If-Modified-Since) @@ -316,19 +335,31 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl { // read resource data to get the content length InputStream inputStream = resourceStream.getInputStream(); - byte[] bytes = IOUtils.toByteArray(inputStream); - long contentLength = bytes.length; + byte[] bytes = null; // send Content-Length header - resourceResponse.setContentLength(contentLength); + if (readBuffered) + { + bytes = IOUtils.toByteArray(inputStream); + resourceResponse.setContentLength(new Long(bytes.length)); + } + else + { + resourceResponse.setContentLength(resourceStream.length().bytes()); + } // get content range information Long startbyte = RequestCycle.get().getMetaData(CONTENT_RANGE_STARTBYTE); Long endbyte = RequestCycle.get().getMetaData(CONTENT_RANGE_ENDBYTE); // send response body with resource data - resourceResponse.setWriteCallback(new PartWriterCallback( - new ByteArrayInputStream(bytes), contentLength, startbyte, endbyte)); + PartWriterCallback partWriterCallback = new PartWriterCallback(bytes != null + ? new ByteArrayInputStream(bytes) : inputStream, + resourceResponse.getContentLength(), startbyte, endbyte); + + // If read buffered is set to false ensure the part writer callback is going to + // close the input stream + resourceResponse.setWriteCallback(partWriterCallback.setClose(!readBuffered)); } catch (IOException e) { @@ -342,9 +373,13 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl } finally { + try { - resourceStream.close(); + if (readBuffered) + { + IOUtils.close(resourceStream); + } } catch (IOException e) { @@ -421,8 +456,8 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl } /** - * @return whether {@link org.apache.wicket.resource.ITextResourceCompressor} can be used to compress the - * resource. + * @return whether {@link org.apache.wicket.resource.ITextResourceCompressor} can be used to + * compress the resource. */ public boolean getCompress() { @@ -441,9 +476,10 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl private IResourceStream internalGetResourceStream(final String style, final Locale locale) { IResourceStreamLocator resourceStreamLocator = Application.get() - .getResourceSettings() - .getResourceStreamLocator(); - IResourceStream resourceStream = resourceStreamLocator.locate(getScope(), absolutePath, style, variation, locale, null, false); + .getResourceSettings() + .getResourceStreamLocator(); + IResourceStream resourceStream = resourceStreamLocator.locate(getScope(), absolutePath, + style, variation, locale, null, false); String realPath = absolutePath; if (resourceStream instanceof IFixedLocationResourceStream) @@ -467,8 +503,8 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl if (accept(realPath) == false) { throw new PackageResourceBlockedException( - "Access denied to (static) package resource " + absolutePath + - ". See IPackageResourceGuard"); + "Access denied to (static) package resource " + absolutePath + + ". See IPackageResourceGuard"); } if (resourceStream != null) @@ -493,19 +529,23 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl @Override public InputStream getInputStream() throws ResourceStreamNotFoundException { - byte[] bytes; + byte[] bytes = null; InputStream inputStream = super.getInputStream(); - try - { - bytes = IOUtils.toByteArray(inputStream); - } - catch (IOException iox) - { - throw new WicketRuntimeException(iox); - } - finally + + if (readBuffered) { - IOUtils.closeQuietly(this); + try + { + bytes = IOUtils.toByteArray(inputStream); + } + catch (IOException iox) + { + throw new WicketRuntimeException(iox); + } + finally + { + IOUtils.closeQuietly(this); + } } RequestCycle cycle = RequestCycle.get(); @@ -519,8 +559,15 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl // use empty request and response in case of non-http thread. WICKET-5532 attributes = new Attributes(new MockWebRequest(Url.parse("")), new StringResponse()); } - byte[] processedBytes = processResponse(attributes, bytes); - return new ByteArrayInputStream(processedBytes); + if (bytes != null) + { + byte[] processedBytes = processResponse(attributes, bytes); + return new ByteArrayInputStream(processedBytes); + } + else + { + return inputStream; + } } } @@ -710,4 +757,23 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl return sb.toString(); } } + + /** + * If the package resource should be read buffered.<br> + * <br> + * WARNING - if the stream is not read buffered compressors will not work, because they require + * the whole content to be read into memory.<br> + * ({@link org.apache.wicket.javascript.IJavaScriptCompressor}, <br> + * {@link org.apache.wicket.css.ICssCompressor}, <br> + * {@link org.apache.wicket.resource.IScopeAwareTextResourceProcessor}) + * + * @param readBuffered + * if the package resource should be read buffered + * @return the current package resource + */ + public PackageResource readBuffered(boolean readBuffered) + { + this.readBuffered = readBuffered; + return this; + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java index 749769e..4bd20f0 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java @@ -30,8 +30,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * This is a ResourceReference that knows how to find and serve resources located in the - * Java package (i.e. next to the class files). + * This is a ResourceReference that knows how to find and serve resources located in the Java + * package (i.e. next to the class files). + * + * @author Tobias Soloschenko */ public class PackageResourceReference extends ResourceReference { @@ -45,12 +47,16 @@ public class PackageResourceReference extends ResourceReference private transient ConcurrentMap<UrlAttributes, UrlAttributes> urlAttributesCacheMap; /** - * Cache for existence of minified version of the resource to avoid repetitive calls - * to org.apache.wicket.util.resource.locator.IResourceStreamLocator#locate() and + * Reads the resource buffered - the content is copied into memory + */ + private boolean readBuffered = true; + + /** + * Cache for existence of minified version of the resource to avoid repetitive calls to + * org.apache.wicket.util.resource.locator.IResourceStreamLocator#locate() and * #getMinifiedName(). */ - private static final ConcurrentMap<PackageResourceReference, String> MINIFIED_NAMES_CACHE - = Generics.newConcurrentHashMap(); + private static final ConcurrentMap<PackageResourceReference, String> MINIFIED_NAMES_CACHE = Generics.newConcurrentHashMap(); /** * A constant used to indicate that there is no minified version of the resource. @@ -117,17 +123,17 @@ public class PackageResourceReference extends ResourceReference if (CSS_EXTENSION.equals(extension)) { resource = new CssPackageResource(getScope(), getName(), getLocale(), getStyle(), - getVariation()); + getVariation()).readBuffered(readBuffered); } else if (JAVASCRIPT_EXTENSION.equals(extension)) { - resource = new JavaScriptPackageResource(getScope(), getName(), getLocale(), getStyle(), - getVariation()); + resource = new JavaScriptPackageResource(getScope(), getName(), getLocale(), + getStyle(), getVariation()).readBuffered(readBuffered); } else { resource = new PackageResource(getScope(), getName(), getLocale(), getStyle(), - getVariation()); + getVariation()).readBuffered(readBuffered); } removeCompressFlagIfUnnecessary(resource); @@ -136,13 +142,14 @@ public class PackageResourceReference extends ResourceReference } /** - * Method allowing to remove the compress flag if the resource has been detected as a minified one - * (i.e. ending with .min.EXT) - * This method is to be called by subclasses overriding <code>getResource</code> - * if they want to rely on default minification detection handling + * Method allowing to remove the compress flag if the resource has been detected as a minified + * one (i.e. ending with .min.EXT) This method is to be called by subclasses overriding + * <code>getResource</code> if they want to rely on default minification detection handling * * see WICKET-5250 for further explanation - * @param resource resource to check + * + * @param resource + * resource to check */ protected final void removeCompressFlagIfUnnecessary(final PackageResource resource) { @@ -153,7 +160,8 @@ public class PackageResourceReference extends ResourceReference } } - private ResourceReference.UrlAttributes getUrlAttributes(Locale locale, String style, String variation) + private ResourceReference.UrlAttributes getUrlAttributes(Locale locale, String style, + String variation) { IResourceStreamLocator locator = Application.get() .getResourceSettings() @@ -167,7 +175,8 @@ public class PackageResourceReference extends ResourceReference if (stream == null) return new ResourceReference.UrlAttributes(null, null, null); - return new ResourceReference.UrlAttributes(stream.getLocale(), stream.getStyle(), stream.getVariation()); + return new ResourceReference.UrlAttributes(stream.getLocale(), stream.getStyle(), + stream.getVariation()); } private Locale getCurrentLocale() @@ -182,8 +191,9 @@ public class PackageResourceReference extends ResourceReference /** * Initializes the cache for the existence of the minified resource. + * * @return the name of the minified resource or the special constant {@link #NO_MINIFIED_NAME} - * if there is no minified version + * if there is no minified version */ private String internalGetMinifiedName() { @@ -195,18 +205,18 @@ public class PackageResourceReference extends ResourceReference String name = getMinifiedName(); IResourceStreamLocator locator = Application.get() - .getResourceSettings() - .getResourceStreamLocator(); + .getResourceSettings() + .getResourceStreamLocator(); String absolutePath = Packages.absolutePath(getScope(), name); IResourceStream stream = locator.locate(getScope(), absolutePath, getStyle(), - getVariation(), getLocale(), null, true); + getVariation(), getLocale(), null, true); minifiedName = stream != null ? name : NO_MINIFIED_NAME; MINIFIED_NAMES_CACHE.put(this, minifiedName); if (minifiedName == NO_MINIFIED_NAME && log.isDebugEnabled()) { log.debug("No minified version of '" + super.getName() + - "' found, expected a file with the name '" + name + "', using full version"); + "' found, expected a file with the name '" + name + "', using full version"); } return minifiedName; } @@ -231,7 +241,8 @@ public class PackageResourceReference extends ResourceReference { String name = null; - if (Application.exists() && Application.get().getResourceSettings().getUseMinifiedResources()) + if (Application.exists() && + Application.get().getResourceSettings().getUseMinifiedResources()) { String minifiedName = internalGetMinifiedName(); if (minifiedName != NO_MINIFIED_NAME) @@ -254,7 +265,8 @@ public class PackageResourceReference extends ResourceReference String style = getCurrentStyle(); String variation = getVariation(); - ResourceReference.UrlAttributes key = new ResourceReference.UrlAttributes(locale, style, variation); + ResourceReference.UrlAttributes key = new ResourceReference.UrlAttributes(locale, style, + variation); if (urlAttributesCacheMap == null) { @@ -273,4 +285,23 @@ public class PackageResourceReference extends ResourceReference return value; } + + /** + * If the package resource should be read buffered.<br> + * <br> + * WARNING - if the stream is not read buffered compressors will not work, because they require the + * whole content to be read into memory.<br> + * ({@link org.apache.wicket.javascript.IJavaScriptCompressor}, <br> + * {@link org.apache.wicket.css.ICssCompressor}, <br> + * {@link org.apache.wicket.resource.IScopeAwareTextResourceProcessor}) + * + * @param readBuffered + * if the package resource should be read buffered + * @return the current package resource + */ + public PackageResourceReference readBuffered(boolean readBuffered) + { + this.readBuffered = readBuffered; + return this; + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java index 59b617f..f3fcb6e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java @@ -30,7 +30,8 @@ import org.apache.wicket.util.lang.Args; /** * Used to read a part of an input stream and writes it to the output stream of the response taken - * from attributes in {@link #writeData(org.apache.wicket.request.resource.IResource.Attributes)} method. + * from attributes in {@link #writeData(org.apache.wicket.request.resource.IResource.Attributes)} + * method. * * @author Tobias Soloschenko * @since 7.0.0 @@ -48,14 +49,14 @@ public class PartWriterCallback extends WriteCallback private final Long contentLength; /** - * The byte to start reading from. If omitted then the input stream will be read - * from its beginning + * The byte to start reading from. If omitted then the input stream will be read from its + * beginning */ private Long startbyte; /** - * The end byte to read from the {@link #inputStream}. - * If omitted then the input stream will be read till its end + * The end byte to read from the {@link #inputStream}. If omitted then the input stream will be + * read till its end */ private Long endbyte; @@ -64,6 +65,11 @@ public class PartWriterCallback extends WriteCallback */ private int bufferSize; + /** + * If the given input stream is going to be closed + */ + private boolean close = false; + /** * Creates a part writer callback.<br> @@ -169,6 +175,10 @@ public class PartWriterCallback extends WriteCallback // org.apache.catalina.connector.ClientAbortException) // we ignore this case } + if (close) + { + IOUtils.close(inputStream); + } } /** @@ -186,10 +196,36 @@ public class PartWriterCallback extends WriteCallback * * @param bufferSize * the buffer size used to send the data to the client + * @return the part writer callback */ - public void setBufferSize(int bufferSize) + public PartWriterCallback setBufferSize(int bufferSize) { this.bufferSize = bufferSize; + return this; + } + + /** + * If the given input stream is going to be closed + * + * @return if the given input stream is going to be closed + */ + public boolean isClose() + { + return close; + } + + /** + * If set true the given input stream is going to be closed + * + * @param close + * if the given input stream is going to be closed + * @return the part writer callback + */ + public PartWriterCallback setClose(boolean close) + { + this.close = close; + return this; + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.html ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.html b/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.html index be0b1ce..4a1725d 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.html +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.html @@ -10,7 +10,7 @@ <div> <!-- Video 1 --> <video wicket:id="video1" ></video> - <div class="videoDescription"><b>Video1</b><br/>Demonstrate the basic set of methods to configure a video (setAutoplay(false); setControls(true); setLooping(false); setWidth(320); setHeight(240);) The width and height are null by default which means that the video is going to be rendered in size of the media file.</div> + <div class="videoDescription"><b>Video1</b><br/>Demonstrate the basic set of methods to configure a video (setAutoplay(false); setControls(true); setLooping(false); setWidth(320); setHeight(240);) The width and height are null by default which means that the video is going to be rendered in size of the media file. The PackageResourceReference is set to readBuffered(false) which means that the media file is not stored in memory.</div> <div class="clearer"></div> <!-- Video 2 --> http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java b/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java index 9055ff1..d9892f6 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java @@ -50,7 +50,7 @@ public final class Home extends WicketExamplePage // Internal video with several options Video video1 = new Video("video1", new PackageResourceReference(Home.class, - "video.mp4")); + "video1.mp4").readBuffered(false)); video1.setAutoplay(false); video1.setControls(true); video1.setLooping(false); @@ -65,7 +65,7 @@ public final class Home extends WicketExamplePage video2.setPoster(new PackageResourceReference(Home.class, "novideo.gif")); Source source2 = new Source("source2", new PackageResourceReference(Home.class, - "video.mp4")); + "video2.mp4")); // Need to be set to true to show the type source2.setDisplayType(true); // the default type is the mime type of the image with no codec information http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-examples/src/main/java/org/apache/wicket/examples/media/video.mp4 ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/media/video.mp4 b/wicket-examples/src/main/java/org/apache/wicket/examples/media/video.mp4 deleted file mode 100644 index cf59777..0000000 Binary files a/wicket-examples/src/main/java/org/apache/wicket/examples/media/video.mp4 and /dev/null differ http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-examples/src/main/java/org/apache/wicket/examples/media/video1.mp4 ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/media/video1.mp4 b/wicket-examples/src/main/java/org/apache/wicket/examples/media/video1.mp4 new file mode 100644 index 0000000..cf59777 Binary files /dev/null and b/wicket-examples/src/main/java/org/apache/wicket/examples/media/video1.mp4 differ http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-examples/src/main/java/org/apache/wicket/examples/media/video2.mp4 ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/media/video2.mp4 b/wicket-examples/src/main/java/org/apache/wicket/examples/media/video2.mp4 new file mode 100644 index 0000000..cf59777 Binary files /dev/null and b/wicket-examples/src/main/java/org/apache/wicket/examples/media/video2.mp4 differ http://git-wip-us.apache.org/repos/asf/wicket/blob/4468ef93/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc b/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc index ecd4aba..7315892 100644 --- a/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc +++ b/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc @@ -129,6 +129,8 @@ h3. Media tags - resource references with content range support Since Wicket 7.0.0 the PackageResource and the PackageResourceReference support "Range" HTTP header for the request and "Content-Range" / "Accept-Range" HTTP headers for the response, which are used for videos / audio tags. The "Range" header allows the client to only request a specific byte range of the resource. The server provides the "Content-Range" and tells the client which bytes are going to be send. +If you want the resource not to be load into memory apply readBuffered(false) - this way the stream is written directly to the response. (@org.apache.wicket.resource.ITextResourceCompressor@ will not be applied if readBuffered is set to false) + *HTML:* {code:html} ... @@ -139,7 +141,7 @@ Since Wicket 7.0.0 the PackageResource and the PackageResourceReference support *Java Code:* {code} ... - Video video = new Video("video", new PackageResourceReference(getClass(),"video.mp4")); + Video video = new Video("video", new PackageResourceReference(getClass(),"video.mp4").readBuffered(false)); ... {code}
