001// Copyright 2005 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.tapestry.services;
016
017import org.apache.hivemind.Location;
018import org.apache.hivemind.Resource;
019import org.apache.tapestry.spec.IComponentSpecification;
020import org.apache.tapestry.spec.ILibrarySpecification;
021
022/**
023 * Companion to the standard {@link org.apache.tapestry.engine.Namespace implementation} of
024 * {@link org.apache.tapestry.INamespace}. Defines resources needed by the Namespace instance to
025 * operate (these have grown numerous!)
026 * 
027 * @author Howard M. Lewis Ship
028 * @since 4.0
029 */
030public interface NamespaceResources
031{
032    /**
033     * Finds a child library specification for some parent library specification.
034     * 
035     * @param libraryResource
036     *            the {@link Resource} from which the parent library (or application) specification
037     *            was loaded
038     * @param path
039     *            the relative path from the parent specification resource to the library
040     *            specification. As a special case, a path starting with a leading slash is assumed
041     *            to be on the classpath.
042     * @param location TODO
043     * @return the library specification.
044     */
045    ILibrarySpecification findChildLibrarySpecification(Resource libraryResource, String path, Location location);
046
047    /**
048     * Retrieves a page specification, parsing it as necessary.
049     * 
050     * @param libraryResource
051     *            the base resource for resolving the path to the page specification; this will be
052     *            the resource for the library (or application) specification
053     * @param specificationPath
054     *            the path to the specification to be parsed
055     * @param location
056     *            used to report errors
057     * @throws org.apache.hivemind.ApplicationRuntimeException
058     *             if the specification doesn't exist, is unreadable or invalid.
059     * @see org.apache.tapestry.engine.ISpecificationSource#getPageSpecification(Resource)
060     */
061
062    IComponentSpecification getPageSpecification(Resource libraryResource,
063            String specificationPath, Location location);
064
065    /**
066     * Retrieves a component specification, parsing it as necessary.
067     * 
068     * @param libraryResource
069     *            the base resource for resolving the path to the page specification; this will be
070     *            the resource for the library (or application) specification
071     * @param specificationPath
072     *            the path to the specification to be parsed
073     * @param location
074     *            used to report errors
075     * @throws org.apache.hivemind.ApplicationRuntimeException
076     *             if the specification doesn't exist, is unreadable or invalid.
077     */
078
079    public IComponentSpecification getComponentSpecification(Resource libraryResource,
080            String specificationPath, Location location);
081
082}