001// Licensed under the Apache License, Version 2.0 (the "License"); 002// you may not use this file except in compliance with the License. 003// You may obtain a copy of the License at 004// 005// http://www.apache.org/licenses/LICENSE-2.0 006// 007// Unless required by applicable law or agreed to in writing, software 008// distributed under the License is distributed on an "AS IS" BASIS, 009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 010// See the License for the specific language governing permissions and 011// limitations under the License. 012 013package org.apache.tapestry5.services.assets; 014 015import org.apache.tapestry5.ioc.annotations.Primary; 016import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration; 017 018import java.io.IOException; 019 020/** 021 * Certain kinds of resources can be minimized: this primarily refers to JavaScript and CSS, both of which contain 022 * whitespace, comments and other features that can be reduced. 023 * 024 * The service configuration maps a MIME content type (e.g., "text/javascript") to an appropriate implementation of this 025 * interface. The master service has the @{@link Primary} marker interface. 026 * 027 * @since 5.3 028 */ 029@UsesMappedConfiguration(ResourceMinimizer.class) 030public interface ResourceMinimizer 031{ 032 /** 033 * Checks the {@linkplain StreamableResource#getContentType() content type} of the resource and applies an 034 * appropriate minimization to it if possible. 035 * 036 * @param resource 037 * to minimize 038 * @return the same resource, or a minimized replacement for the resource 039 * @throws IOException 040 */ 041 StreamableResource minimize(StreamableResource resource) throws IOException; 042}