001// Copyright 2006, 2008, 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 015package org.apache.tapestry5.internal.services; 016 017import java.io.IOException; 018 019import javax.servlet.http.HttpServletResponse; 020 021import org.apache.tapestry5.ioc.Resource; 022import org.apache.tapestry5.services.assets.StreamableResource; 023import org.apache.tapestry5.services.assets.StreamableResourceSource; 024 025/** 026 * Responsible for streaming the contents of a resource to the client. The {@link org.apache.tapestry5.ioc.Resource} to 027 * stream is a {@link org.apache.tapestry5.ioc.internal.util.ClasspathResource} or {@link ContextResource}. 028 * 029 * @since 5.1.0.0 030 */ 031public interface ResourceStreamer 032{ 033 /** 034 * Streams the content of the resource to the client (or sends 035 * an alternative response such as {@link HttpServletResponse#SC_NOT_MODIFIED}). Encapsulates logic for compression 036 * and for caching. 037 * 038 * @see StreamableResourceSource 039 */ 040 void streamResource(Resource resource) throws IOException; 041 042 /** 043 * Streams a resource that has been assembled elsewhere. 044 * 045 * @param resource 046 * @throws IOException 047 * @since 5.3 048 */ 049 void streamResource(StreamableResource resource) throws IOException; 050}