001// Copyright 2004, 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.resolver;
016
017import org.apache.hivemind.Location;
018import org.apache.tapestry.INamespace;
019import org.apache.tapestry.IRequestCycle;
020import org.apache.tapestry.spec.IComponentSpecification;
021
022/**
023 * Service interface for locating component specifications.
024 * 
025 * @author Howard Lewis Ship
026 * @since 4.0
027 */
028public interface ComponentSpecificationResolver
029{
030    /**
031     * Passed the namespace of a container (to resolve the type in) and the type to resolve,
032     * performs the processing. A "bare type" (without a library prefix) may be in the
033     * containerNamespace, or the framework namespace (a search occurs in that order).
034     * 
035     * @param cycle
036     *            current request cycle
037     * @param containerNamespace
038     *            namespace that may contain a library referenced in the type
039     * @param type
040     *            the component specification to find, either a simple name, or prefixed with a
041     *            library id (defined for the container namespace)
042     * @see #getNamespace()
043     * @see #getSpecification()
044     */
045    public void resolve(IRequestCycle cycle, INamespace containerNamespace, String type,
046            Location location);
047
048    /**
049     * Like
050     * {@link #resolve(org.apache.tapestry.IRequestCycle, org.apache.tapestry.INamespace, java.lang.String, org.apache.tapestry.ILocation)},
051     * but used when the type has already been parsed into a library id and a simple type.
052     * 
053     * @param cycle
054     *            current request cycle
055     * @param containerNamespace
056     *            namespace that may contain a library referenced in the type
057     * @param libraryId
058     *            the library id within the container namespace, or null
059     * @param type
060     *            the component specification to find as a simple name (without a library prefix)
061     * @param location
062     *            of reference to be resolved
063     * @throws ApplicationRuntimeException
064     *             if the type cannot be resolved
065     */
066    public void resolve(IRequestCycle cycle, INamespace containerNamespace, String libraryId,
067            String type, Location location);
068
069    /**
070     * The specification resolved by the resolve() method.
071     */
072    public IComponentSpecification getSpecification();
073
074    /**
075     * The namespace containing the resolved component.
076     */
077    public INamespace getNamespace();
078
079    /**
080     * Returns the unqualified type of the component (i.e., with any namespace prefix stripped off).
081     */
082    public String getType();
083}