@Override public void propertyAction(TypedProperties props) { props.put(prop, value); }
@Override public String createFactoryConfiguration(String factoryPid, String alias, Map<String, Object> properties) throws IOException { Configuration config = configAdmin.createFactoryConfiguration(factoryPid, "?"); TypedProperties props = new TypedProperties(); File file = null; if (alias != null && !"".equals(alias.trim())) { file = new File(new File(System.getProperty("karaf.etc")), factoryPid + "-" + alias + ".cfg"); } else { file = File.createTempFile(factoryPid + "-", ".cfg", new File(System.getProperty("karaf.etc"))); } props.putAll(properties); props.save(file); props.put(FILEINSTALL_FILE_NAME, file.toURI().toString()); config.update(new Hashtable<>(props)); return config.getPid(); }
@Override public void propertyAction(TypedProperties props) { props.put(prop, value); }
public Object put(String key, String comment, Object value) { return put(key, Collections.singletonList(comment), value); }
public Object put(String key, String comment, Object value) { return put(key, Collections.singletonList(comment), value); }
public Object put(String key, String comment, Object value) { return put(key, Collections.singletonList(comment), value); }
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public void propertyAction(TypedProperties props) { final Object currentValue = props.get(prop); if (currentValue == null) { props.put(prop, value); } else if (currentValue instanceof String) { props.put(prop, currentValue + value); } else if (currentValue instanceof Collection) { ((Collection) currentValue).add(value); } else { System.err.println("Append Failed: current value is not a String."); } } }
private static void appendToPropList(TypedProperties p, String key, List<String> elements) { if (elements == null) { return; } StringBuilder sb = new StringBuilder(p.get(key).toString().trim()); for (String f : elements) { if (sb.length() > 0) { sb.append(','); } sb.append(f); } p.put(key, sb.toString()); }
/** * Puts properties under single comment. * @param comment * @param properties * @param values */ private void addGroupOfProperties(String comment, TypedProperties properties, Map<String, Object> values) { boolean first = true; for (Entry<String, Object> entry : values.entrySet()) { if (first) { first = false; properties.put(entry.getKey(), comment(comment), entry.getValue()); } else { properties.put(entry.getKey(), entry.getValue()); } } }
private static void appendToPropList(TypedProperties p, String key, List<String> elements) { if (elements == null) { return; } StringBuilder sb = new StringBuilder(p.get(key).toString().trim()); for (String f : elements) { if (sb.length() > 0) { sb.append(','); } sb.append(f); } p.put(key, sb.toString()); }
public boolean update(Map<String, Object> props) { TypedProperties properties; if (props instanceof TypedProperties) { properties = (TypedProperties) props; } else { properties = new TypedProperties(); for (Entry<String, Object> e : props.entrySet()) { properties.put(e.getKey(), e.getValue()); } } return update(properties); }
public boolean update(Map<String, Object> props) { TypedProperties properties; if (props instanceof TypedProperties) { properties = (TypedProperties) props; } else { properties = new TypedProperties(); for (Entry<String, Object> e : props.entrySet()) { properties.put(e.getKey(), e.getValue()); } } return update(properties); }
public boolean update(Map<String, Object> props) { TypedProperties properties; if (props instanceof TypedProperties) { properties = (TypedProperties) props; } else { properties = new TypedProperties(); for (Entry<String, Object> e : props.entrySet()) { properties.put(e.getKey(), e.getValue()); } } return update(properties); }
public Object put(String key, List<String> commentLines, Object value) { if (value instanceof String && !storage.typed) { return storage.put(key, commentLines, (String) value); } else { ensureTyped(); return put(key, commentLines, Arrays.asList(convertToString(value).split("\n"))); } }
@Override public void appendProperty(String pid, String key, String value) throws MBeanException { try { TypedProperties dictionary = getConfigProperties(pid); Object currentValue = dictionary.get(key); if (currentValue == null) { dictionary.put(key, value); } else if (currentValue instanceof String) { dictionary.put(key, currentValue + value); } else { throw new IllegalStateException("Current value is not a String"); } configRepo.update(pid, dictionary); } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
private void setKarafHost(final String name, final String path, final String key, final String host) throws IOException { execute(state -> { InstanceState instance = state.instances.get(name); if (instance == null) { throw new IllegalArgumentException("Instance " + name + " not found"); } checkPid(instance); if (instance.pid != 0) { throw new IllegalStateException("Instance is not stopped"); } File f = new File(instance.loc, path); FileLockUtils.execute(f, properties -> { properties.put(key, host); }, true); return null; }, true); }
public Object put(String key, List<String> commentLines, Object value) { if (value instanceof String && !storage.typed) { return storage.put(key, commentLines, (String) value); } else { ensureTyped(); return put(key, commentLines, Arrays.asList(convertToString(value).split("\n"))); } }
public Object put(String key, List<String> commentLines, Object value) { if (value instanceof String && !storage.typed) { return storage.put(key, commentLines, (String) value); } else { ensureTyped(); return put(key, commentLines, Arrays.asList(convertToString(value).split("\n"))); } }
@Override public void setProperty(String pid, String key, String value) throws MBeanException { try { TypedProperties dictionary = getConfigProperties(pid); dictionary.put(key, value); configRepo.update(pid, dictionary); } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
@Override public void setProperty(String pid, String key, String value) throws MBeanException { try { TypedProperties dictionary = getConfigProperties(pid); dictionary.put(key, value); configRepo.update(pid, dictionary); } catch (Exception e) { throw new MBeanException(null, e.toString()); } }