You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/10/26 19:47:27 UTC
svn commit: r1189339 - in /tapestry/tapestry5/trunk:
tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/
tapestry-core/src/main/java/org/apache/tapestry5/services/assets/
tapestry-yuicompressor/src/main/java/org/apache/tapestry5/...
Author: hlship
Date: Wed Oct 26 17:47:26 2011
New Revision: 1189339
URL: http://svn.apache.org/viewvc?rev=1189339&view=rev
Log:
TAP5-1729: Improve debugging output for streamable resources to clearly identify what is being compressed and/or minimized
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/SRSCompressingInterceptor.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StackAssetRequestHandler.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceSourceImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java
tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java
tapestry/tapestry5/trunk/tapestry-yuicompressor/src/test/java/yuicompressor/testapp/services/AppModule.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/SRSCompressingInterceptor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/SRSCompressingInterceptor.java?rev=1189339&r1=1189338&r2=1189339&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/SRSCompressingInterceptor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/SRSCompressingInterceptor.java Wed Oct 26 17:47:26 2011
@@ -70,7 +70,8 @@ public class SRSCompressingInterceptor i
BytestreamCache cache = new BytestreamCache(bos);
- return new StreamableResourceImpl(uncompressed.getContentType(), CompressionStatus.COMPRESSED,
+ return new StreamableResourceImpl(uncompressed.getDescription(),
+ uncompressed.getContentType(), CompressionStatus.COMPRESSED,
uncompressed.getLastModified(), cache);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StackAssetRequestHandler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StackAssetRequestHandler.java?rev=1189339&r1=1189338&r2=1189339&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StackAssetRequestHandler.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StackAssetRequestHandler.java Wed Oct 26 17:47:26 2011
@@ -170,18 +170,21 @@ public class StackAssetRequestHandler im
JavaScriptStack stack = javascriptStackSource.getStack(stackName);
List<Asset> libraries = stack.getJavaScriptLibraries();
- StreamableResource stackContent = assembleStackContent(libraries);
+ StreamableResource stackContent = assembleStackContent(localeName, stackName, libraries);
return minificationEnabled ? resourceMinimizer.minimize(stackContent) : stackContent;
}
- private StreamableResource assembleStackContent(List<Asset> libraries) throws IOException
+ private StreamableResource assembleStackContent(String localeName, String stackName, List<Asset> libraries) throws IOException
{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
PrintWriter writer = new PrintWriter(osw, true);
long lastModified = 0;
+ StringBuilder description = new StringBuilder(String.format("stack=%s, locale=%s, resources=[", stackName, localeName));
+ String sep = "";
+
JSONArray paths = new JSONArray();
for (Asset library : libraries)
@@ -194,6 +197,9 @@ public class StackAssetRequestHandler im
Resource resource = library.getResource();
+ description.append(sep).append(resource.toString());
+ sep = ", ";
+
StreamableResource streamable = streamableResourceSource.getStreamableResource(resource,
StreamableResourceProcessing.FOR_AGGREGATION, resourceChangeTracker);
@@ -204,7 +210,9 @@ public class StackAssetRequestHandler im
writer.close();
- return new StreamableResourceImpl(JAVASCRIPT_CONTENT_TYPE, CompressionStatus.COMPRESSABLE, lastModified,
+ return new StreamableResourceImpl(
+ description.append("]").toString(),
+ JAVASCRIPT_CONTENT_TYPE, CompressionStatus.COMPRESSABLE, lastModified,
new BytestreamCache(stream));
}
@@ -219,7 +227,7 @@ public class StackAssetRequestHandler im
BytestreamCache cache = new BytestreamCache(compressed);
- return new StreamableResourceImpl(JAVASCRIPT_CONTENT_TYPE, CompressionStatus.COMPRESSED,
+ return new StreamableResourceImpl(uncompressed.getDescription(), JAVASCRIPT_CONTENT_TYPE, CompressionStatus.COMPRESSED,
uncompressed.getLastModified(), cache);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java?rev=1189339&r1=1189338&r2=1189339&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java Wed Oct 26 17:47:26 2011
@@ -14,15 +14,17 @@
package org.apache.tapestry5.internal.services.assets;
+import org.apache.tapestry5.services.assets.CompressionStatus;
+import org.apache.tapestry5.services.assets.StreamableResource;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import org.apache.tapestry5.services.assets.CompressionStatus;
-import org.apache.tapestry5.services.assets.StreamableResource;
-
public class StreamableResourceImpl implements StreamableResource
{
+ private final String description;
+
private final String contentType;
private final CompressionStatus compression;
@@ -31,15 +33,21 @@ public class StreamableResourceImpl impl
private final BytestreamCache bytestreamCache;
- public StreamableResourceImpl(String contentType, CompressionStatus compression, long lastModified,
- BytestreamCache bytestreamCache)
+ public StreamableResourceImpl(String description, String contentType, CompressionStatus compression, long lastModified,
+ BytestreamCache bytestreamCache)
{
+ this.description = description;
this.contentType = contentType;
this.compression = compression;
this.lastModified = lastModified;
this.bytestreamCache = bytestreamCache;
}
+ public String getDescription()
+ {
+ return description;
+ }
+
public CompressionStatus getCompression()
{
return compression;
@@ -73,7 +81,7 @@ public class StreamableResourceImpl impl
@Override
public String toString()
{
- return String.format("StreamableResource<%s %s lastModified: %tc size: %d>", contentType, compression.name(),
+ return String.format("StreamableResource<%s %s %s lastModified: %tc size: %d>", contentType, description, compression.name(),
lastModified, getSize());
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceSourceImpl.java?rev=1189339&r1=1189338&r2=1189339&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceSourceImpl.java Wed Oct 26 17:47:26 2011
@@ -74,7 +74,7 @@ public class StreamableResourceSourceImp
long lastModified = resourceChangeTracker.trackResource(baseResource);
- return new StreamableResourceImpl(contentType, compressable ? CompressionStatus.COMPRESSABLE
+ return new StreamableResourceImpl(baseResource.toString(), contentType, compressable ? CompressionStatus.COMPRESSABLE
: CompressionStatus.NOT_COMPRESSABLE, lastModified, bytestreamCache);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java?rev=1189339&r1=1189338&r2=1189339&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java Wed Oct 26 17:47:26 2011
@@ -14,19 +14,28 @@
package org.apache.tapestry5.services.assets;
+import org.apache.tapestry5.ioc.Resource;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import org.apache.tapestry5.ioc.Resource;
-
/**
* An object, derived from a {@link Resource}, that can be streamed (ultimately, to a client web browser).
- *
+ *
* @since 5.3
*/
public interface StreamableResource
{
+ /**
+ * Describes the underlying {@link Resource} (or resources} for this streamble resource; expressly used
+ * as part of the object's {@code toString()}.
+ */
+ String getDescription();
+
+ /**
+ * Indicates if the content is compressed, or compressable.
+ */
CompressionStatus getCompression();
/**
@@ -48,7 +57,7 @@ public interface StreamableResource
/**
* Opens the content of the resource as an input stream; the caller is responsible for closing the stream
* after reading it.
- *
+ *
* @return stream of the contents of the resource
* @throws IOException
*/
Modified: tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java?rev=1189339&r1=1189338&r2=1189339&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java (original)
+++ tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java Wed Oct 26 17:47:26 2011
@@ -23,7 +23,6 @@ import org.apache.tapestry5.ioc.internal
import org.apache.tapestry5.services.assets.CompressionStatus;
import org.apache.tapestry5.services.assets.ResourceMinimizer;
import org.apache.tapestry5.services.assets.StreamableResource;
-import org.mozilla.javascript.EvaluatorException;
import org.slf4j.Logger;
import javax.management.RuntimeErrorException;
@@ -79,7 +78,8 @@ public abstract class AbstractMinimizer
// The content is minimized, but can still be (GZip) compressed.
- StreamableResource output = new StreamableResourceImpl(input.getContentType(), CompressionStatus.COMPRESSABLE,
+ StreamableResource output = new StreamableResourceImpl("minimized " + input.getDescription(),
+ input.getContentType(), CompressionStatus.COMPRESSABLE,
input.getLastModified(), new BytestreamCache(bos));
long elapsedNanos = System.nanoTime() - startNanos;
@@ -88,8 +88,8 @@ public abstract class AbstractMinimizer
{
double elapsedMillis = ((double) elapsedNanos) * NANOS_TO_MILLIS;
- logger.debug(String.format("Minimized %,d input bytes of %s to %,d output bytes in %.2f ms",
- input.getSize(), resourceType, output.getSize(), elapsedMillis));
+ logger.debug(String.format("Minimized %s (%,d input bytes of %s to %,d output bytes in %.2f ms)",
+ input.getDescription(), input.getSize(), resourceType, output.getSize(), elapsedMillis));
}
return output;
Modified: tapestry/tapestry5/trunk/tapestry-yuicompressor/src/test/java/yuicompressor/testapp/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-yuicompressor/src/test/java/yuicompressor/testapp/services/AppModule.java?rev=1189339&r1=1189338&r2=1189339&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-yuicompressor/src/test/java/yuicompressor/testapp/services/AppModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-yuicompressor/src/test/java/yuicompressor/testapp/services/AppModule.java Wed Oct 26 17:47:26 2011
@@ -15,7 +15,6 @@ public class AppModule
@ApplicationDefaults
public static void setupConfiguration(MappedConfiguration<String, Object> configuration)
{
- configuration.add(SymbolConstants.BLACKBIRD_ENABLED, true);
configuration.add(SymbolConstants.COMBINE_SCRIPTS, true);
configuration.add(SymbolConstants.MINIFICATION_ENABLED, true);
configuration.add(SymbolConstants.PRODUCTION_MODE, false);