public static void copySystemProperties(Properties configProps) { for (Enumeration<?> e = System.getProperties().propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); if (key.startsWith("felix.") || key.startsWith("karaf.") || key.startsWith("org.osgi.framework.")) { configProps.setProperty(key, System.getProperty(key)); } } }
public SimpleFileLock(Properties props) { BootstrapLogManager.configureLogger(LOG); try { String lock = props.getProperty(PROPERTY_LOCK_DIR); if (lock != null) { File karafLock = getKarafLock(new File(lock), props); props.setProperty(PROPERTY_LOCK_DIR, karafLock.getPath()); } else { props.setProperty(PROPERTY_LOCK_DIR, System.getProperty(PROP_KARAF_BASE)); } File base = new File(props.getProperty(PROPERTY_LOCK_DIR)); lockPath = new File(base, "lock"); lockFile = new RandomAccessFile(lockPath, "rw"); } catch (IOException ioe){ throw new RuntimeException("Karaf can't startup, make sure the log file can be accessed and written by the user starting Karaf : " + ioe.getMessage(), ioe); } catch (Exception e){ throw new RuntimeException("Could not create file lock: " + e.getMessage(), e); } }
@Override public void setName(String name) { try { String karafEtc = bundleContext.getProperty("karaf.etc"); File etcDir = new File(karafEtc); File syspropsFile = new File(etcDir, "system.properties"); FileInputStream fis = new FileInputStream(syspropsFile); Properties props = new Properties(); props.load(fis); fis.close(); props.setProperty("karaf.name", name); FileOutputStream fos = new FileOutputStream(syspropsFile); props.store(fos, ""); fos.close(); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
protected Object doExecute() throws Exception { if (name == null) { System.out.println(bundleContext.getProperty("karaf.name")); } else { try { String karafEtc = bundleContext.getProperty("karaf.etc"); File syspropsFile = new File(karafEtc, "system.properties"); FileInputStream fis = new FileInputStream(syspropsFile); Properties props = new Properties(); props.load(fis); fis.close(); props.setProperty("karaf.name", name); FileOutputStream fos = new FileOutputStream(syspropsFile); props.store(fos, ""); fos.close(); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } System.out.println("Instance name changed to " + name + ". Restart needed for this to take effect."); } return null; }
@Override public void setName(String name) { try { String karafEtc = bundleContext.getProperty("karaf.etc"); File etcDir = new File(karafEtc); File syspropsFile = new File(etcDir, "system.properties"); FileInputStream fis = new FileInputStream(syspropsFile); Properties props = new Properties(); props.load(fis); fis.close(); props.setProperty("karaf.name", name); FileOutputStream fos = new FileOutputStream(syspropsFile); props.store(fos, ""); fos.close(); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
throw new Exception(se.getMessage()); props.setProperty(Constants.FRAMEWORK_STORAGE, storage.getAbsolutePath());
val.append(",").append(clause1.toString()); config.setProperty(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, val.toString()); val.append(",").append(clause1.getName()); config.setProperty(Constants.FRAMEWORK_BOOTDELEGATION, val.toString());
this.lockLostThreshold = Integer.parseInt(props.getProperty(PROPERTY_LOCK_LOST_THRESHOLD, DEFAULT_LOCK_LOST_THRESHOLD)); this.lockSlaveBlock = Boolean.parseBoolean(props.getProperty(PROPERTY_LOCK_SLAVE_BLOCK, "false")); this.props.setProperty(Constants.FRAMEWORK_BEGINNING_STARTLEVEL, Integer.toString(lockDefaultBootLevel)); this.shutdownTimeout = Integer.parseInt(props.getProperty(KARAF_SHUTDOWN_TIMEOUT, Integer.toString(shutdownTimeout))); this.useLock = Boolean.parseBoolean(props.getProperty(PROPERTY_USE_LOCK, "true"));
val.append(",").append(clause1.toString()); config.setProperty(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, val.toString()); val.append(",").append(clause1.getName()); config.setProperty(Constants.FRAMEWORK_BOOTDELEGATION, val.toString());