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: 487175 $ $Date: 2006-12-14 03:10:31 -0800 (Thu, 14 Dec 2006) $
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         */
070        public void setValue(Artifact configurationName, AbstractName gbean, GAttributeInfo attribute, Object value);
071    
072        /**
073         * Sets the pattern for a GBean reference. The reference is
074         * identified by the configuration name, GBean ObjectName, and reference
075         * information.
076         *
077         * To "null-out" the reference use setReferencePatterns(configurationName, gbean, reference, Collections.EMPTY_SET).
078         *
079         * @param configurationName the name of the configuration holding the GBean in question
080         * @param gbean the ObjectName of the GBean
081         * @param reference the attribute information
082         * @param patterns
083         */
084        public void setReferencePatterns(Artifact configurationName, AbstractName gbean, GReferenceInfo reference, ReferencePatterns patterns);
085    
086        /**
087         * Sets whether a particular GBean should be loaded for this configuration.
088         * The GBean must already exist in the configuration, this just toggles the
089         * flag for whether to stop it from loading when the configuration is
090         * loaded.
091         *
092         * @param configurationName The configuration that the GBean belongs to
093         * @param gbean             The GBean in question
094         * @param load              True if the GBean should load with the configuration
095         */
096        public void setShouldLoad(Artifact configurationName, AbstractName gbean, boolean load);
097    
098    
099        /**
100         * Adds a GBean to the configuration.
101         * @param configurationName the configuration that the GBean belongs to
102         * @param gbeanData the GBean to add
103         */
104        public void addGBean(Artifact configurationName, GBeanData gbeanData);
105    
106        /**
107         * Saves the current values to persistent storage.  This should be called
108         * when the server is shut down or more often, to make sure that any
109         * changes will be reflected the next time the server starts and the
110         * store is consulted.
111         */
112        public void save() throws IOException;
113    }