1 /* 2 * Copyright 2002-2014 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.springframework.web.servlet.resource; 18 19 import java.io.IOException; 20 import javax.servlet.http.HttpServletRequest; 21 22 import org.springframework.core.io.Resource; 23 24 /** 25 * A contract for invoking a chain of {@link ResourceTransformer}s where each resolver 26 * is given a reference to the chain allowing it to delegate when necessary. 27 * 28 * @author Rossen Stoyanchev 29 * @since 4.1 30 */ 31 public interface ResourceTransformerChain { 32 33 /** 34 * Return the {@code ResourceResolverChain} that was used to resolve the 35 * {@code Resource} being transformed. This may be needed for resolving 36 * related resources, e.g. links to other resources. 37 */ 38 ResourceResolverChain getResolverChain(); 39 40 /** 41 * Transform the given resource. 42 * 43 * @param request the current request 44 * @param resource the candidate resource to transform 45 * @return the transformed or the same resource, never {@code null} 46 * 47 * @throws java.io.IOException if transformation fails 48 */ 49 Resource transform(HttpServletRequest request, Resource resource) throws IOException; 50 51 }