当前位置: 首页>>代码示例>>Java>>正文


Java Properties.setProperty方法代码示例

本文整理汇总了Java中java.util.Properties.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Properties.setProperty方法的具体用法?Java Properties.setProperty怎么用?Java Properties.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Properties的用法示例。


在下文中一共展示了Properties.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Service

import java.util.Properties; //导入方法依赖的package包/类
public Service() throws NamingException {
    System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info");
    System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
    System.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "yyyy-MM-dd HH:mm:ss Z");
    System.setProperty("org.slf4j.simpleLogger.showThreadName", "false");

    try {
        Properties properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
        properties.setProperty("connectionfactory.connection", String.format(
                "amqp://%s:%d?amqp.idleTimeout=30000&jms.forceAsyncSend=true",
                "localhost",
                5672));
        properties.setProperty("queue.time", "/time");
        properties.setProperty("queue.date", "/date");
        this.context = new InitialContext(properties);
    } catch (NamingException ex) {
        LOGGER.error("Unable to proceed with broadcast receiver", ex);
        throw ex;
    }
}
 
开发者ID:scholzj,项目名称:dbg-amqp-dispatch-workshop,代码行数:22,代码来源:Service.java

示例2: testGetShortProperty

import java.util.Properties; //导入方法依赖的package包/类
@Test
public void testGetShortProperty() throws Exception {
  String someStringKey = "someStringKey";
  String someStringValue = "someStringValue";

  String someKey = "someKey";
  Short someValue = 2;

  Short someDefaultValue = -1;

  //set up config repo
  someProperties = new Properties();
  someProperties.setProperty(someStringKey, someStringValue);
  someProperties.setProperty(someKey, String.valueOf(someValue));
  when(configRepository.getConfig()).thenReturn(someProperties);

  DefaultConfig defaultConfig =
      new DefaultConfig(someNamespace, configRepository);

  assertEquals(someValue, defaultConfig.getShortProperty(someKey, someDefaultValue));
  assertEquals(someDefaultValue, defaultConfig.getShortProperty(someStringKey, someDefaultValue));
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:23,代码来源:DefaultConfigTest.java

示例3: compile

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Compile the XSD, if needed, to generate JAX-B binding library jars
 */
public boolean compile() throws IOException {
    if (getJaxbJarFile() != null) {
        return true;
    }
    
    FileObject jaxbBaseDir = getOrCreateJaxbFolder();
    FileObject userBuildFile = SaasServicesModel.getWebServiceHome()
            .getParent().getParent().getFileObject("build.properties");
    File jaxbBasePath = FileUtil.normalizeFile(FileUtil.toFile(jaxbBaseDir));
    File xsdFilePath = FileUtil.normalizeFile(FileUtil.toFile(xsdFile));
    File userBuildPath = FileUtil.normalizeFile(FileUtil.toFile(userBuildFile));
    
    Properties p = new Properties();
    p.setProperty(PROP_XSD_FILE, xsdFilePath.getPath());
    p.setProperty(PROP_PACKAGE_NAME, packageName);
    p.setProperty(PROP_JAXB_BASE, jaxbBasePath.getPath());
    p.setProperty(PROP_JAXB_JAR, jaxbJarPath);
    p.setProperty(PROP_JAXB_SRC_JAR, jaxbSourceJarPath);
    p.setProperty(PROP_USER_BUILD_PROPERTIES, userBuildPath.getPath());
    
    return createJaxBJar(p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:Xsd2Java.java

示例4: init

import java.util.Properties; //导入方法依赖的package包/类
@Override
public void init(Properties p) throws WorkloadException {
  disksize = Long.parseLong(p.getProperty(DISK_SIZE_PROPERTY, String.valueOf(DISK_SIZE_PROPERTY_DEFAULT)));
  storageages = Long.parseLong(p.getProperty(STORAGE_AGE_PROPERTY, String.valueOf(STORAGE_AGE_PROPERTY_DEFAULT)));
  occupancy = Double.parseDouble(p.getProperty(OCCUPANCY_PROPERTY, String.valueOf(OCCUPANCY_PROPERTY_DEFAULT)));

  if (p.getProperty(Client.RECORD_COUNT_PROPERTY) != null ||
      p.getProperty(Client.INSERT_COUNT_PROPERTY) != null ||
      p.getProperty(Client.OPERATION_COUNT_PROPERTY) != null) {
    System.err.println("Warning: record, insert or operation count was set prior to initting " +
        "ConstantOccupancyWorkload.  Overriding old values.");
  }
  NumberGenerator g = CoreWorkload.getFieldLengthGenerator(p);
  double fieldsize = g.mean();
  int fieldcount = Integer.parseInt(p.getProperty(FIELD_COUNT_PROPERTY, FIELD_COUNT_PROPERTY_DEFAULT));

  objectCount = (long) (occupancy * (disksize / (fieldsize * fieldcount)));
  if (objectCount == 0) {
    throw new IllegalStateException("Object count was zero.  Perhaps disksize is too low?");
  }
  p.setProperty(Client.RECORD_COUNT_PROPERTY, String.valueOf(objectCount));
  p.setProperty(Client.OPERATION_COUNT_PROPERTY, String.valueOf(storageages * objectCount));
  p.setProperty(Client.INSERT_COUNT_PROPERTY, String.valueOf(objectCount));

  super.init(p);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:ConstantOccupancyWorkload.java

示例5: createRegion

import java.util.Properties; //导入方法依赖的package包/类
private Region createRegion(int ttl) {
  Properties props = new Properties();
  props.setProperty(MCAST_PORT, "0");
  props.setProperty(LOG_LEVEL, "info");
  // props.setProperty("log-file", "junit.log");
  cache = new CacheFactory(props).create();
  cache.createDiskStoreFactory().setMaxOplogSize(1).setDiskDirs(new File[] {dir}).create("disk");


  RegionFactory<Object, Object> rf = cache.createRegionFactory()
      .setDataPolicy(DataPolicy.PERSISTENT_PARTITION).setDiskStoreName("disk");
  rf.setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(1).create());
  if (ttl > 0) {
    rf.setEntryTimeToLive(new ExpirationAttributes(ttl, ExpirationAction.DESTROY));
  }
  Region region = rf.create("region");
  return region;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:PersistentPartitionedRegionJUnitTest.java

示例6: testBug27655

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Tests fix for BUG#27655 - getTransactionIsolation() uses
 * "SHOW VARIABLES LIKE" which is very inefficient on MySQL-5.0+
 * 
 * @throws Exception
 */
public void testBug27655() throws Exception {
    Properties props = new Properties();
    props.setProperty("profileSQL", "true");
    props.setProperty("logger", "StandardLogger");
    StandardLogger.startLoggingToBuffer();

    Connection loggedConn = null;

    try {
        loggedConn = getConnectionWithProps(props);
        loggedConn.getTransactionIsolation();

        if (versionMeetsMinimum(8, 0, 3)) {
            assertEquals(-1, StandardLogger.getBuffer().toString().indexOf("SHOW VARIABLES LIKE 'transaction_isolation'"));
        } else if (versionMeetsMinimum(4, 0, 3)) {
            assertEquals(-1, StandardLogger.getBuffer().toString().indexOf("SHOW VARIABLES LIKE 'tx_isolation'"));
        }
    } finally {
        StandardLogger.dropBuffer();
        if (loggedConn != null) {
            loggedConn.close();
        }
    }
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:31,代码来源:ConnectionRegressionTest.java

示例7: validateRegionMap

import java.util.Properties; //导入方法依赖的package包/类
@Test
public void validateRegionMap() {
  Properties properties = new Properties();
  properties.setProperty("mcast-port", "0");
  CacheFactory cacheFactory = new CacheFactory(properties);
  Cache cache = cacheFactory.create();
  Region<Object, Object> replicatedRegion =
      cache.createRegionFactory(RegionShortcut.REPLICATE).create("ReplicatedRegion");
  assertTrue(((LocalRegion) replicatedRegion).entries instanceof VMRegionMap);
  replicatedRegion.destroyRegion();

  Region<Object, Object> partitionRegion =
      cache.createRegionFactory(RegionShortcut.PARTITION).create("PartitionRegion");

  assertTrue(((LocalRegion) partitionRegion).entries instanceof VMRegionMap);
  partitionRegion.destroyRegion();

  Region<Object, Object> partitionRegionLRU =
      cache.createRegionFactory(RegionShortcut.PARTITION_OVERFLOW).create("PartitionRegionLRU");

  assertTrue(((LocalRegion) partitionRegionLRU).entries instanceof VMLRURegionMap);
  partitionRegionLRU.destroyRegion();
  cache.close();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:25,代码来源:RegionMapFactoryImplTest.java

示例8: getClientInfo

import java.util.Properties; //导入方法依赖的package包/类
public synchronized Properties getClientInfo(java.sql.Connection conn) throws SQLException {
    ResultSet rs = null;

    Properties props = new Properties();

    try {
        this.getClientInfoBulkSp.execute();

        rs = this.getClientInfoBulkSp.getResultSet();

        while (rs.next()) {
            props.setProperty(rs.getString(1), rs.getString(2));
        }
    } finally {
        if (rs != null) {
            rs.close();
        }
    }

    return props;
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:22,代码来源:JDBC4ClientInfoProviderSP.java

示例9: loadProperties

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Loads properties from a properties file or resource bundle.
 * First the <code>ResourceBundle</code> by the name "apfloat" is
 * located, then all properties found from that resource bundle
 * are put to a <code>Properties</code> object.<p>
 *
 * The resource bundle is found basically using the following logic
 * (note that this is standard Java <code>ResourceBundle</code>
 * functionality), in this order whichever is found first:
 *
 * <ol>
 *   <li>From the class named <code>apfloat</code> (that should be a subclass of <code>ResourceBundle</code>), in the current class path</li>
 *   <li>From the file "apfloat.properties" in the current class path</li>
 * </ol>
 *
 * @return Properties found in the "apfloat" resource bundle, or an empty <code>Properties</code> object, if the resource bundle is not found.
 */

public static Properties loadProperties()
    throws ApfloatRuntimeException
{
    Properties properties = new Properties();

    try
    {
        ResourceBundle resourceBundle = ResourceBundle.getBundle("apfloat");

        Enumeration<String> keys = resourceBundle.getKeys();
        while (keys.hasMoreElements())
        {
            String key = keys.nextElement();
            properties.setProperty(key, resourceBundle.getString(key));
        }
    }
    catch (MissingResourceException mre)
    {
        // Ignore - properties file or class is not found or can't be read
    }

    return properties;
}
 
开发者ID:mtommila,项目名称:apfloat,代码行数:42,代码来源:ApfloatContext.java

示例10: object2Properties

import java.util.Properties; //导入方法依赖的package包/类
public static Properties object2Properties(final Object object) {
    Properties properties = new Properties();

    Field[] fields = object.getClass().getDeclaredFields();
    for (Field field : fields) {
        if (!Modifier.isStatic(field.getModifiers())) {
            String name = field.getName();
            if (!name.startsWith("this")) {
                Object value = null;
                try {
                    field.setAccessible(true);
                    value = field.get(object);
                } catch (IllegalArgumentException | IllegalAccessException e) {
                    e.printStackTrace();
                }

                if (value != null) {
                    properties.setProperty(name, value.toString());
                }
            }
        }
    }

    return properties;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:26,代码来源:MixAll.java

示例11: testBug26173

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Tests fix for BUG#26173 - fetching rows via cursor retrieves corrupted
 * data.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug26173() throws Exception {
    if (!versionMeetsMinimum(5, 0)) {
        return;
    }

    createTable("testBug26173", "(fkey int, fdate date, fprice decimal(15, 2), fdiscount decimal(5,3))", "InnoDB");
    this.stmt.executeUpdate("insert into testBug26173 values (1, '2007-02-23', 99.9, 0.02)");

    Connection fetchConn = null;
    Statement stmtRead = null;

    Properties props = new Properties();
    props.setProperty("useServerPrepStmts", "true");
    props.setProperty("useCursorFetch", "true");

    try {

        fetchConn = getConnectionWithProps(props);
        stmtRead = fetchConn.createStatement();
        stmtRead.setFetchSize(1000);

        this.rs = stmtRead.executeQuery("select extract(year from fdate) as fyear, fprice * (1 - fdiscount) as fvalue from testBug26173");

        assertTrue(this.rs.next());
        assertEquals(2007, this.rs.getInt(1));
        assertEquals("97.90200", this.rs.getString(2));
    } finally {
        if (stmtRead != null) {
            stmtRead.close();
        }

        if (fetchConn != null) {
            fetchConn.close();
        }
    }
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:44,代码来源:ResultSetRegressionTest.java

示例12: configureSparkContext

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Add specific configuration for Spark SQL execution.
 */
public void configureSparkContext(){
	Properties properties = new Properties();
	properties.setProperty("spark.sql.parquet.filterPushdown", "true");
	properties.setProperty("spark.sql.inMemoryColumnarStorage.batchSize", "20000");
	if(dfPartitions != 0){
		properties.setProperty("spark.sql.shuffle.partitions", Integer.toString(dfPartitions));
	}
	
	hiveContext.setConf(properties);
}
 
开发者ID:aschaetzle,项目名称:Sempala,代码行数:14,代码来源:Spark.java

示例13: main

import java.util.Properties; //导入方法依赖的package包/类
public static void main(String[] args){
	ArrayList<Attribute> atts = new ArrayList<Attribute>();
	
	Properties p1 = new Properties();
	p1.setProperty("range", "[0,1]");
	ProtectedProperties prop1 = new ProtectedProperties(p1);
	
	Properties p2 = new Properties();
	p2.setProperty("range", "[321,1E9]");
	ProtectedProperties prop2 = new ProtectedProperties(p2);
	
	Properties p3 = new Properties();
	p3.setProperty("range", "[1,30]");
	ProtectedProperties prop3 = new ProtectedProperties(p3);
	
	ArrayList<String> attVals = new ArrayList<String>();
	for (int i = 0; i < 5; i++)
	      attVals.add("val" + (i+1));
	
	atts.add(new Attribute("att1", prop1));
	atts.add(new Attribute("att2", prop2));
	atts.add(new Attribute("att3", prop3));
	//atts.add(new Attribute("att4", attVals));
	//Instances data = LHSInitializer.getMultiDimContinuous(atts, 10, false);
	//Instances data = LHSInitializer.getMultiDim(atts, 10, false);
	DDSSampler sampler = new DDSSampler(3);
	
	sampler.setCurrentRound(0);
	Instances data = sampler.sampleMultiDimContinuous(atts, 2, false);
	System.out.println(data);
	
	sampler.setCurrentRound(01);
	data = sampler.sampleMultiDimContinuous(atts, 2, false);
	System.out.println(data);
	
	sampler.setCurrentRound(2);
	data = sampler.sampleMultiDimContinuous(atts, 2, false);
	System.out.println(data);
}
 
开发者ID:zhuyuqing,项目名称:bestconf,代码行数:40,代码来源:DDSSampler.java

示例14: testBug72712

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Test for Bug#72712 - SET NAMES issued unnecessarily.
 * 
 * Using a statement interceptor, ensure that SET NAMES is not
 * called if the encoding requested by the client application
 * matches that of character_set_server.
 * 
 * Also test that character_set_results is not set unnecessarily.
 */
public void testBug72712() throws Exception {
    // this test is only run when character_set_server=latin1
    if (!((MySQLConnection) this.conn).getServerVariable("character_set_server").equals("latin1")) {
        return;
    }

    Properties p = new Properties();
    p.setProperty("characterEncoding", "cp1252");
    p.setProperty("characterSetResults", "cp1252");
    p.setProperty("statementInterceptors", Bug72712StatementInterceptor.class.getName());

    getConnectionWithProps(p);
    // exception will be thrown from the statement interceptor if any SET statements are issued
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:24,代码来源:ConnectionRegressionTest.java

示例15: testTruncationDisable

import java.util.Properties; //导入方法依赖的package包/类
public void testTruncationDisable() throws Exception {
    Properties props = new Properties();
    props.setProperty("jdbcCompliantTruncation", "false");
    Connection truncConn = null;

    truncConn = getConnectionWithProps(props);
    this.rs = truncConn.createStatement().executeQuery("SELECT " + Long.MAX_VALUE);
    this.rs.next();
    this.rs.getInt(1);

}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:12,代码来源:ResultSetRegressionTest.java


注:本文中的java.util.Properties.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。