public T withName(String name) { // only if name is not defined yet if (!properties.containsKey(NAME)) { this.name = name; properties.putIfAbsent(NAME, name); } return (T) this; }
/** * be able to start JMX manager and admin rest on default ports */ public T withJMXManager(boolean useProductDefaultPorts) { if (!useProductDefaultPorts) { // do no override these properties if already exists properties.putIfAbsent(JMX_MANAGER_PORT, portSupplier.getAvailablePort() + ""); this.jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT)); } else { // the real port numbers will be set after we started the server/locator. this.jmxPort = 0; } properties.putIfAbsent(JMX_MANAGER, "true"); properties.putIfAbsent(JMX_MANAGER_START, "true"); return (T) this; }
@Override public synchronized Object putIfAbsent(Object key, Object value) { if (interned != null) copyFromInternedToThis(); return super.putIfAbsent(key, value); }
private LdapContext buildLdapContext() throws NamingException { config.putIfAbsent(Context.INITIAL_CONTEXT_FACTORY, DEFAULT_INITIAL_CONTEXT_FACTORY); config.putIfAbsent(Context.SECURITY_AUTHENTICATION, DEFAULT_SECURITY_AUTHENTICATION); String protocol = config.getProperty(Context.SECURITY_PROTOCOL); config.putIfAbsent(Context.PROVIDER_URL, createDefaultProviderUrl(protocol)); if (log.isDebugEnabled()) { log.debug("Using following InitialLdapContext properties:"); log.debug("Initial Context Factory: {}", config.getProperty(Context.INITIAL_CONTEXT_FACTORY)); log.debug("Authentication Type: {}", config.getProperty(Context.SECURITY_AUTHENTICATION)); log.debug("Protocol: {}", config.getProperty(Context.SECURITY_PROTOCOL)); log.debug("Provider URL: {}", config.getProperty(Context.PROVIDER_URL)); log.debug("User DN: {}", config.getProperty(Context.SECURITY_PRINCIPAL)); log.debug("Password: {}", config.getProperty(Context.SECURITY_CREDENTIALS)); } return new InitialLdapContext(config, null); }
@Override public void before() { normalizeProperties(); if (httpPort < 0) { // at this point, httpPort is not being configured by api, we assume they do not // want to start the http service. // use putIfAbsent if it was configured using withProperty properties.putIfAbsent(HTTP_SERVICE_PORT, "0"); } firstLevelChildrenFile = Arrays.asList(getWorkingDir().listFiles()); }
protected void normalizeProperties() { // if name is set via property, not with API if (name == null) { if (properties.containsKey(NAME)) { name = properties.getProperty(NAME); } else { if (this instanceof ServerStarterRule) { name = "server"; } else { name = "locator"; } } withName(name); } // if jmxPort is set via property, not with API if (jmxPort < 0 && properties.containsKey(JMX_MANAGER_PORT)) { // this will make sure we have all the missing properties, but it won't override // the existing properties withJMXManager(false); } // if caller wants the logs being put into a file instead of in console output // do it here since only here, we can guarantee the name is present if (logFile) { properties.putIfAbsent(LOG_FILE, new File(name + ".log").getAbsolutePath()); } }
indexConfiguration.putIfAbsent( FulltextIndexSettings.INDEX_CONFIG_ANALYZER, defaultAnalyzerName ); indexConfiguration.putIfAbsent( FulltextIndexSettings.INDEX_CONFIG_EVENTUALLY_CONSISTENT, defaultEventuallyConsistentSetting ); return new FulltextSchemaDescriptor( schema, indexConfiguration );
private void processIncludes(Properties props, ResolutionInfo resolutionInfo) { Map<String,String> includes = props.entrySet().stream() .filter(isInclude) .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString())); includes.keySet().forEach(props::remove); includes.values().stream() .map( s -> s.split("::")) .forEach( ref -> { Properties refProps = resolve(ref[0], resolutionInfo); props.putIfAbsent(ref[1], refProps.getProperty(ref[1])); }); }
Properties p = new Properties(); p.load(in); p.forEach((key, value) -> properties.putIfAbsent(key, environment.resolvePlaceholders((String) value)));
@Override public synchronized Object putIfAbsent(Object key, Object value) { keys.remove(key); return super.putIfAbsent(key, value); }
/** * Dynamic index uninverting is deprecated: using it will cause warnings to be logged, * to encourage people to use the annotation org.hibernate.search.annotations.SortableField. * The default in Hibernate Search is to throw an exception rather than logging a warning; * we opt to be more lenient by default in the Infinispan use case, matching the behaviour * of previous versions of Hibernate Search. * * @param indexingProperties */ private void allowDynamicSortingByDefault(Properties indexingProperties) { indexingProperties.putIfAbsent(Environment.INDEX_UNINVERTING_ALLOWED, Boolean.TRUE.toString()); }
private void initializeLazyValue(String key) { if (!fullyInitialized && lazyRuntimeValues.containsKey(key) && properties.get(key) == null) { /* * putIfAbsent has the correct synchronization to guard against concurrent manual * updates of the same property key. */ properties.putIfAbsent(key, lazyRuntimeValues.get(key).get()); } }
public static Properties merge(Properties base, Properties addtional){ Properties properties = new Properties(); properties.putAll(base); if(addtional != null){ for(String key : addtional.stringPropertyNames()){ properties.putIfAbsent(key, addtional.getProperty(key)); } } return properties; }
static void configure() { if (SimpleLoggerUtil.class.getClassLoader().getResource(NAME_RESOURCE_FILE) != null) { return; } AccessController.doPrivileged((PrivilegedAction<Void>) () -> { Properties props = System.getProperties(); OPT_DEFAULTS.forEach((k, v) -> props.putIfAbsent(k, v)); System.setProperties(props); return null; }); } }
static void configure() { if (SimpleLoggerUtil.class.getClassLoader().getResource(NAME_RESOURCE_FILE) != null) { return; } AccessController.doPrivileged((PrivilegedAction<Void>) () -> { Properties props = System.getProperties(); OPT_DEFAULTS.forEach((k, v) -> props.putIfAbsent(k, v)); System.setProperties(props); return null; }); } }
@Override public Properties getProperties(EmbeddedNeo4jConfiguration embedded) { Properties commonProperties = getCommonProperties(); commonProperties.putIfAbsent(PROPERTY_NEO4J_DBMS_CONNECTOR_BOLT_ENABLED, Boolean.toString(embedded.isConnectorEnabled())); commonProperties.putIfAbsent(PROPERTY_NEO4J_DBMS_CONNECTOR_BOLT_LISTEN_ADDRESS, embedded.getListenAddress() + ":" + embedded.getBoltPort()); commonProperties.putIfAbsent(PROPERTY_NEO4J_DBMS_SECURITY_PROCEDURES_UNRESTRICTED, "apoc.*"); commonProperties.putIfAbsent(PROPERTY_NEO4J_DBMS_TX_LOG_ROTATION_SIZE, "50M"); commonProperties.putIfAbsent(PROPERTY_NEO4J_DBMS_TX_LOG_ROTATION_RETENTION_POLICY, Boolean.FALSE.toString()); return commonProperties; } }
@Override public synchronized Object putIfAbsent(Object key, Object value) { if (interned != null) copyFromInternedToThis(); return super.putIfAbsent(key, value); }
/** * Add only absent parameters from argument. * * @see Properties#putIfAbsent(java.lang.Object, java.lang.Object) * @param parameters */ public void addAbsentParameters(Properties parameters) { parameters.forEach((Object k, Object v) -> { LuceneSpinSail.this.parameters.putIfAbsent(k, v); }); }
/** * Returns a new properties merging two instances * @param properties main property instance * @param defaults contains default properties to be merged if containing entries are not defined in main instance. * @return merged instance. */ public static Properties mergeProperties(Properties properties, Properties defaults) { Properties tmpProperties = new Properties(); for (Map.Entry mainEntry : properties.entrySet()) { tmpProperties.put(mainEntry.getKey(), mainEntry.getValue()); } for (Map.Entry defaultEntry : defaults.entrySet()) { tmpProperties.putIfAbsent(defaultEntry.getKey(), defaultEntry.getValue()); } return tmpProperties; } // =========================================================================
/** * Returns the list of configured properties and their values. * * @return The list of configured properties and their values. */ @Override public synchronized String toString() { Properties allProperties = new Properties(); allProperties.putAll(this); for (Property property : Property.values()) { allProperties.putIfAbsent(property.key(), property.defaultValue()); } StringBuilder sb = new StringBuilder(); sb.append("Using the following configured values:\n"); Pattern pattern = Pattern.compile("pwd|secret|password|passwd|token"); Set<String> names = new TreeSet<>(allProperties.stringPropertyNames()); names.stream().forEach((name) -> { String value = pattern.matcher(name).find() ? "********" : allProperties.get(name).toString(); sb.append("\t").append(name).append(" : ").append(value).append("\n"); }); return sb.toString(); }