public static TypedProperties toProperties(byte[] source) { try { TypedProperties rc = new TypedProperties(false); if (source != null) { rc.load(new ByteArrayInputStream(source)); } return rc; } catch (IOException ex) { throw new IllegalArgumentException("Cannot load properties", ex); } }
public static TypedProperties toProperties(Map<String, Object> source) { if (source instanceof TypedProperties) { return (TypedProperties) source; } TypedProperties rc = new TypedProperties(false); rc.putAll(source); return rc; }
private static TypedProperties load(RandomAccessFile raf) throws IOException { byte[] buffer = new byte[(int) raf.length()]; raf.readFully(buffer); TypedProperties props = new TypedProperties(); props.load(new ByteArrayInputStream(buffer)); return props; }
public State() { //read port start value from the root instance configuration try { TypedProperties shellProperty = new TypedProperties(); shellProperty.load(new File(System.getProperty("karaf.etc"), "org.apache.karaf.shell.cfg")); defaultSshPortStart = getInt(shellProperty,"sshPort", 8101); TypedProperties managementProperty = new TypedProperties(); managementProperty.load(new File(System.getProperty("karaf.etc"), "org.apache.karaf.management.cfg")); defaultRmiRegistryPortStart = getInt(managementProperty, "rmiRegistryPort", 1099); defaultRmiServerPortStart = getInt(managementProperty, "rmiServerPort", 1099); } catch (Exception e) { LOGGER.debug("Could not read port start value from the root instance configuration.", e); } }
public static TypedProperties toProperties(Map<String, Object> source) { if (source instanceof TypedProperties) { return (TypedProperties) source; } TypedProperties rc = new TypedProperties(false); rc.putAll(source); return rc; }
public static TypedProperties toProperties(byte[] source) { try { TypedProperties rc = new TypedProperties(false); if (source != null) { rc.load(new ByteArrayInputStream(source)); } return rc; } catch (IOException ex) { throw new IllegalArgumentException("Cannot load properties", ex); } }
public State() { //read port start value from the root instance configuration try { TypedProperties shellProperty = new TypedProperties(); shellProperty.load(new File(System.getProperty("karaf.etc"), "org.apache.karaf.shell.cfg")); defaultSshPortStart = getInt(shellProperty,"sshPort", 8101); TypedProperties managementProperty = new TypedProperties(); managementProperty.load(new File(System.getProperty("karaf.etc"), "org.apache.karaf.management.cfg")); defaultRmiRegistryPortStart = getInt(managementProperty, "rmiRegistryPort", 1099); defaultRmiServerPortStart = getInt(managementProperty, "rmiServerPort", 1099); } catch (Exception e) { LOGGER.debug("Could not read port start value from the root instance configuration.", e); } }
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); }
private static TypedProperties loadProps(File file, Properties context) { TypedProperties props = new TypedProperties((name, key, value) -> context.getProperty(value)); try { props.load(file); } catch (Exception e) { System.err.println("Warning: could not load properties from: " + file + ": " + e); } return props; }
private static TypedProperties loadProps(File file, Properties context) { TypedProperties props = new TypedProperties((name, key, value) -> context.getProperty(value)); try { props.load(file); } catch (Exception e) { System.err.println("Warning: could not load properties from: " + file + ": " + e); } return props; }
@Override public void create(String pid) throws MBeanException { try { configRepo.update(pid, new TypedProperties()); } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
@Override public void create(String pid) throws MBeanException { try { configRepo.update(pid, new TypedProperties()); } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
@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 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 String createFactoryConfiguration(String factoryPid, Map<String, String> properties) throws MBeanException { try { TypedProperties props = new TypedProperties(); props.putAll(properties); return configRepo.createFactoryConfiguration(factoryPid, props); } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
@Override public String createFactoryConfiguration(String factoryPid, Map<String, String> properties) throws MBeanException { try { TypedProperties props = new TypedProperties(); props.putAll(properties); return configRepo.createFactoryConfiguration(factoryPid, props); } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
protected Object doExecute() throws Exception { TypedProperties props = getEditedProps(); if (props == null && pid == null) { System.err.println("No configuration is being edited--run the edit command first"); } else { if (props == null) { props = new TypedProperties(); } propertyAction(props); if(requiresUpdate(pid)) { this.configRepository.update(pid, props); } } return null; }
protected Object doExecute() throws Exception { TypedProperties props = getEditedProps(); if (props == null && pid == null) { System.err.println("No configuration is being edited--run the edit command first"); } else { if (props == null) { props = new TypedProperties(); } propertyAction(props); if(requiresUpdate(pid)) { this.configRepository.update(pid, props); } } return null; }