001// Copyright 2006, 2007, 2008, 2009, 2010, 2013 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 org.apache.tapestry5.Asset; 018import org.apache.tapestry5.commons.Resource; 019import org.apache.tapestry5.http.services.Context; 020import org.apache.tapestry5.http.services.ResponseCompressionAnalyzer; 021import org.apache.tapestry5.internal.services.assets.ResourceChangeTracker; 022import org.apache.tapestry5.services.AssetFactory; 023import org.apache.tapestry5.services.assets.AssetPathConstructor; 024import org.apache.tapestry5.services.assets.StreamableResourceSource; 025 026/** 027 * Implementation of {@link AssetFactory} for assets that are part of the web application context. 028 * 029 * @see org.apache.tapestry5.internal.services.ContextResource 030 */ 031public class ContextAssetFactory extends AbstractAssetFactory 032{ 033 034 public ContextAssetFactory(ResponseCompressionAnalyzer compressionAnalyzer, 035 ResourceChangeTracker resourceChangeTracker, 036 StreamableResourceSource streamableResourceSource, 037 AssetPathConstructor assetPathConstructor, 038 Context context) 039 { 040 super(compressionAnalyzer, resourceChangeTracker, streamableResourceSource, assetPathConstructor, 041 new ContextResource(context, "/")); 042 } 043 044 public Asset createAsset(final Resource resource) 045 { 046 return createAsset(resource, RequestConstants.CONTEXT_FOLDER, resource.getPath()); 047 } 048}