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