You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ts...@apache.org on 2015/05/24 13:13:04 UTC

wicket git commit: WICKET-5819 Guide update, JavaDoc update, Examples update

Repository: wicket
Updated Branches:
  refs/heads/WICKET-5819_Improvements 7e3fed6dc -> 4323f563a


WICKET-5819 Guide update, JavaDoc update, Examples update

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

Branch: refs/heads/WICKET-5819_Improvements
Commit: 4323f563aeac6f228bf79147e2d19b6a69dc270a
Parents: 7e3fed6
Author: Tobias Soloschenko <ts...@apache.org>
Authored: Sun May 24 13:08:28 2015 +0200
Committer: Tobias Soloschenko <ts...@apache.org>
Committed: Sun May 24 13:08:28 2015 +0200

----------------------------------------------------------------------
 .../request/resource/PackageResource.java       |  8 ++-
 .../resource/PackageResourceReference.java      | 63 ++++++++++++--------
 .../org/apache/wicket/examples/media/Home.html  |  2 +-
 .../src/docs/guide/resources/resources_3.gdoc   |  4 +-
 4 files changed, 49 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/4323f563/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 27d3822..59abd4c 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
 {
@@ -740,7 +741,12 @@ public class PackageResource extends AbstractResource implements IStaticCacheabl
 	}
 
 	/**
-	 * If the packaage resource should be read partially
+	 * If the packaage resource should be read partially.<br>
+	 * <br>
+	 * WARNING - if the stream is read partially compressors will not work, because they require the
+	 * whole content to be read <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

http://git-wip-us.apache.org/repos/asf/wicket/blob/4323f563/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 c3d3353..de9417e 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
 {
@@ -43,16 +45,15 @@ public class PackageResourceReference extends ResourceReference
 	private static final String JAVASCRIPT_EXTENSION = "js";
 
 	private transient ConcurrentMap<UrlAttributes, UrlAttributes> urlAttributesCacheMap;
-	
+
 	private boolean readPartially = false;
 
 	/**
-	 * Cache for existence of minified version of the resource to avoid repetitive calls
-	 * to org.apache.wicket.util.resource.locator.IResourceStreamLocator#locate() and
+	 * 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.
@@ -123,8 +124,8 @@ public class PackageResourceReference extends ResourceReference
 		}
 		else if (JAVASCRIPT_EXTENSION.equals(extension))
 		{
-			resource = new JavaScriptPackageResource(getScope(), getName(), getLocale(), getStyle(),
-				getVariation()).readPartially(readPartially);
+			resource = new JavaScriptPackageResource(getScope(), getName(), getLocale(),
+				getStyle(), getVariation()).readPartially(readPartially);
 		}
 		else
 		{
@@ -138,13 +139,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)
 	{
@@ -155,7 +157,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()
@@ -169,7 +172,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()
@@ -184,8 +188,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()
 	{
@@ -197,18 +202,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;
 	}
@@ -233,7 +238,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)
@@ -256,7 +262,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)
 		{
@@ -275,9 +282,15 @@ public class PackageResourceReference extends ResourceReference
 
 		return value;
 	}
-	
+
 	/**
-	 * If the packaage resource should be read partially
+	 * If the packaage resource should be read partially.<br>
+	 * <br>
+	 * WARNING - if the stream is read partially compressors will not work, because they require the
+	 * whole content to be read <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

http://git-wip-us.apache.org/repos/asf/wicket/blob/4323f563/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..98395e0 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 marked to be read partially so 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/4323f563/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..3344a08 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 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.
+
 *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").readPartially(true));
 ...
 {code}