1 5 package com.tc.config.schema; 6 7 import org.apache.xmlbeans.XmlObject; 8 9 import com.tc.config.schema.context.ConfigContext; 10 import com.tc.config.schema.dynamic.ConfigItem; 11 import com.tc.config.schema.dynamic.XPathBasedConfigItem; 12 import com.tc.config.schema.setup.ConfigurationSetupException; 13 import com.tc.util.Assert; 14 import com.terracottatech.config.ConfigurationModel; 15 import com.terracottatech.config.System; 16 17 20 public class NewSystemConfigObject extends BaseNewConfigObject implements NewSystemConfig { 21 22 private final ConfigItem configurationModel; 23 24 public NewSystemConfigObject(ConfigContext context) throws ConfigurationSetupException { 25 super(context); 26 27 this.context.ensureRepositoryProvides(System .class); 28 29 this.configurationModel = new XPathBasedConfigItem(this.context, "configuration-model") { 30 protected Object fetchDataFromXmlObject(XmlObject xmlObject) { 31 if (xmlObject == null) return null; 32 if (((ConfigurationModel) xmlObject).enumValue().equals(ConfigurationModel.DEVELOPMENT)) return com.tc.config.schema.ConfigurationModel.DEVELOPMENT; 33 if (((ConfigurationModel) xmlObject).enumValue().equals(ConfigurationModel.PRODUCTION)) return com.tc.config.schema.ConfigurationModel.PRODUCTION; 34 throw Assert.failure("Unexpected configuration model: " + xmlObject); 35 } 36 }; 37 } 38 39 public ConfigItem configurationModel() { 40 return this.configurationModel; 41 } 42 43 } 44 | Popular Tags |