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    
015    package org.apache.tapestry;
016    
017    import java.util.Collection;
018    
019    import org.apache.hivemind.ApplicationRuntimeException;
020    import org.apache.hivemind.ClassResolver;
021    
022    /**
023     * An object that provides a component with access to helper beans. Helper beans
024     * are JavaBeans associated with a page or component that are used to extend the
025     * functionality of the component via aggregation.
026     * 
027     * @author Howard Lewis Ship
028     * @since 1.0.4
029     */
030    
031    public interface IBeanProvider
032    {
033    
034        /**
035         * Returns the JavaBean with the specified name. The bean is created as
036         * needed.
037         * 
038         * @throws ApplicationRuntimeException
039         *             if no such bean is available.
040         */
041    
042        Object getBean(String name);
043    
044        /**
045         * Returns the {@link IComponent} (which may be a
046         * {@link org.apache.tapestry.IPage}) for which this bean provider is
047         * providing beans.
048         * 
049         * @since 1.0.5
050         */
051    
052        IComponent getComponent();
053    
054        /**
055         * Returns a collection of the names of any beans which may be provided.
056         * 
057         * @since 1.0.6
058         * @see org.apache.tapestry.spec.IComponentSpecification#getBeanNames()
059         */
060    
061        Collection getBeanNames();
062    
063        /**
064         * Returns true if the provider can provide the named bean.
065         * 
066         * @since 2.2
067         */
068    
069        boolean canProvideBean(String name);
070    
071        /**
072         * Returns a resource resolver.
073         * 
074         * @since 1.0.8
075         */
076    
077        ClassResolver getClassResolver();
078    
079    }