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.services.javascript;
014
015import org.apache.tapestry5.commons.Resource;
016import org.apache.tapestry5.commons.util.UnknownValueException;
017import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
018
019import java.util.List;
020
021/**
022 * Manages the available {@link JavaScriptStack}s, each of which has a unique name.
023 *
024 * @since 5.2.0
025 */
026@UsesMappedConfiguration(JavaScriptStack.class)
027public interface JavaScriptStackSource
028{
029    /**
030     * Gets a stack by name (ignoring case).
031     *
032     * @return named stack
033     * @throws UnknownValueException
034     *         if no such stack
035     */
036    JavaScriptStack getStack(String name);
037
038    /**
039     * Gets a stack by name (ignoring case).
040     *
041     * @return named stack, or null if not found
042     * @since 5.4
043     */
044    JavaScriptStack findStack(String name);
045
046    /**
047     * Returns the names of all stacks, in sorted order.
048     *
049     * @since 5.2.1
050     */
051    List<String> getStackNames();
052
053    /**
054     * Attempts to find the stack containing the indicated JavaScript library.
055     *
056     * @param resource identifies a potential JavaScript Library
057     * @return the stack if found, or null
058     * @since 5.4
059     * @see JavaScriptStack#getJavaScriptLibraries()
060     */
061    JavaScriptStack findStackForJavaScriptLibrary(Resource resource);
062}