Author: mgrigorov
Date: Mon Dec 20 15:44:14 2010
New Revision: 1051150

URL: http://svn.apache.org/viewvc?rev=1051150&view=rev
Log:
Add javadocs to the new demo application

Added:
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupingHeaderResponse.java
   (contents, props changed)
      - copied, changed from r1051131, 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java
Removed:
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java
Modified:
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java

Modified: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java?rev=1051150&r1=1051149&r2=1051150&view=diff
==============================================================================
--- 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java
 (original)
+++ 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupedAndOrderedResourceReference.java
 Mon Dec 20 15:44:14 2010
@@ -18,11 +18,19 @@ package org.apache.wicket.examples.resou
 
 import org.apache.wicket.request.resource.PackageResourceReference;
 
+/**
+ * Assigns a group and order to load in that group to a {...@link 
PackageResourceReference}.
+ * 
+ * @author jthomerson
+ */
 public class GroupedAndOrderedResourceReference extends 
PackageResourceReference
 {
 
        private static final long serialVersionUID = 1L;
 
+       /**
+        * Some demo groups
+        */
        public static enum ResourceGroup {
                UNKNOWN, GLOBAL, APPLICATION, PAGE, COMPONENT
        }
@@ -30,6 +38,14 @@ public class GroupedAndOrderedResourceRe
        private final ResourceGroup group;
        private final int loadOrder;
 
+       /**
+        * Construct.
+        * 
+        * @param group
+        * @param loadOrder
+        * @param scope
+        * @param name
+        */
        public GroupedAndOrderedResourceReference(ResourceGroup group, int 
loadOrder, Class<?> scope,
                String name)
        {
@@ -38,6 +54,13 @@ public class GroupedAndOrderedResourceRe
                this.loadOrder = loadOrder;
        }
 
+       /**
+        * Construct.
+        * 
+        * @param group
+        * @param loadOrder
+        * @param name
+        */
        public GroupedAndOrderedResourceReference(ResourceGroup group, int 
loadOrder, String name)
        {
                super(name);
@@ -45,11 +68,17 @@ public class GroupedAndOrderedResourceRe
                this.loadOrder = loadOrder;
        }
 
+       /**
+        * @return the assigned group for this {...@link 
PackageResourceReference}
+        */
        public ResourceGroup getGroup()
        {
                return group;
        }
 
+       /**
+        * @return the load order for this {...@link PackageResourceReference}
+        */
        public int getLoadOrder()
        {
                return loadOrder;

Copied: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupingHeaderResponse.java
 (from r1051131, 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java)
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupingHeaderResponse.java?p2=wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupingHeaderResponse.java&p1=wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java&r1=1051131&r2=1051150&rev=1051150&view=diff
==============================================================================
--- 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingHeaderResponse.java
 (original)
+++ 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupingHeaderResponse.java
 Mon Dec 20 15:44:14 2010
@@ -29,8 +29,13 @@ import org.apache.wicket.request.resourc
 import 
org.apache.wicket.resource.aggregation.AbstractResourceAggregatingHeaderResponse;
 import org.apache.wicket.resource.aggregation.ResourceReferenceAndStringData;
 
-
-public class HttpAggregatingHeaderResponse
+/**
+ * A {...@link IHeaderResponse} decorator that groups the resources by type 
(css or js) and by
+ * {...@link ResourceGroup custom groups}
+ * 
+ * @author jthomerson
+ */
+public class GroupingHeaderResponse
        extends
        
AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,
 BasicGroupingKey>
 {
@@ -41,14 +46,14 @@ public class HttpAggregatingHeaderRespon
                ResourceGroup.UNKNOWN, 0, false);
 
        // holder for all javascript blocks so that we can render them *after* 
the script tags
-       private List<Runnable> javascriptResponse = new ArrayList<Runnable>();
+       private final List<Runnable> javascriptResponse = new 
ArrayList<Runnable>();
 
        /**
         * Construct.
         * 
         * @param real
         */
-       public HttpAggregatingHeaderResponse(IHeaderResponse real)
+       public GroupingHeaderResponse(IHeaderResponse real)
        {
                super(real);
        }
@@ -61,7 +66,7 @@ public class HttpAggregatingHeaderRespon
                getRealResponse().renderString("<!-- " + key + " -->\n");
 
                // TODO: I'm not sure why yet, but our aggregator fails on 
wicket-event.js, so for now, we
-// skip aggregating all "UNKNOWN" references
+               // skip aggregating all "UNKNOWN" references
                if (ResourceGroup.UNKNOWN.equals(key.getGroup()))
                {
                        super.renderCollection(alreadyRendered, key, coll);
@@ -102,13 +107,13 @@ public class HttpAggregatingHeaderRespon
        {
                super.onAllCollectionsRendered(allTopLevelReferences);
 
-               // TODO: you could also externalize these JS statements into a 
file that is loaded rather
-// than being inline in the HTML if you so desired
+               // you could also externalize these JS statements into a file 
that is loaded rather
+               // than being inline in the HTML if you so desired
                for (Runnable runnable : javascriptResponse)
                {
                        runnable.run();
                }
-               javascriptResponse = null;
+               javascriptResponse.clear();
        }
 
        @Override
@@ -121,8 +126,8 @@ public class HttpAggregatingHeaderRespon
        @Override
        protected BasicGroupingKey 
newGroupingKey(ResourceReferenceAndStringData ref)
        {
-               // THIS IS JUST A SIMPLE EXAMPLE. IN REALITY, YOU'LL ALMOST 
SURELY WANT TO ALSO GROUP BY
-// MEDIA TYPE FOR CSS.
+               // this is just a simple example. in reality, you'll almost 
surely want to also group by
+               // media type for CSS.
                if (ref.getReference() instanceof 
GroupedAndOrderedResourceReference)
                {
                        GroupedAndOrderedResourceReference ourRef = 
(GroupedAndOrderedResourceReference)ref.getReference();
@@ -186,12 +191,6 @@ public class HttpAggregatingHeaderRespon
        private void toJsResponse(Runnable runnable)
        {
                javascriptResponse.add(runnable);
-// Response old = RequestCycle.get().setResponse(javascriptResponse);
-// try {
-// runnable.run();
-// } finally {
-// RequestCycle.get().setResponse(old);
-// }
        }
 
 }

Propchange: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/GroupingHeaderResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java?rev=1051150&r1=1051149&r2=1051150&view=diff
==============================================================================
--- 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java
 (original)
+++ 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HomePage.java
 Mon Dec 20 15:44:14 2010
@@ -29,7 +29,11 @@ import org.apache.wicket.request.mapper.
 import org.apache.wicket.request.resource.PackageResourceReference;
 import org.apache.wicket.util.time.Duration;
 
-/***/
+/**
+ * A demo page showing how to render grouped resources
+ * 
+ * @author jthomerson
+ */
 public class HomePage extends WicketExamplePage
 {
        private static final long serialVersionUID = 1L;
@@ -77,16 +81,21 @@ public class HomePage extends WicketExam
        public void renderHead(IHeaderResponse response)
        {
                // example of things that may be shared for all your 
applications across your company,
-// etc...:
-               response.renderCSSReference(new 
GroupedAndOrderedResourceReference(ResourceGroup.GLOBAL, 0,
+
+               // two CSS resources in the same group. header.css is rendered 
first because has lower
+               // "order" number
+               response.renderCSSReference(new 
GroupedAndOrderedResourceReference(ResourceGroup.GLOBAL, 1,
                        HomePage.class, "footer.css"));
                response.renderCSSReference(new 
GroupedAndOrderedResourceReference(ResourceGroup.GLOBAL, 0,
                        HomePage.class, "header.css"));
+
                response.renderJavaScriptReference(new 
GroupedAndOrderedResourceReference(
                        ResourceGroup.GLOBAL, 0, HomePage.class, 
"jquery-1.4.3.min.js"));
+
                // example of something that may be in this single application:
                response.renderCSSReference(new 
GroupedAndOrderedResourceReference(
                        ResourceGroup.APPLICATION, 0, HomePage.class, 
"app.css"));
+
                // example of something that may be limited to certain pages:
                response.renderCSSReference(new 
GroupedAndOrderedResourceReference(ResourceGroup.PAGE, 0,
                        HomePage.class, "HomePage.css"));

Modified: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java?rev=1051150&r1=1051149&r2=1051150&view=diff
==============================================================================
--- 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java
 (original)
+++ 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/HttpAggregatingResourceReferenceCollection.java
 Mon Dec 20 15:44:14 2010
@@ -18,10 +18,13 @@ package org.apache.wicket.examples.resou
 
 import org.apache.wicket.resource.aggregation.ResourceReferenceCollection;
 
+/**
+ * @author jthomerson
+ */
 public class HttpAggregatingResourceReferenceCollection extends 
ResourceReferenceCollection
 {
        private static final long serialVersionUID = 1L;
 
        // you could customize this collection class to have code specific to 
the collection, like
-// creating or rendering URLs, etc..
+       // creating or rendering URLs, etc..
 }

Modified: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java?rev=1051150&r1=1051149&r2=1051150&view=diff
==============================================================================
--- 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java
 (original)
+++ 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/MergedResourcesResource.java
 Mon Dec 20 15:44:14 2010
@@ -24,6 +24,13 @@ import org.apache.wicket.request.resourc
 import org.apache.wicket.util.lang.WicketObjects;
 import org.apache.wicket.util.resource.PackageResourceStream;
 
+/**
+ * A shared resource that receives as query parameters a list of the names of 
grouped resources and
+ * their type, then it loads each resource and merges it with the others. At 
the end returns the
+ * merged resource.
+ * 
+ * @author jthomerson
+ */
 public class MergedResourcesResource extends AbstractResource
 {
        private static final long serialVersionUID = 1L;

Modified: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java?rev=1051150&r1=1051149&r2=1051150&view=diff
==============================================================================
--- 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java
 (original)
+++ 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java
 Mon Dec 20 15:44:14 2010
@@ -16,11 +16,21 @@
  */
 package org.apache.wicket.examples.resourcedecoration;
 
+import org.apache.wicket.Application;
 import org.apache.wicket.markup.html.IHeaderResponse;
 import org.apache.wicket.markup.html.IHeaderResponseDecorator;
 import org.apache.wicket.protocol.http.WebApplication;
 
-
+/**
+ * An application showing how to return several resources into a single http 
response.
+ * 
+ * <p>
+ * The key is to register a custom {...@link IHeaderResponseDecorator} via
+ * {...@link Application#setHeaderResponseDecorator(IHeaderResponseDecorator)} 
that will intercept all
+ * resource contributions.
+ * 
+ * @author jthomerson
+ */
 public class ResourceDecorationApplication extends WebApplication
 {
 
@@ -38,9 +48,8 @@ public class ResourceDecorationApplicati
                        {
                                // add one that aggregates http requests,
                                // but delegates writing of the scripts (or 
aggregated URL script and link tags) to
-// the real response
-
-                               return new 
HttpAggregatingHeaderResponse(response);
+                               // the real response
+                               return new GroupingHeaderResponse(response);
                        }
                });
        }


Reply via email to