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;
014
015import org.apache.tapestry5.Binding;
016import org.apache.tapestry5.ComponentResources;
017import org.apache.tapestry5.commons.Location;
018
019/**
020 * Creates a binding of a particular type.  This is usually invoked from the {@link
021 * org.apache.tapestry5.services.BindingSource} service.
022 */
023public interface BindingFactory
024{
025    /**
026     * Creates a new binding instance.
027     *
028     * The binding represents a connection between the container and the component (the component is usually the child
029     * of the component, though in a few cases, it is the component itself). In most cases, the expression is evaluated
030     * in terms of the resources of the <em>container</em> and the component is ignored.
031     *
032     * @param description of the binding, such as, "parameter foo"
033     * @param container   the component, as represented by its resources, for which a binding is to be created.
034     * @param component   the component whose parameter is to be bound by the resulting binding (rarely used)
035     * @param expression
036     * @param location    from which the binding was generate, or null if not known
037     * @return the new binding instance
038     */
039    Binding newBinding(String description, ComponentResources container, ComponentResources component,
040                       String expression, Location location);
041}