001 /** 002 * 003 * Copyright 2004 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * 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 import java.util.Set; 029 030 /** 031 * Able to retrieve the values of certain "manageable" attributes from a 032 * repository that is more accessible to an end user (compared to the 033 * serialized data in the ConfigStore). 034 * 035 * @version $Rev: 399794 $ $Date: 2006-05-04 11:04:16 -0700 (Thu, 04 May 2006) $ 036 */ 037 public interface ManageableAttributeStore { 038 039 public static final String ATTRIBUTE_STORE = "AttributeStore"; 040 041 /** 042 * Given a configuration name and a set of GBeanDatas, apply all the saved 043 * overrides to that set of GBeans before the caller attempts to load 044 * them. 045 * 046 * @param configurationName The configuration in question 047 * @param datas The initial GBeanData's for all the GBeans in 048 * the configuration 049 * @param classLoader 050 * @return The modified GBeanData's 051 * @throws InvalidConfigException If something bad happens 052 */ 053 public Collection applyOverrides(Artifact configurationName, Collection datas, ClassLoader classLoader) throws InvalidConfigException; 054 055 /** 056 * Sets the stored value for a particular attribute. The attribute is 057 * identified by the configuration name, GBean ObjectName, and attribute 058 * information. Note: it is not possible to store a meaningful value of 059 * "null"; that would be treated the same as if no value was stored. 060 * 061 * Generally, whenever the value for a manageable attribute is changed, 062 * this method should be called so that value isn't reversed the next time 063 * the GBean is started. 064 * 065 * @param configurationName The name of the configuration holding the GBean 066 * in question 067 * @param gbean The ObjectName of the GBean in question 068 * @param attribute The attribute in question 069 * @param value The value to save, or null if no value should be saved 070 */ 071 public void setValue(Artifact configurationName, AbstractName gbean, GAttributeInfo attribute, Object value); 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 */ 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 }