001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.kernel.config;
018    
019    import org.apache.geronimo.gbean.GAttributeInfo;
020    import org.apache.geronimo.gbean.GBeanData;
021    import org.apache.geronimo.gbean.GReferenceInfo;
022    import org.apache.geronimo.gbean.AbstractName;
023    import org.apache.geronimo.gbean.ReferencePatterns;
024    import org.apache.geronimo.kernel.repository.Artifact;
025    
026    import java.io.IOException;
027    import java.util.Collection;
028    
029    /**
030     * Able to retrieve the values of certain "manageable" attributes from a
031     * repository that is more accessible to an end user (compared to the
032     * serialized data in the ConfigStore).
033     *
034     * @version $Rev: 555993 $ $Date: 2007-07-13 09:39:25 -0400 (Fri, 13 Jul 2007) $
035     */
036    public interface ManageableAttributeStore {
037    
038        public static final String ATTRIBUTE_STORE = "AttributeStore";
039    
040        /**
041         * Given a configuration name and a set of GBeanDatas, apply all the saved
042         * overrides to that set of GBeans before the caller attempts to load
043         * them.
044         *
045         * @param configurationName The configuration in question
046         * @param datas             The initial GBeanData's for all the GBeans in
047         *                          the configuration
048         * @param classLoader
049         * @return                  The modified GBeanData's
050         * @throws InvalidConfigException If something bad happens
051         */
052        public Collection applyOverrides(Artifact configurationName, Collection datas, ClassLoader classLoader) throws InvalidConfigException;
053    
054        /**
055         * Sets the stored value for a particular attribute.  The attribute is
056         * identified by the configuration name, GBean ObjectName, and attribute
057         * information.  Note: it is not possible to store a meaningful value of
058         * "null"; that would be treated the same as if no value was stored.
059         *
060         * Generally, whenever the value for a manageable attribute is changed,
061         * this method should be called so that value isn't reversed the next time
062         * the GBean is started.
063         *
064         * @param configurationName The name of the configuration holding the GBean
065         *                          in question
066         * @param gbean The ObjectName of the GBean in question
067         * @param attribute The attribute in question
068         * @param value The value to save, or null if no value should be saved
069         * @param classLoader The configuration's classLoader
070         */
071        public void setValue(Artifact configurationName, AbstractName gbean, GAttributeInfo attribute, Object value, ClassLoader classLoader);
072    
073        /**
074         * Sets the pattern for a GBean reference. The reference is
075         * identified by the configuration name, GBean ObjectName, and reference
076         * information.
077         *
078         * To "null-out" the reference use setReferencePatterns(configurationName, gbean, reference, Collections.EMPTY_SET).
079         *
080         * @param configurationName the name of the configuration holding the GBean in question
081         * @param gbean the ObjectName of the GBean
082         * @param reference the attribute information
083         * @param patterns
084         */
085        public void setReferencePatterns(Artifact configurationName, AbstractName gbean, GReferenceInfo reference, ReferencePatterns patterns);
086    
087        /**
088         * Sets whether a particular GBean should be loaded for this configuration.
089         * The GBean must already exist in the configuration, this just toggles the
090         * flag for whether to stop it from loading when the configuration is
091         * loaded.
092         *
093         * @param configurationName The configuration that the GBean belongs to
094         * @param gbean             The GBean in question
095         * @param load              True if the GBean should load with the configuration
096         */
097        public void setShouldLoad(Artifact configurationName, AbstractName gbean, boolean load);
098    
099    
100        /**
101         * Adds a GBean to the configuration.
102         * @param configurationName the configuration that the GBean belongs to
103         * @param gbeanData the GBean to add
104         * @param classLoader The configuration classLoader
105         */
106        public void addGBean(Artifact configurationName, GBeanData gbeanData, ClassLoader classLoader);
107    
108        /**
109         * Saves the current values to persistent storage.  This should be called
110         * when the server is shut down or more often, to make sure that any
111         * changes will be reflected the next time the server starts and the
112         * store is consulted.
113         */
114        public void save() throws IOException;
115    }