001// Copyright 2007, 2008, 2009 The Apache Software Foundation
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
007//     http://www.apache.org/licenses/LICENSE-2.0
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.
015package org.apache.tapestry5.services;
017import org.apache.tapestry5.PropertyConduit;
020 * A source for {@link org.apache.tapestry5.PropertyConduit}s, which can be thought of as a compiled property path
021 * expression. PropertyConduits are the basis of the "prop:" binding factory, thus this service defines the expression
022 * format used by the {@link org.apache.tapestry5.internal.bindings.PropBindingFactory}.
023 */
024public interface PropertyConduitSource
026    /**
027     * Returns a property conduit instance for the given expression. PropertyConduitSource caches the conduits it
028     * returns, so despite the name, this method does not always create a <em>new</em> conduit. The cache is cleared if
029     * a change to component classes is observed.
030     * <p/>
031     * Callers of this method should observe notifications from the {@link org.apache.tapestry5.services.InvalidationEventHub}
032     * for {@link org.apache.tapestry5.services.ComponentClasses} and discard any aquired conduits; failure to do so
033     * will create memory leaks whenever component classes change (the conduits will keep references to the old classes
034     * and classloaders).
035     *
036     * @param rootType   the type of the root object to which the expression is applied
037     * @param expression expression to be evaluated on instances of the root class
038     * @return RuntimeException if the expression is invalid (poorly formed, references non-existent properties, etc.)
039     */
040    PropertyConduit create(Class rootType, String expression);