001 // Copyright 2006, 2007, 2008, 2010 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 015 package org.apache.tapestry5.ioc.services; 016 017 import org.apache.tapestry5.ioc.annotations.UsesOrderedConfiguration; 018 import org.apache.tapestry5.ioc.annotations.Value; 019 020 /** 021 * Used to manage <em>symbols</em>, configuration properties whose value is evaluated at runtime. Symbols use the Ant 022 * syntax: <code>${foo.bar.baz}</code> where <code>foo.bar.baz</code> is the name of the symbol. The symbol may appear 023 * inside some annotation, such as {@link Value}. 024 * <p/> 025 * The SymbolSource service configuration is an ordered list of {@link org.apache.tapestry5.ioc.services.SymbolProvider}s. 026 * Two key SymbolProvider services are FactoryDefaults and ApplicationDefaults. 027 */ 028 @UsesOrderedConfiguration(SymbolProvider.class) 029 public interface SymbolSource 030 { 031 /** 032 * Expands the value for a particular symbol. This may involve recursive expansion, if the immediate value for the 033 * symbol itself contains symbols. 034 * 035 * @param symbolName 036 * @return the expanded string 037 * @throws RuntimeException if the symbol name can not be expanded (no {@link SymbolProvider} can provide its 038 * value), or if an expansion is directly or indirectly recursive 039 */ 040 String valueForSymbol(String symbolName); 041 042 /** 043 * Given an input string that <em>may</em> contain symbols, returns the string with any and all symbols fully 044 * expanded. 045 * 046 * @param input 047 * @return expanded input 048 */ 049 String expandSymbols(String input); 050 }