001 // Copyright 2011 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry5.services.assets; 016 017 import org.apache.tapestry5.ioc.Resource; 018 import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration; 019 020 import java.io.IOException; 021 022 /** 023 * Converts {@link Resource}s into {@link StreamableResource}s, and may be responsible for 024 * {@linkplain ResourceTransformer transforming} resources based on file extension. In addition, 025 * service decorators added to the service may provide additional processing (compression, minimization, and caching). 026 * 027 * @since 5.3 028 */ 029 @UsesMappedConfiguration(ResourceTransformer.class) 030 public interface StreamableResourceSource 031 { 032 /** 033 * Converts a Resource (which must be non-null and exist) into a streamable resource, along with 034 * some additional optional behaviors. 035 * 036 * @param baseResource the resource to convert 037 * @param processing defines additional processing after the resource has been read and possibly transformed 038 * @param dependencies Passed to any {@link ResourceTransformer} to track additional dependencies of the base resource 039 * @return the contents of the Resource, possibly transformed, in a streamable format. 040 * @throws IOException if the resource does not exist or a URL for the content is not available 041 */ 042 StreamableResource getStreamableResource(Resource baseResource, StreamableResourceProcessing processing, ResourceDependencies dependencies) 043 throws IOException; 044 }