protected String getString(String key, String def) { if (configuration != null) { Object val = configuration.get(key); if (val != null) { return val.toString(); } } return def; }
@Override public void propertyAction(TypedProperties props) { if (raw) { List<String> strings = props.getRaw(prop); for (String s : strings) { System.out.println(s); } } else { System.out.println(displayValue(props.get(prop))); } }
private static String getString(TypedProperties storage, String name, String def) { Object value = storage.get(name); return value != null ? value.toString() : def; }
@Override public void propertyAction(TypedProperties props) { if (raw) { List<String> strings = props.getRaw(prop); for (String s : strings) { System.out.println(s); } } else { System.out.println(displayValue(props.get(prop))); } }
private static String getString(TypedProperties storage, String name, String def) { Object value = storage.get(name); return value != null ? value.toString() : def; }
protected String getString(String key, String def) { if (configuration != null) { Object val = configuration.get(key); if (val != null) { return val.toString(); } } return def; }
private static boolean getBool(TypedProperties storage, String name, boolean def) { Object value = storage.get(name); if (value instanceof Boolean) { return (Boolean) value; } else if (value != null) { return Boolean.parseBoolean(value.toString()); } else { return def; } }
private static int getInt(TypedProperties storage, String name, int def) { Object value = storage.get(name); if (value instanceof Number) { return ((Number) value).intValue(); } else if (value != null) { return Integer.parseInt(value.toString()); } else { return def; } }
protected int getInt(String key, int def) { if (configuration != null) { Object val = configuration.get(key); if (val instanceof Number) { return ((Number) val).intValue(); } else if (val != null) { return Integer.parseInt(val.toString()); } } return def; }
private static boolean getBool(TypedProperties storage, String name, boolean def) { Object value = storage.get(name); if (value instanceof Boolean) { return (Boolean) value; } else if (value != null) { return Boolean.parseBoolean(value.toString()); } else { return def; } }
private static int getInt(TypedProperties storage, String name, int def) { Object value = storage.get(name); if (value instanceof Number) { return ((Number) value).intValue(); } else if (value != null) { return Integer.parseInt(value.toString()); } else { return def; } }
protected long getLong(String key, long def) { if (configuration != null) { Object val = configuration.get(key); if (val instanceof Number) { return ((Number) val).longValue(); } else if (val != null) { return Long.parseLong(val.toString()); } } return def; }
protected long getLong(String key, long def) { if (configuration != null) { Object val = configuration.get(key); if (val instanceof Number) { return ((Number) val).longValue(); } else if (val != null) { return Long.parseLong(val.toString()); } } return def; }
protected int getInt(String key, int def) { if (configuration != null) { Object val = configuration.get(key); if (val instanceof Number) { return ((Number) val).intValue(); } else if (val != null) { return Integer.parseInt(val.toString()); } } return def; }
private String getKarafHost(State state, String name, String path, final String key) { InstanceState instance = state.instances.get(name); if (instance == null) { throw new IllegalArgumentException("Instance " + name + " not found"); } File f = new File(instance.loc, path); try { return FileLockUtils.execute(f, (TypedProperties properties) -> properties.get(key).toString(), false); } catch (IOException e) { return "0.0.0.0"; } }
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()); }
private String getKarafHost(State state, String name, String path, final String key) { InstanceState instance = state.instances.get(name); if (instance == null) { throw new IllegalArgumentException("Instance " + name + " not found"); } File f = new File(instance.loc, path); try { return FileLockUtils.execute(f, (TypedProperties properties) -> properties.get(key).toString(), false); } catch (IOException e) { return "0.0.0.0"; } }
private Integer getKarafPort(State state, String name, String path, final String key) { InstanceState instance = state.instances.get(name); if (instance == null) { throw new IllegalArgumentException("Instance " + name + " not found"); } File f = new File(instance.loc, path); try { return FileLockUtils.execute(f, properties -> { Object obj = properties.get(key); return obj instanceof Number ? ((Number) obj).intValue() : Integer.parseInt(obj.toString()); }, false); } catch (IOException e) { return 0; } }
@Override public String getProperty(String pid, String key) throws MBeanException { try { TypedProperties dictionary = getConfigProperties(pid); Object value = dictionary.get(key); if (value != null) { return value.toString(); } return null; } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
@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()); } }