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.spec;
016    
017    import java.util.Map;
018    
019    import org.apache.hivemind.LocationHolder;
020    import org.apache.tapestry.util.IPropertyHolder;
021    
022    /**
023     * Defines an "extension", which is much like a helper bean, but is part of a
024     * library or application specification (and has the same lifecycle as the
025     * application).
026     * 
027     * @author glongman@intelligentworks.com
028     */
029    public interface IExtensionSpecification extends IPropertyHolder,
030            LocationHolder
031    {
032    
033        String getClassName();
034    
035        void setClassName(String className);
036    
037        void addConfiguration(String propertyName, String value);
038    
039        /**
040         * Returns an immutable Map of the configuration; keyed on property name,
041         * with values as properties to assign.
042         */
043        Map getConfiguration();
044    
045        /**
046         * Invoked to instantiate an instance of the extension and return it. It
047         * also configures properties of the extension.
048         */
049        Object instantiateExtension();
050    
051        /**
052         * Returns true if the extensions should be instantiated immediately after
053         * the containing {@link org.apache.tapestry.spec.LibrarySpecification}if
054         * parsed. Non-immediate extensions are instantiated only as needed.
055         */
056        boolean isImmediate();
057    
058        void setImmediate(boolean immediate);
059    }