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