1 17 18 package org.apache.geronimo.kernel.config; 19 20 import java.io.File ; 21 import java.io.Serializable ; 22 import java.util.ArrayList ; 23 import java.util.Collections ; 24 import java.util.LinkedHashSet ; 25 import java.util.List ; 26 import java.util.Map ; 27 import java.util.LinkedHashMap ; 28 import java.util.Set ; 29 30 import org.apache.geronimo.gbean.GBeanData; 31 import org.apache.geronimo.gbean.GBeanInfo; 32 import org.apache.geronimo.kernel.Naming; 33 import org.apache.geronimo.kernel.repository.Artifact; 34 import org.apache.geronimo.kernel.repository.Environment; 35 36 39 public class ConfigurationData implements Serializable { 40 private static final long serialVersionUID = 4324193220056650732L; 41 42 45 private final long created = System.currentTimeMillis(); 46 47 50 private final ConfigurationModuleType moduleType; 51 52 55 private final Environment environment; 56 57 60 private final LinkedHashSet classPath = new LinkedHashSet (); 61 62 65 private final GBeanState gbeanState; 66 67 70 private final Map childConfigurations = new LinkedHashMap (); 71 72 75 private final Set ownedConfigurations = new LinkedHashSet (); 76 77 80 private transient File configurationDir; 81 82 85 private File inPlaceConfigurationDir; 86 87 90 private boolean autoStart = true; 91 92 95 private transient Naming naming; 96 97 100 private transient ConfigurationStore configurationStore; 101 102 public ConfigurationData(Artifact configId, Naming naming, GBeanState gbeanState) { 103 this(new Environment(configId), naming, gbeanState); 104 } 105 106 public ConfigurationData(Environment environment, Naming naming, GBeanState gbeanState) { 107 if (environment == null) throw new NullPointerException ("environment is null"); 108 if (environment.getConfigId() == null) throw new NullPointerException ("environment.configId is null"); 109 if (naming == null) throw new NullPointerException ("naming is null"); 110 111 this.environment = environment; 112 this.naming = naming; 113 this.gbeanState = gbeanState; 114 115 this.moduleType = ConfigurationModuleType.CAR; 116 } 117 118 public ConfigurationData(Artifact configId, Naming naming) { 119 this(new Environment(configId), naming); 120 } 121 122 public ConfigurationData(Environment environment, Naming naming) { 123 this(null, null, null, null, environment, null, null, naming); 124 } 125 126 public ConfigurationData(ConfigurationModuleType moduleType, LinkedHashSet classPath, List gbeans, Map childConfigurations, Environment environment, File configurationDir, File inPlaceConfigurationDir, Naming naming) { 127 if (naming == null) throw new NullPointerException ("naming is null"); 128 this.naming = naming; 129 if (moduleType != null) { 130 this.moduleType = moduleType; 131 } else { 132 this.moduleType = ConfigurationModuleType.CAR; 133 } 134 if (classPath != null) { 135 this.classPath.addAll(classPath); 136 } 137 gbeanState = ConfigurationUtil.newGBeanState(gbeans); 138 if (childConfigurations != null) { 139 this.childConfigurations.putAll(childConfigurations); 140 } 141 142 if (environment == null) throw new NullPointerException ("environment is null"); 143 if (environment.getConfigId() == null) throw new NullPointerException ("environment.configId is null"); 144 this.environment = environment; 145 this.configurationDir = configurationDir; 146 this.inPlaceConfigurationDir = inPlaceConfigurationDir; 147 } 148 149 public Artifact getId() { 150 return environment.getConfigId(); 151 } 152 153 157 public long getCreated() { 158 return created; 159 } 160 161 public ConfigurationModuleType getModuleType() { 162 return moduleType; 163 } 164 165 public List getClassPath() { 166 return Collections.unmodifiableList(new ArrayList (classPath)); 167 } 168 169 public List getGBeans(ClassLoader classLoader) throws InvalidConfigException { 170 if (classLoader == null) throw new NullPointerException ("classLoader is null"); 171 return gbeanState.getGBeans(classLoader); 172 } 173 174 public void addGBean(GBeanData gbeanData) { 175 if (gbeanData == null) throw new NullPointerException ("gbeanData is null"); 176 gbeanState.addGBean(gbeanData); 177 } 178 179 public GBeanData addGBean(String name, GBeanInfo gbeanInfo) { 180 if (name == null) throw new NullPointerException ("name is null"); 181 if (gbeanInfo == null) throw new NullPointerException ("gbeanInfo is null"); 182 return gbeanState.addGBean(name, gbeanInfo, naming, environment); 183 } 184 185 public GBeanState getGbeanState() { 186 return gbeanState; 187 } 188 189 194 public Map getChildConfigurations() { 195 return Collections.unmodifiableMap(childConfigurations); 196 } 197 198 public void addChildConfiguration(ConfigurationData configurationData) { 199 if (configurationData == null) throw new NullPointerException ("configurationData is null"); 200 childConfigurations.put(configurationData.getId(), configurationData); 201 } 202 203 209 public Set getOwnedConfigurations() { 210 return Collections.unmodifiableSet(ownedConfigurations); 211 } 212 213 public void addOwnedConfigurations(Artifact id) { 214 if (id == null) throw new NullPointerException ("id is null"); 215 if (!id.isResolved()) throw new IllegalArgumentException ("id is not resolved: " + id); 216 ownedConfigurations.add(id); 217 } 218 219 public Environment getEnvironment() { 220 return environment; 221 } 222 223 public File getInPlaceConfigurationDir() { 224 return inPlaceConfigurationDir; 225 } 226 227 public File getConfigurationDir() { 228 return configurationDir; 229 } 230 231 public void setConfigurationDir(File configurationDir) { 232 if (configurationDir == null) throw new NullPointerException ("configurationDir is null"); 233 this.configurationDir = configurationDir; 234 } 235 236 public Naming getNaming() { 237 return naming; 238 } 239 240 public void setNaming(Naming naming) { 241 this.naming = naming; 242 } 243 244 public boolean isAutoStart() { 245 return autoStart; 246 } 247 248 public void setAutoStart(boolean autoStart) { 249 this.autoStart = autoStart; 250 } 251 252 public ConfigurationStore getConfigurationStore() { 253 return configurationStore; 254 } 255 256 public void setConfigurationStore(ConfigurationStore configurationStore) { 257 if (configurationStore == null) throw new NullPointerException ("configurationStore is null"); 258 this.configurationStore = configurationStore; 259 } 260 } 261 | Popular Tags |