private static Config readComponent(Bundle bundle, XmlPullParser parser) throws XmlPullParserException, IOException, IllegalXMLException { Config curr = new Config(bundle); boolean serviceFound = false; setComponent(curr, parser); int event = parser.getEventType(); while (event != XmlPullParser.END_TAG) { if (event != XmlPullParser.START_TAG) { // nothing of interest. event = parser.next(); continue; } if (isInSCRNamespace(parser, "implementation", 2)) { setImplementation(curr, parser); } else if (isInSCRNamespace(parser, "property", 2)) { setProperty(curr, parser); } else if (isInSCRNamespace(parser, "properties", 2)) { setProperties(curr, parser, bundle); } else if (isInSCRNamespace(parser, "service", 2)) { if (!serviceFound) { serviceFound = true; setService(curr, parser); parser.next(); } else { throw new IllegalXMLException( "More than one service-tag " + "in component: \"" + curr.getName() + "\""); } } else if (isInSCRNamespace(parser, "reference", 2)) { setReference(curr, parser, bundle); } else { skip(parser); } event = parser.getEventType(); } if (curr.getImplementation() == null) { throw new IllegalXMLException( "Component \"" + curr.getName() + "\" lacks implementation-tag"); } return curr; }
private SingleConfigurationConfigurable(RunnerAndConfigurationSettingsImpl settings) { super(new ConfigurationSettingsEditorWrapper(settings), settings); final Config configuration = (Config) getSettings().getConfiguration(); myDisplayName = getSettings().getName(); myHelpTopic = null; // TODO myIcon = configuration.getType().getIcon(); myBrokenConfiguration = configuration instanceof UnknownRunConfiguration; setNameText(configuration.getName()); myNameDocument.addDocumentListener( new DocumentAdapter() { public void textChanged(DocumentEvent event) { setModified(true); } }); getEditor() .addSettingsEditorListener( new SettingsEditorListener() { public void stateChanged(SettingsEditor settingsEditor) { myValidationResultValid = false; } }); }
public synchronized void setConfig(Config config) { if (config.getName() != _config.getName() || config.getCallTracker() != _config.getCallTracker() || config.getClock() != _config.getClock()) { throw new IllegalArgumentException("Degrader Name, CallTracker and Clock cannot be changed"); } _config = new ImmutableConfig(config); _maxDropDuration = config.getMaxDropDuration(); setComputedDropRate(_computedDropRate); // overrideDropRate may have changed }
public Config copyConfig(Configs configs, Config config, String destConfigName, Logger logger) throws PropertyVetoException, TransactionFailure { final Config destCopy = (Config) config.deepCopy(configs); if (systemproperties != null) { final Properties properties = GenericCrudCommand.convertStringToProperties(systemproperties, ':'); for (final Object key : properties.keySet()) { final String propName = (String) key; // cannot update a system property so remove it first List<SystemProperty> sysprops = destCopy.getSystemProperty(); for (SystemProperty sysprop : sysprops) { if (propName.equals(sysprop.getName())) { sysprops.remove(sysprop); break; } } SystemProperty newSysProp = destCopy.createChild(SystemProperty.class); newSysProp.setName(propName); newSysProp.setValue(properties.getProperty(propName)); destCopy.getSystemProperty().add(newSysProp); } } final String configName = destConfigName; destCopy.setName(configName); configs.getConfig().add(destCopy); copyOfConfig = destCopy; String srcConfig = ""; srcConfig = config.getName(); File configConfigDir = new File(env.getConfigDirPath(), configName); for (Config c : configs.getConfig()) { File existingConfigConfigDir = new File(env.getConfigDirPath(), c.getName()); if (!c.getName().equals(configName) && configConfigDir.equals(existingConfigConfigDir)) { throw new TransactionFailure( localStrings.getLocalString( "config.duplicate.dir", "Config {0} is trying to use the same directory as config {1}", configName, c.getName())); } } try { if (!(new File(configConfigDir, "docroot").mkdirs() && new File(configConfigDir, "lib/ext").mkdirs())) { throw new IOException( localStrings.getLocalString( "config.mkdirs", "error creating config specific directories")); } String srcConfigLoggingFile = env.getInstanceRoot().getAbsolutePath() + File.separator + "config" + File.separator + srcConfig + File.separator + ServerEnvironmentImpl.kLoggingPropertiesFileName; File src = new File(srcConfigLoggingFile); if (!src.exists()) { src = new File(env.getConfigDirPath(), ServerEnvironmentImpl.kLoggingPropertiesFileName); } File dest = new File(configConfigDir, ServerEnvironmentImpl.kLoggingPropertiesFileName); FileUtils.copy(src, dest); } catch (Exception e) { logger.log(Level.WARNING, ConfigApiLoggerInfo.copyConfigError, e.getLocalizedMessage()); } return destCopy; }