View Javadoc

1   /**
2    *
3    * Copyright 2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.geronimo.kernel.config;
18  
19  import org.apache.geronimo.gbean.GAttributeInfo;
20  import org.apache.geronimo.gbean.GBeanData;
21  import org.apache.geronimo.gbean.GReferenceInfo;
22  import org.apache.geronimo.gbean.AbstractName;
23  import org.apache.geronimo.gbean.ReferencePatterns;
24  import org.apache.geronimo.kernel.repository.Artifact;
25  
26  import java.io.IOException;
27  import java.util.Collection;
28  import java.util.Set;
29  
30  /**
31   * Able to retrieve the values of certain "manageable" attributes from a
32   * repository that is more accessible to an end user (compared to the
33   * serialized data in the ConfigStore).
34   *
35   * @version $Rev: 399794 $ $Date: 2006-05-04 11:04:16 -0700 (Thu, 04 May 2006) $
36   */
37  public interface ManageableAttributeStore {
38  
39      public static final String ATTRIBUTE_STORE = "AttributeStore";
40  
41      /**
42       * Given a configuration name and a set of GBeanDatas, apply all the saved
43       * overrides to that set of GBeans before the caller attempts to load
44       * them.
45       *
46       * @param configurationName The configuration in question
47       * @param datas             The initial GBeanData's for all the GBeans in
48       *                          the configuration
49       * @param classLoader
50       * @return                  The modified GBeanData's
51       * @throws InvalidConfigException If something bad happens
52       */
53      public Collection applyOverrides(Artifact configurationName, Collection datas, ClassLoader classLoader) throws InvalidConfigException;
54  
55      /**
56       * Sets the stored value for a particular attribute.  The attribute is
57       * identified by the configuration name, GBean ObjectName, and attribute
58       * information.  Note: it is not possible to store a meaningful value of
59       * "null"; that would be treated the same as if no value was stored.
60       *
61       * Generally, whenever the value for a manageable attribute is changed,
62       * this method should be called so that value isn't reversed the next time
63       * the GBean is started.
64       *
65       * @param configurationName The name of the configuration holding the GBean
66       *                          in question
67       * @param gbean The ObjectName of the GBean in question
68       * @param attribute The attribute in question
69       * @param value The value to save, or null if no value should be saved
70       */
71      public void setValue(Artifact configurationName, AbstractName gbean, GAttributeInfo attribute, Object value);
72  
73      /**
74       * Sets the pattern for a GBean reference. The reference is
75       * identified by the configuration name, GBean ObjectName, and reference
76       * information.
77       *
78       * To "null-out" the reference use setReferencePatterns(configurationName, gbean, reference, Collections.EMPTY_SET).
79       *
80       * @param configurationName the name of the configuration holding the GBean in question
81       * @param gbean the ObjectName of the GBean
82       * @param reference the attribute information
83       * @param patterns
84       */
85      public void setReferencePatterns(Artifact configurationName, AbstractName gbean, GReferenceInfo reference, ReferencePatterns patterns);
86  
87      /**
88       * Sets whether a particular GBean should be loaded for this configuration.
89       * The GBean must already exist in the configuration, this just toggles the
90       * flag for whether to stop it from loading when the configuration is
91       * loaded.
92       *
93       * @param configurationName The configuration that the GBean belongs to
94       * @param gbean             The GBean in question
95       * @param load              True if the GBean should load with the configuration
96       */
97      public void setShouldLoad(Artifact configurationName, AbstractName gbean, boolean load);
98  
99  
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      */
105     public void addGBean(Artifact configurationName, GBeanData gbeanData);
106 
107     /**
108      * Saves the current values to persistent storage.  This should be called
109      * when the server is shut down or more often, to make sure that any
110      * changes will be reflected the next time the server starts and the
111      * store is consulted.
112      */
113     public void save() throws IOException;
114 }