org.apache.felix.utils.properties.Properties.setProperty()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.apache.felix.utils.properties.Properties.setProperty()方法的一些代码示例,展示了Properties.setProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Properties.setProperty()方法的具体详情如下:
包路径:org.apache.felix.utils.properties.Properties
类名称:Properties
方法名:setProperty

Properties.setProperty介绍

[英]Calls the map method put. Provided for parallelism with the getProperty method. Enforces use of strings for property keys and values. The value returned is the result of the map call to put.
[中]调用map方法put。提供了与getProperty方法的并行性。强制对属性键和值使用字符串。返回的值是对put的map调用的结果。

代码示例

代码示例来源:origin: apache/karaf

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));
    }
  }
}

代码示例来源:origin: apache/karaf

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);
  }
}

代码示例来源:origin: apache/karaf

@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);
  }
}

代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.osgi

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;
}

代码示例来源:origin: org.apache.karaf.system/org.apache.karaf.system.core

@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);
  }
}

代码示例来源:origin: apache/karaf

throw new Exception(se.getMessage()); 
props.setProperty(Constants.FRAMEWORK_STORAGE, storage.getAbsolutePath());

代码示例来源:origin: apache/karaf

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());

代码示例来源:origin: apache/karaf

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"));

代码示例来源:origin: org.apache.karaf.profile/org.apache.karaf.profile.core

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());

相关文章