Repository: wicket
Updated Branches:
  refs/heads/WICKET-5819_Improvements 7343727ce -> 7a837f605


WICKET-5819 - renamed readPartially to readBuffered (default true)

Some minor fixes.

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/7a837f60
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/7a837f60
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/7a837f60

Branch: refs/heads/WICKET-5819_Improvements
Commit: 7a837f605f0df3777f5a3a2b70d3f1142f32a1f4
Parents: 7343727
Author: Tobias Soloschenko <[email protected]>
Authored: Mon May 25 22:37:30 2015 +0200
Committer: Tobias Soloschenko <[email protected]>
Committed: Mon May 25 22:37:30 2015 +0200

----------------------------------------------------------------------
 .../apache/wicket/markup/html/image/Image.java  |  2 +-
 .../request/resource/PackageResource.java       | 30 ++++++++++----------
 .../resource/PackageResourceReference.java      | 24 ++++++++--------
 .../org/apache/wicket/examples/media/Home.java  |  2 +-
 .../src/docs/guide/resources/resources_3.gdoc   |  4 +--
 5 files changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/7a837f60/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 f9484ed..ac88b46 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
@@ -595,7 +595,7 @@ public class Image extends WebComponent implements 
IResourceListener
         * <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.
+        * <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
         *

http://git-wip-us.apache.org/repos/asf/wicket/blob/7a837f60/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 5e1fc2f..e2cbe02 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
@@ -147,9 +147,9 @@ public class PackageResource extends AbstractResource 
implements IStaticCacheabl
        private String textEncoding = null;
 
        /**
-        * Reads the resource partially - the content is not copied into memory
+        * Reads the resource buffered - the content is not copied into memory
         */
-       private boolean readPartially = false;
+       private boolean readBuffered = true;
 
        /**
         * Hidden constructor.
@@ -338,14 +338,14 @@ public class PackageResource extends AbstractResource 
implements IStaticCacheabl
 
                                byte[] bytes = null;
                                // send Content-Length header
-                               if (readPartially)
+                               if (readBuffered)
                                {
-                                       
resourceResponse.setContentLength(resourceStream.length().bytes());
+                                       bytes = 
IOUtils.toByteArray(inputStream);
+                                       resourceResponse.setContentLength(new 
Long(bytes.length));
                                }
                                else
                                {
-                                       bytes = 
IOUtils.toByteArray(inputStream);
-                                       resourceResponse.setContentLength(new 
Long(bytes.length));
+                                       
resourceResponse.setContentLength(resourceStream.length().bytes());
                                }
 
                                // get content range information
@@ -372,7 +372,7 @@ public class PackageResource extends AbstractResource 
implements IStaticCacheabl
 
                                try
                                {
-                                       if (!readPartially)
+                                       if (readBuffered)
                                        {
                                                IOUtils.close(resourceStream);
                                        }
@@ -528,7 +528,7 @@ public class PackageResource extends AbstractResource 
implements IStaticCacheabl
                        byte[] bytes = null;
                        InputStream inputStream = super.getInputStream();
 
-                       if (!readPartially)
+                       if (readBuffered)
                        {
                                try
                                {
@@ -755,21 +755,21 @@ public class PackageResource extends AbstractResource 
implements IStaticCacheabl
        }
 
        /**
-        * If the packaage resource should be read partially.<br>
+        * If the package resource should be read buffered.<br>
         * <br>
-        * WARNING - if the stream is read partially compressors will not work, 
because they require the
-        * whole content to be read <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 readPartially
-        *            if the package resource should be read partially
+        * @param readBuffered
+        *            if the package resource should be read buffered
         * @return the current package resource
         */
-       public PackageResource readPartially(boolean readPartially)
+       public PackageResource readBuffered(boolean readBuffered)
        {
-               this.readPartially = readPartially;
+               this.readBuffered = readBuffered;
                return this;
        }
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/7a837f60/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 c4aa6be..22aaaed 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
@@ -47,9 +47,9 @@ public class PackageResourceReference extends 
ResourceReference
        private transient ConcurrentMap<UrlAttributes, UrlAttributes> 
urlAttributesCacheMap;
 
        /**
-        * Reads the resource partially - the content is not copied into memory
+        * Reads the resource buffered - the content is not copied into memory
         */
-       private boolean readPartially = false;
+       private boolean readBuffered = true;
 
        /**
         * Cache for existence of minified version of the resource to avoid 
repetitive calls to
@@ -123,17 +123,17 @@ public class PackageResourceReference extends 
ResourceReference
                if (CSS_EXTENSION.equals(extension))
                {
                        resource = new CssPackageResource(getScope(), 
getName(), getLocale(), getStyle(),
-                               getVariation()).readPartially(readPartially);
+                               getVariation()).readBuffered(readBuffered);
                }
                else if (JAVASCRIPT_EXTENSION.equals(extension))
                {
                        resource = new JavaScriptPackageResource(getScope(), 
getName(), getLocale(),
-                               getStyle(), 
getVariation()).readPartially(readPartially);
+                               getStyle(), 
getVariation()).readBuffered(readBuffered);
                }
                else
                {
                        resource = new PackageResource(getScope(), getName(), 
getLocale(), getStyle(),
-                               getVariation()).readPartially(readPartially);
+                               getVariation()).readBuffered(readBuffered);
                }
 
                removeCompressFlagIfUnnecessary(resource);
@@ -287,21 +287,21 @@ public class PackageResourceReference extends 
ResourceReference
        }
 
        /**
-        * If the packaage resource should be read partially.<br>
+        * If the package resource should be read buffered.<br>
         * <br>
-        * WARNING - if the stream is read partially compressors will not work, 
because they require the
-        * whole content to be read <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 readPartially
-        *            if the package resource should be read partially
+        * @param readBuffered
+        *            if the package resource should be read buffered
         * @return the current package resource
         */
-       public PackageResourceReference readPartially(boolean readPartially)
+       public PackageResourceReference readBuffered(boolean readBuffered)
        {
-               this.readPartially = readPartially;
+               this.readBuffered = readBuffered;
                return this;
        }
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/7a837f60/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 c1de448..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,
-                       "video1.mp4").readPartially(true));
+                       "video1.mp4").readBuffered(false));
                video1.setAutoplay(false);
                video1.setControls(true);
                video1.setLooping(false);

http://git-wip-us.apache.org/repos/asf/wicket/blob/7a837f60/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 3344a08..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,7 +129,7 @@ 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 readPartially(true). 
By using this flag the stream is written directly to the response - 
@org.apache.wicket.resource.ITextResourceCompressor@ will not be applied if the 
readPartially is set to true.
+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}
@@ -141,7 +141,7 @@ If you want the resource not to be load into memory apply 
readPartially(true). B
 *Java Code:*
 {code}
 ...
-    Video video = new Video("video", new 
PackageResourceReference(getClass(),"video.mp4").readPartially(true));
+    Video video = new Video("video", new 
PackageResourceReference(getClass(),"video.mp4").readBuffered(false));
 ...
 {code} 
 

Reply via email to