Package org.apache.tapestry5.services.assets

Examples of org.apache.tapestry5.services.assets.StreamableResource


    @SuppressWarnings("unchecked")
    @Test
    public void single_validator_via_specification() throws Exception
    {
        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        Messages messages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
View Full Code Here


        writer.close();

        // The content is minimized, but can still be (GZip) compressed.

        StreamableResource output = new StreamableResourceImpl("minimized " + input.getDescription(),
                input.getContentType(), CompressionStatus.COMPRESSABLE,
                input.getLastModified(), new BytestreamCache(bos));

        if (logger.isInfoEnabled())
        {
            long elapsedNanos = System.nanoTime() - startNanos;

            int inputSize = input.getSize();
            int outputSize = output.getSize();

            double elapsedMillis = ((double) elapsedNanos) * NANOS_TO_MILLIS;
            // e.g., reducing 100 bytes to 25 would be a (100-25)/100 reduction, or 75%
            double reduction = 100d * ((double) (inputSize - outputSize)) / ((double) inputSize);

View Full Code Here

        if (!enableCache(processing))
        {
            return delegate.getStreamableResource(baseResource, processing, dependencies);
        }

        StreamableResource result = TapestryInternalUtils.getAndDeref(cache, baseResource);

        if (result == null)
        {
            result = delegate.getStreamableResource(baseResource, processing, dependencies);
View Full Code Here

            public void perform() throws IOException
            {
                StreamableResourceProcessing processing = analyzer.isGZipSupported() ? StreamableResourceProcessing.COMPRESSION_ENABLED
                        : StreamableResourceProcessing.COMPRESSION_DISABLED;

                StreamableResource streamable = streamableResourceSource.getStreamableResource(resource, processing, resourceChangeTracker);

                streamResource(streamable);
            }
        });
    }
View Full Code Here

        writer.close();

        // The content is minimized, but can still be (GZip) compressed.

        StreamableResource output = new StreamableResourceImpl("minimized " + input.getDescription(),
                input.getContentType(), CompressionStatus.COMPRESSABLE,
                input.getLastModified(), new BytestreamCache(bos));

        long elapsedNanos = System.nanoTime() - startNanos;

        if (logger.isDebugEnabled())
        {
            double elapsedMillis = ((double) elapsedNanos) * NANOS_TO_MILLIS;

            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;
    }
View Full Code Here

        if (processing == StreamableResourceProcessing.FOR_AGGREGATION)
        {
            return delegate.getStreamableResource(baseResource, processing, dependencies);
        }

        StreamableResource result = TapestryInternalUtils.getAndDeref(cache, baseResource);

        if (result == null)
        {
            result = delegate.getStreamableResource(baseResource, processing, dependencies);
View Full Code Here

            }
        });

        // The content is minimized, but can still be (GZip) compressed.

        StreamableResource output = new StreamableResourceImpl("minimized " + input.getDescription(),
                input.getContentType(), CompressionStatus.COMPRESSABLE,
                input.getLastModified(), new BytestreamCache(bos), checksumGenerator, input.getResponseCustomizer());

        if (logger.isInfoEnabled())
        {
            long elapsedNanos = System.nanoTime() - startNanos;

            int inputSize = input.getSize();
            int outputSize = output.getSize();

            double elapsedMillis = ((double) elapsedNanos) * NANOS_TO_MILLIS;
            // e.g., reducing 100 bytes to 25 would be a (100-25)/100 reduction, or 75%
            double reduction = 100d * ((double) (inputSize - outputSize)) / ((double) inputSize);

View Full Code Here

    private List<String> combinedStackURL(String stackName, JavaScriptStack stack)
    {
        try
        {
            StreamableResource assembled = assembler.assembleJavaScriptResourceForStack(stackName, compressionAnalyzer.isGZipSupported(),
                    stack.getJavaScriptAggregationStrategy());

            String path = String.format("%s/%s.js",
                    threadLocale.getLocale(),
                    stackName);
View Full Code Here

    }

    @Override
    public StreamableResource getStreamableResource(Resource baseResource, StreamableResourceProcessing processing, ResourceDependencies dependencies) throws IOException
    {
        StreamableResource resource = delegate.getStreamableResource(baseResource, processing, dependencies);

        ContentType contentType = resource.getContentType();

        if (contentType.getBaseType().equals("text")
                && ! contentType.hasParameters()
                && processing != StreamableResourceProcessing.FOR_AGGREGATION)
        {
            return resource.withContentType(contentType.withCharset("utf-8"));
        }

        return resource;
    }
View Full Code Here

        // Yes, I have a big regret that the JavaScript stack stuff relies on this global, rather than
        // having it passed around properly.

        localizationSetter.setNonPersistentLocaleFromLocaleName(localeName);

        StreamableResource resource =
                tracker.perform(String.format("Assembling JavaScript asset stack '%s' (%s)",
                                stackName, localeName),
                        new IOOperation<StreamableResource>()
                        {
                            public StreamableResource perform() throws IOException
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.assets.StreamableResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.