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