001 /* 002 * Copyright 2007 Tacos. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * under the License. 016 */ 017 package net.sf.tacos.asset; 018 019 import java.io.InputStream; 020 021 import org.apache.tapestry.IAsset; 022 import org.apache.hivemind.Resource; 023 import org.apache.hivemind.Location; 024 import org.apache.tapestry.services.AbsoluteURLBuilder; 025 026 /** 027 * Decorates an asset in order to generate an absolute url. 028 * @author Andreas Andreou 029 */ 030 public class AbsoluteAsset implements IAsset { 031 032 private IAsset asset; 033 private AbsoluteURLBuilder absoluteURLBuilder; 034 035 public AbsoluteAsset(IAsset asset, AbsoluteURLBuilder absoluteURLBuilder) { 036 this.asset = asset; 037 this.absoluteURLBuilder = absoluteURLBuilder; 038 } 039 040 public String buildURL() { 041 return absoluteURLBuilder.constructURL(asset.buildURL()); 042 } 043 044 public InputStream getResourceAsStream() { 045 return asset.getResourceAsStream(); 046 } 047 048 public Resource getResourceLocation() { 049 return asset.getResourceLocation(); 050 } 051 052 public Location getLocation() { 053 return asset.getLocation(); 054 } 055 } 056