下面列出了java.util.Properties#remove ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static void mapChildViewsToNamespace(String connUrl, Properties props, List<TableInfo> viewInfoList)
throws SQLException, SnapshotCreationException, IllegalArgumentException, IOException,
InterruptedException {
String tenantId = null;
String prevTenantId = null;
PhoenixConnection conn = null;
for (TableInfo viewInfo : viewInfoList) {
tenantId = viewInfo.getTenantId()!=null ? Bytes.toString(viewInfo.getTenantId()) : null;
String viewName = SchemaUtil.getTableName(viewInfo.getSchemaName(), viewInfo.getTableName());
if (!java.util.Objects.equals(prevTenantId, tenantId)) {
if (tenantId != null) {
props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
} else {
props.remove(PhoenixRuntime.TENANT_ID_ATTRIB);
}
if (conn!=null)
conn.close();
conn = DriverManager.getConnection(connUrl, props).unwrap(PhoenixConnection.class);
}
LOGGER.info(String.format("Upgrading view %s for tenantId %s..", viewName,tenantId));
UpgradeUtil.upgradeTable(conn, viewName);
prevTenantId = tenantId;
}
}
public void getSearchProperties(final Properties props) {
setSearchProperty(props, "aq", authorQuery.getValue());
setSearchProperty(props, "tq", titleQuery.getValue());
setSearchProperty(props, "dq", descriptionQuery.getValue());
setSearchProperty(props, "cd", createdDate.getValue());
setSearchProperty(props, "md", modifiedDate.getValue());
setSearchProperty(props, "mtdq", metadataQuery.getValue());
if (metadataType.isOneSelected()) {
props.setProperty("mtdt", metadataType.getSelectedKey());
} else {
props.remove("mtdt");
}
final Set<String> selectedKeys = documentTypeQuery.getSelectedKeys();
final StringBuilder sb = new StringBuilder();
for (final String selectedKey : selectedKeys) {
sb.append(selectedKey).append('|');
}
props.setProperty("dtypes", sb.toString());
}
private static void convert(final Properties properties, final Duration duration, final String key, final String oldKey) {
properties.remove(key);
// If someone is using the legacy property, use it
if (properties.contains(oldKey)) {
return;
}
properties.remove(oldKey);
if (duration == null) {
return;
}
if (duration.getUnit() == null) {
duration.setUnit(TimeUnit.MILLISECONDS);
}
final long milliseconds = TimeUnit.MILLISECONDS.convert(duration.getTime(), duration.getUnit());
properties.put(oldKey, String.valueOf(milliseconds));
}
public void testCompatiblePersistDDOnServers() throws Exception {
Properties props = new Properties();
props.setProperty(Attribute.GFXD_PERSIST_DD, "true");
startVMs(0, 1, 0, null, props);
startVMs(0, 1, 0, null, props);
props.setProperty(Attribute.GFXD_PERSIST_DD, "false");
startVMs(1, 0, 0, null, props);
props.setProperty(Attribute.GFXD_PERSIST_DD, "false");
// add expected exception
final String expectedExStr = "persist-dd should be same on all the servers";
props.put(TestUtil.EXPECTED_STARTUP_EXCEPTIONS,
new Object[] { "Failed to start database", expectedExStr });
try {
startVMs(0, 1, 0, null, props);
fail("Test should have failed ");
} catch (RMIException e) {
if (!e.getCause().getCause().getMessage().startsWith(expectedExStr)) {
fail("Got unexpected exception :", e);
}
}
props.remove(TestUtil.EXPECTED_STARTUP_EXCEPTIONS);
props.setProperty(Attribute.GFXD_PERSIST_DD, "true");
startVMs(0, 1, 0, null, props);
}
public static boolean writeConfigValue(File file, String key, String value) {
try {
Properties conf = new Properties();
try ( BufferedInputStream in = new BufferedInputStream(new FileInputStream(file))) {
conf.load(in);
}
try ( BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file))) {
if (value == null) {
conf.remove(key);
} else {
conf.setProperty(key, value);
}
conf.store(out, "Update " + key);
}
return true;
} catch (Exception e) {
logger.error(e.toString());
return false;
}
}
public void setDefault(String jarName){
Properties properties = getContent();
if(jarName == null){
properties.remove(DEFAULT);
}else{
properties.put(DEFAULT, jarName);
}
save(properties);
}
public static void deleteUserLoginInfo() {
Properties p = AuthenticActivator.getProperties();
p.remove(Messages.WorkbenchWindowControlContribution1_12);
p.remove(Messages.WorkbenchWindowControlContribution1_13);
p.remove(Messages.WorkbenchWindowControlContribution1_14);
AuthenticActivator.store(p);
}
@Test
public void testGetTopicsFromConfigStore()
throws Exception {
KafkaTopic topic1 = new KafkaTopic("Topic1", Lists.newArrayList());
KafkaTopic topic2 = new KafkaTopic("Topic2", Lists.newArrayList());
KafkaTopic topic3 = new KafkaTopic("Topic3", Lists.newArrayList());
Mockito.when(mockClient.getFilteredTopics(anyList(), anyList()))
.thenReturn(ImmutableList.of(topic1, topic2, topic3));
Properties properties = new Properties();
// Empty properties returns everything: topic1, 2 and 3.
List<KafkaTopic> result = ConfigStoreUtils.getTopicsFromConfigStore(properties, configStoreUri, mockClient);
Assert.assertEquals(result.size(), 3);
properties.setProperty(GOBBLIN_CONFIG_TAGS_WHITELIST, "/tags/whitelist");
properties.setProperty(GOBBLIN_CONFIG_FILTER, "/data/tracking");
properties.setProperty(GOBBLIN_CONFIG_COMMONPATH, "/data/tracking");
// Whitelist only two topics. Should only returned whitelisted topics.
result = ConfigStoreUtils.getTopicsFromConfigStore(properties, configStoreUri, mockClient);
Assert.assertEquals(result.size(), 2);
List<String> resultInString = result.stream().map(KafkaTopic::getName).collect(Collectors.toList());
Assert.assertTrue(resultInString.contains("Topic1"));
Assert.assertTrue(resultInString.contains("Topic2"));
// Blacklist two topics. Should only return non-blacklisted topics.
properties.remove(GOBBLIN_CONFIG_TAGS_WHITELIST);
properties.setProperty(GOBBLIN_CONFIG_TAGS_BLACKLIST, "/tags/blacklist");
result = ConfigStoreUtils.getTopicsFromConfigStore(properties, configStoreUri, mockClient);
Assert.assertEquals(result.size(), 1);
Assert.assertEquals(result.get(0).getName(), "Topic3");
}
public void startOrcaOnly() throws Exception {
startLogging();
this.config = new ConfigService(new File(getConfigFolder(home), "conf.properties"));
// disable hbase service by removing hbase conf
Properties props = this.config.getProperties();
props.remove("hbase_conf");
startDatabase();
}
/**
* Store configuration from control hub in persistent manner inside data directory. This configuration will be
* loaded on data collector start and will override any configuration from sdc.properties.
*
* This method call is able to remove existing properties if the value is "null". Please note that the removal will
* only happen from the 'override' file. This method does not have the capability to remove configuration directly
* from sdc.properties.
*
* @param runtimeInfo RuntimeInfo instance
* @param newConfigs New set of config properties
* @throws IOException
*/
public static void storeControlHubConfigs(
RuntimeInfo runtimeInfo,
Map<String, String> newConfigs
) throws IOException {
File configFile = new File(runtimeInfo.getDataDir(), SCH_CONF_OVERRIDE);
Properties properties = new Properties();
// Load existing properties from disk if they exists
if(configFile.exists()) {
try (FileReader reader = new FileReader(configFile)) {
properties.load(reader);
}
}
// Propagate updated configuration
for(Map.Entry<String, String> entry : newConfigs.entrySet()) {
if(entry.getValue() == null) {
properties.remove(entry.getKey());
} else {
properties.setProperty(entry.getKey(), entry.getValue());
}
}
// Store the new updated configuration back to disk
try(FileWriter writer = new FileWriter(configFile)) {
properties.store(writer, null);
}
}
@Override // GemStoneAddition
public boolean setProperties(Properties props) {
String str;
long[] tmp;
super.setProperties(props);
str=props.getProperty("print_local_addr");
if(str != null) {
print_local_addr=Boolean.valueOf(str).booleanValue();
props.remove("print_local_addr");
}
str=props.getProperty("timeout");
if(str != null) {
tmp=Util.parseCommaDelimitedLongs(str);
props.remove("timeout");
if(tmp != null && tmp.length > 0)
timeout=tmp;
}
str=props.getProperty("max_xmits");
if(str != null) {
// max_xmits=Integer.parseInt(str); GemStoneAddition
props.remove("max_xmits");
}
if(props.size() > 0) {
log.error(ExternalStrings.SMACK_SMACKSETPROPERTIES_THE_FOLLOWING_PROPERTIES_ARE_NOT_RECOGNIZED__0, props);
return false;
}
return true;
}
protected void removeHostRelatedProps(Properties props) {
props.remove(NonRegisteringDriver.HOST_PROPERTY_KEY);
props.remove(NonRegisteringDriver.PORT_PROPERTY_KEY);
int numHosts = Integer.parseInt(props.getProperty(NonRegisteringDriver.NUM_HOSTS_PROPERTY_KEY));
for (int i = 1; i <= numHosts; i++) {
props.remove(NonRegisteringDriver.HOST_PROPERTY_KEY + "." + i);
props.remove(NonRegisteringDriver.PORT_PROPERTY_KEY + "." + i);
}
props.remove(NonRegisteringDriver.NUM_HOSTS_PROPERTY_KEY);
}
@Override // GemStoneAddition
public boolean setProperties(Properties props) {
String str;
super.setProperties(props);
// Milliseconds to wait for application to provide requested state, events are
// STATE_TRANSFER up and STATE_TRANSFER_OK down
str=props.getProperty("timeout_get_appl_state");
if(str != null) {
timeout_get_appl_state=Long.parseLong(str);
props.remove("timeout_get_appl_state");
}
// Milliseconds to wait for 1 or all members to return its/their state. 0 means wait
// forever. States are retrieved using GroupRequest/RequestCorrelator
str=props.getProperty("timeout_return_state");
if(str != null) {
timeout_return_state=Long.parseLong(str);
props.remove("timeout_return_state");
}
if(props.size() > 0) {
log.error(ExternalStrings.STATE_TRANSFER_STATE_TRANSFERSETPROPERTIES_THE_FOLLOWING_PROPERTIES_ARE_NOT_RECOGNIZED__0, props);
return false;
}
return true;
}
public void testset_noaccess() throws Exception {
// start a locator and some severs with auth enabled
final int locPort = AvailablePort
.getRandomAvailablePort(AvailablePort.SOCKET);
final Properties props = new Properties();
props.setProperty("start-locator", "localhost[" + locPort + ']');
props.setProperty("auth-provider", "BUILTIN");
props.setProperty("sqlfire.user.sd", "pwd"); // system user
props.setProperty("user", "sd");
props.setProperty("password", "pwd");
props.setProperty("gemfirexd.sql-authorization", "false");
props.setProperty("gemfirexd.authz-default-connection-mode", "NOACCESS");
props.setProperty("authz-full-access-users", "sd");
startVMs(0, 1, 0, null, props);
props.remove("start-locator");
props.setProperty("locators", "localhost[" + locPort + ']');
startVMs(1, 3, 0, null, props);
// connect as system user 'sd'
final Properties props2 = new Properties();
props2.setProperty("user", "sd");
props2.setProperty("password", "pwd");
Connection conn1 = TestUtil.getConnection(props2);
Statement systemUser_stmt = conn1.createStatement();
// create a new user
systemUser_stmt.execute("call sys.create_user('user1', 'a')");
systemUser_stmt.execute("create table s1(col1 int)");
// connect as user 'user1'
props2.setProperty("user", "user1");
props2.setProperty("password", "a");
try {
Connection conn2 = TestUtil.getConnection(props2);
} catch (SQLException se) {
if (!se.getSQLState().equals("08004")) {
throw se;
}
}
}
/**
* Common part of (Sub-)Equipment update method. Mainly deals
* with rollback of other cache changes in case of failure.
*
* @param abstractEquipmentId id of (sub)equipment
* @param elementProperties properties with update details
* @return changes to be sent to the DAQ layer
* @throws IllegalAccessException if thrown when updating fields
*/
protected List<ProcessChange> commonUpdate(Long abstractEquipmentId, Properties elementProperties) throws IllegalAccessException {
LOGGER.debug("Updating (sub-)equipment {}", abstractEquipmentId);
// TODO or not todo: warning: can still update commfault, alive and state
// tag id to non-existent tags (id is NOT checked and exceptions will be
// thrown!)
// do not allow id changes! (they would not be applied in any case)
if (elementProperties.containsKey("id")) {
LOGGER.warn("Attempting to change the equipment/subequipment id - this is not currently supported!");
elementProperties.remove("id");
}
boolean aliveConfigure = false;
if (elementProperties.containsKey("aliveInterval") || elementProperties.containsKey("aliveTagId")) {
aliveConfigure = true;
}
boolean commFaultConfigure = false;
if (elementProperties.containsKey("commFaultTagId")) {
commFaultConfigure = true;
}
abstractEquipmentCache.acquireWriteLockOnKey(abstractEquipmentId);
try {
T abstractEquipmentCopy = abstractEquipmentCache.getCopy(abstractEquipmentId);
try {
Long oldAliveId = abstractEquipmentCopy.getAliveTagId();
Long oldCommFaultId = abstractEquipmentCopy.getCommFaultTagId();
List<ProcessChange> processChanges = abstractEquipmentConfigTransacted.doUpdateAbstractEquipment(abstractEquipmentCopy, elementProperties);
// commit local changes back to the cache
abstractEquipmentCache.putQuiet(abstractEquipmentCopy);
abstractEquipmentCache.releaseWriteLockOnKey(abstractEquipmentId);
if (aliveConfigure) {
if (oldAliveId != null)
commonEquipmentFacade.removeAliveDirectly(oldAliveId);
if (abstractEquipmentCopy.getAliveTagId() != null)
commonEquipmentFacade.loadAndStartAliveTag(abstractEquipmentCopy.getId());
}
if (commFaultConfigure && abstractEquipmentCopy.getCommFaultTagId() != null) {
if (oldCommFaultId != null)
commFaultTagCache.remove(oldCommFaultId);
if (abstractEquipmentCopy.getCommFaultTagId() != null)
commFaultTagCache.loadFromDb(abstractEquipmentCopy.getCommFaultTagId());
}
return processChanges;
} catch (RuntimeException ex) {
LOGGER.error("Exception caught while updating (sub-)equipment - rolling back changes", ex);
//reload all potentially updated cache elements now DB changes are rolled back
if (abstractEquipmentCache.isWriteLockedByCurrentThread(abstractEquipmentId)) {
abstractEquipmentCache.releaseWriteLockOnKey(abstractEquipmentId);
}
commFaultTagCache.remove(abstractEquipmentCopy.getCommFaultTagId());
aliveTimerCache.remove(abstractEquipmentCopy.getAliveTagId());
abstractEquipmentCache.remove(abstractEquipmentId);
T oldAbstractEquipment = abstractEquipmentCache.get(abstractEquipmentId);
commFaultTagCache.loadFromDb(oldAbstractEquipment.getCommFaultTagId());
commonEquipmentFacade.loadAndStartAliveTag(abstractEquipmentId); //reloads alive from DB
throw ex;
}
} finally {
if (abstractEquipmentCache.isWriteLockedByCurrentThread(abstractEquipmentId))
abstractEquipmentCache.releaseWriteLockOnKey(abstractEquipmentId);
}
}
/**
* test for all basic statement stats gathered during dml execution.
* @see com.pivotal.gemfirexd.internal.impl.sql.StatementStats
* @throws Exception on failure.
*/
public void testStatementStats() throws Exception {
try {
Properties serverInfo = new Properties();
serverInfo.setProperty("gemfire.enable-time-statistics", "true");
serverInfo.setProperty("statistic-sample-rate", "100");
serverInfo.setProperty("statistic-sampling-enabled", "true");
startServerVMs(1, 0, null, serverInfo);
Properties info = new Properties();
info.setProperty("host-data", "false");
info.setProperty("gemfire.enable-time-statistics", "true");
// start a client, register the driver.
startClientVMs(1, 0, null, info);
// enable StatementStats for all connections in this VM
System.setProperty(GfxdConstants.GFXD_ENABLE_STATS, "true");
// check that stats are enabled with System property set
Connection conn = TestUtil.getConnection(info);
runAndCheckStats(conn, true, 1);
conn.close();
// now disable stats for a connection and try again
System.clearProperty(GfxdConstants.GFXD_ENABLE_STATS);
info.setProperty(Attribute.ENABLE_STATS, "false");
conn = TestUtil.getConnection(info);
runAndCheckStats(conn, false, 1);
conn.close();
// now disable global flag, enable stats for this particular connection
// and try again
System.clearProperty(GfxdConstants.GFXD_ENABLE_STATS);
info.setProperty(Attribute.ENABLE_STATS, "true");
conn = TestUtil.getConnection(info);
runAndCheckStats(conn, true, 2);
conn.close();
// now enable global flag again, enable stats for one connection, disable
// for another and ensure sys property overrides.
System.setProperty(GfxdConstants.GFXD_ENABLE_STATS, "false");
conn = TestUtil.getConnection(info);
runAndCheckStats(conn, false, 2);
conn.close();
info.setProperty(Attribute.ENABLE_STATS, "true");
Connection conn2 = TestUtil.getConnection(info);
runAndCheckStats(conn2, false, 2);
conn2.close();
// now clear system property and check default behaviour is no stats
System.clearProperty(GfxdConstants.GFXD_ENABLE_STATS);
info.remove(Attribute.ENABLE_STATS);
conn = TestUtil.getConnection(info);
// no stats by default
runAndCheckStats(conn, false, 2);
conn.close();
// Now specially run with Time Stats
System.clearProperty(GfxdConstants.GFXD_ENABLE_STATS);
Properties info2 = new Properties();
info2.setProperty(Attribute.ENABLE_STATS, "true");
info2.setProperty(Attribute.ENABLE_TIMESTATS, "true");
info2.setProperty("gemfire.enable-time-statistics", "true");
info2.setProperty("statistic-sample-rate", "100");
info2.setProperty("statistic-sampling-enabled", "true");
conn = TestUtil.getConnection(info2);
runAndCheckUpdateSelectStats(conn, true, true);
info2.remove(Attribute.ENABLE_TIMESTATS);
info2.remove(Attribute.ENABLE_STATS);
conn.close();
stopVMNums(1, -1);
} finally {
GemFireXDQueryObserverHolder.clearInstance();
System.clearProperty(GfxdConstants.GFXD_ENABLE_STATS);
}
}
public DataSourceWrapper createDataSource(String name, Properties conf,
PasswordResolver passwordResolver) throws PasswordResolverException {
Args.notNull(conf, "conf");
DatabaseType databaseType;
String className = conf.getProperty("dataSourceClassName");
if (className != null) {
databaseType = DatabaseType.forDataSourceClass(className);
} else {
className = conf.getProperty("driverClassName");
if (className != null) {
databaseType = DatabaseType.forDriver(className);
} else {
String jdbcUrl = conf.getProperty("jdbcUrl");
if (jdbcUrl == null) {
throw new IllegalArgumentException("none of the properties dataSourceClassName"
+ ", driverClassName and jdbcUrl is configured");
}
databaseType = DatabaseType.forJdbcUrl(jdbcUrl);
}
}
String password = conf.getProperty("password");
if (password != null) {
if (passwordResolver != null) {
password = new String(passwordResolver.resolvePassword(password));
}
conf.setProperty("password", password);
}
password = conf.getProperty("dataSource.password");
if (password != null) {
if (passwordResolver != null) {
password = new String(passwordResolver.resolvePassword(password));
}
conf.setProperty("dataSource.password", password);
}
/*
* Expand the file path like
* dataSource.url = jdbc:h2:~/xipki/db/h2/ocspcrl
* dataSource.url = jdbc:hsqldb:file:~/xipki/db/hsqldb/ocspcache;sql.syntax_pgs=true
*/
String dataSourceUrl = conf.getProperty("dataSource.url");
if (dataSourceUrl != null) {
String newUrl = null;
final String h2_prefix = "jdbc:h2:";
final String hsqldb_prefix = "jdbc:hsqldb:file:";
if (dataSourceUrl.startsWith(h2_prefix + "~")) {
newUrl = h2_prefix + IoUtil.expandFilepath(
dataSourceUrl.substring(h2_prefix.length()));
} else if (dataSourceUrl.startsWith(hsqldb_prefix + "~")) {
newUrl = hsqldb_prefix + IoUtil.expandFilepath(
dataSourceUrl.substring(hsqldb_prefix.length()));
}
if (newUrl != null) {
conf.setProperty("dataSource.url", newUrl);
}
}
Set<Object> keySet = new HashSet<>(conf.keySet());
for (Object key : keySet) {
if (((String) key).startsWith("liquibase")) {
conf.remove(key);
}
}
return DataSourceWrapper.createDataSource(name, conf, databaseType);
}
/**
* 执行安装
*
* @throws Exception
*/
public void install() throws Exception {
this.installDatabase();
this.installAdmin();
// Save install state (file)
File dest = SysConfiguration.getFileOfData(INSTALL_FILE);
Properties installProps = buildConnectionProps(null);
// Redis
JSONObject cacheProps = this.installProps.getJSONObject("cacheProps");
if (cacheProps != null && !cacheProps.isEmpty()) {
installProps.put(ConfigurableItem.CacheHost.name(), cacheProps.getString(ConfigurableItem.CacheHost.name()));
installProps.put(ConfigurableItem.CachePort.name(), cacheProps.getString(ConfigurableItem.CachePort.name()));
installProps.put(ConfigurableItem.CachePassword.name(), cacheProps.getString(ConfigurableItem.CachePassword.name()));
}
// 加密
String dbPasswd = (String) installProps.remove("db.passwd");
installProps.put("db.passwd.aes",
StringUtils.isBlank(dbPasswd) ? StringUtils.EMPTY : AES.encrypt(dbPasswd));
String cachePasswd = (String) installProps.remove(ConfigurableItem.CachePassword.name());
installProps.put(ConfigurableItem.CachePassword.name() + ".aes",
StringUtils.isBlank(cachePasswd) ? StringUtils.EMPTY : AES.encrypt(cachePasswd));
try {
FileUtils.deleteQuietly(dest);
try (OutputStream os = new FileOutputStream(dest)) {
installProps.store(os, "INSTALL FILE FOR REBUILD. DON'T DELETE OR MODIFY IT!!!");
LOG.warn("Stored install file : " + dest);
}
} catch (IOException e) {
throw new SetupException(e);
}
// initialize
try {
new ServerListener().contextInitialized(null);
} catch (Exception ex) {
// If error
FileUtils.deleteQuietly(dest);
throw ex;
}
// Gen SN
License.SN();
// Clean cached
if (Application.getCommonCache().isUseRedis()) {
try (Jedis jedis = Application.getCommonCache().getJedisPool().getResource()) {
jedis.flushAll();
}
} else {
Application.getCommonCache().getEhcacheCache().clear();
}
}
/**
* Creates an Annotation object based on a list of properties.
*
* @param attributes
* @return an Annotation
*/
public static Annotation getAnnotation(Properties attributes) {
float llx = 0, lly = 0, urx = 0, ury = 0;
String value;
value = attributes.getProperty(ElementTags.LLX);
if (value != null) {
llx = Float.parseFloat(value + "f");
}
value = attributes.getProperty(ElementTags.LLY);
if (value != null) {
lly = Float.parseFloat(value + "f");
}
value = attributes.getProperty(ElementTags.URX);
if (value != null) {
urx = Float.parseFloat(value + "f");
}
value = attributes.getProperty(ElementTags.URY);
if (value != null) {
ury = Float.parseFloat(value + "f");
}
String title = attributes.getProperty(ElementTags.TITLE);
String text = attributes.getProperty(ElementTags.CONTENT);
if (title != null || text != null) {
return new Annotation(title, text, llx, lly, urx, ury);
}
value = attributes.getProperty(ElementTags.URL);
if (value != null) {
return new Annotation(llx, lly, urx, ury, value);
}
value = attributes.getProperty(ElementTags.NAMED);
if (value != null) {
return new Annotation(llx, lly, urx, ury, Integer.parseInt(value));
}
String file = attributes.getProperty(ElementTags.FILE);
String destination = attributes.getProperty(ElementTags.DESTINATION);
String page = (String) attributes.remove(ElementTags.PAGE);
if (file != null) {
if (destination != null) {
return new Annotation(llx, lly, urx, ury, file, destination);
}
if (page != null) {
return new Annotation(llx, lly, urx, ury, file, Integer.parseInt(page));
}
}
return new Annotation("", "", llx, lly, urx, ury);
}
public static void saveAndRemoveProperties(Properties props) {
if (booted)
throw new IllegalStateException("System initialization has completed");
savedProps.putAll(props);
// Set the maximum amount of direct memory. This value is controlled
// by the vm option -XX:MaxDirectMemorySize=<size>.
// The maximum amount of allocatable direct buffer memory (in bytes)
// from the system property sun.nio.MaxDirectMemorySize set by the VM.
// The system property will be removed.
String s = (String)props.remove("sun.nio.MaxDirectMemorySize");
if (s != null) {
if (s.equals("-1")) {
// -XX:MaxDirectMemorySize not given, take default
directMemory = Runtime.getRuntime().maxMemory();
} else {
long l = Long.parseLong(s);
if (l > -1)
directMemory = l;
}
}
// Check if direct buffers should be page aligned
s = (String)props.remove("sun.nio.PageAlignDirectMemory");
if ("true".equals(s))
pageAlignDirectMemory = true;
// Set a boolean to determine whether ClassLoader.loadClass accepts
// array syntax. This value is controlled by the system property
// "sun.lang.ClassLoader.allowArraySyntax".
s = props.getProperty("sun.lang.ClassLoader.allowArraySyntax");
allowArraySyntax = (s == null
? defaultAllowArraySyntax
: Boolean.parseBoolean(s));
// Remove other private system properties
// used by java.lang.Integer.IntegerCache
props.remove("java.lang.Integer.IntegerCache.high");
// used by java.util.zip.ZipFile
props.remove("sun.zip.disableMemoryMapping");
// used by sun.launcher.LauncherHelper
props.remove("sun.java.launcher.diag");
// used by sun.misc.URLClassPath
props.remove("sun.cds.enableSharedLookupCache");
}