code
stringlengths
67
466k
docstring
stringlengths
1
13.2k
public String getShortCommitId() { String shortId = get("commit.id.abbrev"); if (shortId != null) { return shortId; } String id = getCommitId(); if (id == null) { return null; } return (id.length() > 7) ? id.substring(0, 7) : id; }
Return the abbreviated id of the commit or {@code null}. @return the short commit id
private static String coerceToEpoch(String s) { Long epoch = parseEpochSecond(s); if (epoch != null) { return String.valueOf(epoch); } SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); try { return String.valueOf(format.parse(s).getTime()); } catch (ParseException ex) { return s; } }
Attempt to convert the specified value to epoch time. Git properties information are known to be specified either as epoch time in seconds or using a specific date format. @param s the value to coerce to @return the epoch time in milliseconds or the original value if it couldn't be converted
public void write(File file) throws IOException { Assert.state(this.pid != null, "No PID available"); createParentFolder(file); if (file.exists()) { assertCanOverwrite(file); } try (FileWriter writer = new FileWriter(file)) { writer.append(this.pid); } }
Write the PID to the specified file. @param file the PID file @throws IllegalStateException if no PID is available. @throws IOException if the file cannot be written
private void preInitializeLeakyClasses() { try { Class<?> readerClass = ClassNameReader.class; Field field = readerClass.getDeclaredField("EARLY_EXIT"); field.setAccessible(true); ((Throwable) field.get(null)).fillInStackTrace(); } catch (Exception ex) { this.logger.warn("Unable to pre-initialize classes", ex); } }
CGLIB has a private exception field which needs to initialized early to ensure that the stacktrace doesn't retain a reference to the RestartClassLoader.
public void addUrls(Collection<URL> urls) { Assert.notNull(urls, "Urls must not be null"); this.urls.addAll(urls); }
Add additional URLs to be includes in the next restart. @param urls the urls to add
public void restart(FailureHandler failureHandler) { if (!this.enabled) { this.logger.debug("Application restart is disabled"); return; } this.logger.debug("Restarting application"); getLeakSafeThread().call(() -> { Restarter.this.stop(); Restarter.this.start(failureHandler); return null; }); }
Restart the running application. @param failureHandler a failure handler to deal with application that doesn't start
protected void start(FailureHandler failureHandler) throws Exception { do { Throwable error = doStart(); if (error == null) { return; } if (failureHandler.handle(error) == Outcome.ABORT) { return; } } while (true); }
Start the application. @param failureHandler a failure handler for application that won't start @throws Exception in case of errors
protected Throwable relaunch(ClassLoader classLoader) throws Exception { RestartLauncher launcher = new RestartLauncher(classLoader, this.mainClassName, this.args, this.exceptionHandler); launcher.start(); launcher.join(); return launcher.getError(); }
Relaunch the application using the specified classloader. @param classLoader the classloader to use @return any exception that caused the launch to fail or {@code null} @throws Exception in case of errors
protected void stop() throws Exception { this.logger.debug("Stopping application"); this.stopLock.lock(); try { for (ConfigurableApplicationContext context : this.rootContexts) { context.close(); this.rootContexts.remove(context); } cleanupCaches(); if (this.forceReferenceCleanup) { forceReferenceCleanup(); } } finally { this.stopLock.unlock(); } System.gc(); System.runFinalization(); }
Stop the application. @throws Exception in case of errors
void finish() { synchronized (this.monitor) { if (!isFinished()) { this.logger = DeferredLog.replay(this.logger, LogFactory.getLog(getClass())); this.finished = true; } } }
Called to finish {@link Restarter} initialization when application logging is available.
public static void initialize(String[] args, RestartInitializer initializer) { initialize(args, false, initializer, true); }
Initialize restart support. See {@link #initialize(String[], boolean, RestartInitializer)} for details. @param args main application arguments @param initializer the restart initializer @see #initialize(String[], boolean, RestartInitializer)
public static void initialize(String[] args, boolean forceReferenceCleanup, RestartInitializer initializer) { initialize(args, forceReferenceCleanup, initializer, true); }
Initialize restart support. See {@link #initialize(String[], boolean, RestartInitializer, boolean)} for details. @param args main application arguments @param forceReferenceCleanup if forcing of soft/weak reference should happen on @param initializer the restart initializer @see #initialize(String[], boolean, RestartInitializer)
public static void initialize(String[] args, boolean forceReferenceCleanup, RestartInitializer initializer, boolean restartOnInitialize) { Restarter localInstance = null; synchronized (INSTANCE_MONITOR) { if (instance == null) { localInstance = new Restarter(Thread.currentThread(), args, forceReferenceCleanup, initializer); instance = localInstance; } } if (localInstance != null) { localInstance.initialize(restartOnInitialize); } }
Initialize restart support for the current application. Called automatically by {@link RestartApplicationListener} but can also be called directly if main application arguments are not the same as those passed to the {@link SpringApplication}. @param args main application arguments @param forceReferenceCleanup if forcing of soft/weak reference should happen on each restart. This will slow down restarts and is intended primarily for testing @param initializer the restart initializer @param restartOnInitialize if the restarter should be restarted immediately when the {@link RestartInitializer} returns non {@code null} results
public HazelcastInstance getHazelcastInstance() { if (StringUtils.hasText(this.config.getInstanceName())) { return Hazelcast.getOrCreateHazelcastInstance(this.config); } return Hazelcast.newHazelcastInstance(this.config); }
Get the {@link HazelcastInstance}. @return the {@link HazelcastInstance}
public WebEndpointResponse<Health> mapDetails(Supplier<Health> health, SecurityContext securityContext) { if (canSeeDetails(securityContext, this.showDetails)) { Health healthDetails = health.get(); if (healthDetails != null) { return createWebEndpointResponse(healthDetails); } } return new WebEndpointResponse<>(WebEndpointResponse.STATUS_NOT_FOUND); }
Maps the given {@code health} details to a {@link WebEndpointResponse}, honouring the mapper's default {@link ShowDetails} using the given {@code securityContext}. <p> If the current user does not have the right to see the details, the {@link Supplier} is not invoked and a 404 response is returned instead. @param health the provider of health details, invoked if the current user has the right to see them @param securityContext the security context @return the mapped response
public WebEndpointResponse<Health> map(Health health, SecurityContext securityContext) { return map(health, securityContext, this.showDetails); }
Maps the given {@code health} to a {@link WebEndpointResponse}, honouring the mapper's default {@link ShowDetails} using the given {@code securityContext}. @param health the health to map @param securityContext the security context @return the mapped response
public WebEndpointResponse<Health> map(Health health, SecurityContext securityContext, ShowDetails showDetails) { if (!canSeeDetails(securityContext, showDetails)) { health = Health.status(health.getStatus()).build(); } return createWebEndpointResponse(health); }
Maps the given {@code health} to a {@link WebEndpointResponse}, honouring the given {@code showDetails} using the given {@code securityContext}. @param health the health to map @param securityContext the security context @param showDetails when to show details in the response @return the mapped response
public String getLastElement(Form form) { int size = getNumberOfElements(); return (size != 0) ? getElement(size - 1, form) : EMPTY_STRING; }
Return the last element in the name in the given form. @param form the form to return @return the last element
public String getElement(int elementIndex, Form form) { CharSequence element = this.elements.get(elementIndex); ElementType type = this.elements.getType(elementIndex); if (type.isIndexed()) { return element.toString(); } if (form == Form.ORIGINAL) { if (type != ElementType.NON_UNIFORM) { return element.toString(); } return convertToOriginalForm(element).toString(); } if (form == Form.DASHED) { if (type == ElementType.UNIFORM || type == ElementType.DASHED) { return element.toString(); } return convertToDashedElement(element).toString(); } CharSequence uniformElement = this.uniformElements[elementIndex]; if (uniformElement == null) { uniformElement = (type != ElementType.UNIFORM) ? convertToUniformElement(element) : element; this.uniformElements[elementIndex] = uniformElement.toString(); } return uniformElement.toString(); }
Return an element in the name in the given form. @param elementIndex the element index @param form the form to return @return the last element
public ConfigurationPropertyName append(String elementValue) { if (elementValue == null) { return this; } Elements additionalElements = probablySingleElementOf(elementValue); return new ConfigurationPropertyName(this.elements.append(additionalElements)); }
Create a new {@link ConfigurationPropertyName} by appending the given element value. @param elementValue the single element value to append @return a new {@link ConfigurationPropertyName} @throws InvalidConfigurationPropertyNameException if elementValue is not valid
public boolean isParentOf(ConfigurationPropertyName name) { Assert.notNull(name, "Name must not be null"); if (this.getNumberOfElements() != name.getNumberOfElements() - 1) { return false; } return isAncestorOf(name); }
Returns {@code true} if this element is an immediate parent of the specified name. @param name the name to check @return {@code true} if this name is an ancestor
public boolean isAncestorOf(ConfigurationPropertyName name) { Assert.notNull(name, "Name must not be null"); if (this.getNumberOfElements() >= name.getNumberOfElements()) { return false; } return elementsEqual(name); }
Returns {@code true} if this element is an ancestor (immediate or nested parent) of the specified name. @param name the name to check @return {@code true} if this name is an ancestor
static ConfigurationPropertyName of(CharSequence name, boolean returnNullIfInvalid) { Elements elements = elementsOf(name, returnNullIfInvalid); return (elements != null) ? new ConfigurationPropertyName(elements) : null; }
Return a {@link ConfigurationPropertyName} for the specified string. @param name the source name @param returnNullIfInvalid if null should be returned if the name is not valid @return a {@link ConfigurationPropertyName} instance @throws InvalidConfigurationPropertyNameException if the name is not valid and {@code returnNullIfInvalid} is {@code false}
static ConfigurationPropertyName adapt(CharSequence name, char separator, Function<CharSequence, CharSequence> elementValueProcessor) { Assert.notNull(name, "Name must not be null"); if (name.length() == 0) { return EMPTY; } Elements elements = new ElementsParser(name, separator) .parse(elementValueProcessor); if (elements.getSize() == 0) { return EMPTY; } return new ConfigurationPropertyName(elements); }
Create a {@link ConfigurationPropertyName} by adapting the given source. The name is split into elements around the given {@code separator}. This method is more lenient than {@link #of} in that it allows mixed case names and '{@code _}' characters. Other invalid characters are stripped out during parsing. <p> The {@code elementValueProcessor} function may be used if additional processing is required on the extracted element values. @param name the name to parse @param separator the separator used to split the name @param elementValueProcessor a function to process element values @return a {@link ConfigurationPropertyName}
public void addCommands(Iterable<Command> commands) { Assert.notNull(commands, "Commands must not be null"); for (Command command : commands) { addCommand(command); } }
Add the specified commands. @param commands the commands to add
public Command findCommand(String name) { for (Command candidate : this.commands) { String candidateName = candidate.getName(); if (candidateName.equals(name) || (isOptionCommand(candidate) && ("--" + candidateName).equals(name))) { return candidate; } } return null; }
Find a command by name. @param name the name of the command @return the command or {@code null} if not found
public int runAndHandleErrors(String... args) { String[] argsWithoutDebugFlags = removeDebugFlags(args); boolean debug = argsWithoutDebugFlags.length != args.length; if (debug) { System.setProperty("debug", "true"); } try { ExitStatus result = run(argsWithoutDebugFlags); // The caller will hang up if it gets a non-zero status if (result != null && result.isHangup()) { return (result.getCode() > 0) ? result.getCode() : 0; } return 0; } catch (NoArgumentsException ex) { showUsage(); return 1; } catch (Exception ex) { return handleError(debug, ex); } }
Run the appropriate and handle and errors. @param args the input arguments @return a return status code (non boot is used to indicate an error)
protected ExitStatus run(String... args) throws Exception { if (args.length == 0) { throw new NoArgumentsException(); } String commandName = args[0]; String[] commandArguments = Arrays.copyOfRange(args, 1, args.length); Command command = findCommand(commandName); if (command == null) { throw new NoSuchCommandException(commandName); } beforeRun(command); try { return command.run(commandArguments); } finally { afterRun(command); } }
Parse the arguments and run a suitable command. @param args the arguments @return the outcome of the command @throws Exception if the command fails
@SuppressWarnings("unchecked") private Map<String, Object> safeSerialize(ObjectMapper mapper, Object bean, String prefix) { try { return new HashMap<>(mapper.convertValue(bean, Map.class)); } catch (Exception ex) { return new HashMap<>(Collections.singletonMap("error", "Cannot serialize '" + prefix + "'")); } }
Cautiously serialize the bean to a map (returning a map with an error message instead of throwing an exception if there is a problem). @param mapper the object mapper @param bean the source bean @param prefix the prefix @return the serialized instance
protected void configureObjectMapper(ObjectMapper mapper) { mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(MapperFeature.USE_STD_BEAN_NAMING, true); mapper.setSerializationInclusion(Include.NON_NULL); applyConfigurationPropertiesFilter(mapper); applySerializationModifier(mapper); }
Configure Jackson's {@link ObjectMapper} to be used to serialize the {@link ConfigurationProperties @ConfigurationProperties} objects into a {@link Map} structure. @param mapper the object mapper
private void applySerializationModifier(ObjectMapper mapper) { SerializerFactory factory = BeanSerializerFactory.instance .withSerializerModifier(new GenericSerializerModifier()); mapper.setSerializerFactory(factory); }
Ensure only bindable and non-cyclic bean properties are reported. @param mapper the object mapper
private String extractPrefix(ApplicationContext context, ConfigurationBeanFactoryMetadata beanFactoryMetaData, String beanName) { ConfigurationProperties annotation = context.findAnnotationOnBean(beanName, ConfigurationProperties.class); if (beanFactoryMetaData != null) { ConfigurationProperties override = beanFactoryMetaData .findFactoryAnnotation(beanName, ConfigurationProperties.class); if (override != null) { // The @Bean-level @ConfigurationProperties overrides the one at type // level when binding. Arguably we should render them both, but this one // might be the most relevant for a starting point. annotation = override; } } return annotation.prefix(); }
Extract configuration prefix from {@link ConfigurationProperties @ConfigurationProperties} annotation. @param context the application context @param beanFactoryMetaData the bean factory meta-data @param beanName the bean name @return the prefix
@SuppressWarnings("unchecked") private Map<String, Object> sanitize(String prefix, Map<String, Object> map) { map.forEach((key, value) -> { String qualifiedKey = (prefix.isEmpty() ? prefix : prefix + ".") + key; if (value instanceof Map) { map.put(key, sanitize(qualifiedKey, (Map<String, Object>) value)); } else if (value instanceof List) { map.put(key, sanitize(qualifiedKey, (List<Object>) value)); } else { value = this.sanitizer.sanitize(key, value); value = this.sanitizer.sanitize(qualifiedKey, value); map.put(key, value); } }); return map; }
Sanitize all unwanted configuration properties to avoid leaking of sensitive information. @param prefix the property prefix @param map the source map @return the sanitized map
public void setKeysToSanitize(String... keysToSanitize) { Assert.notNull(keysToSanitize, "KeysToSanitize must not be null"); this.keysToSanitize = new Pattern[keysToSanitize.length]; for (int i = 0; i < keysToSanitize.length; i++) { this.keysToSanitize[i] = getPattern(keysToSanitize[i]); } }
Keys that should be sanitized. Keys can be simple strings that the property ends with or regular expressions. @param keysToSanitize the keys to sanitize
public Object sanitize(String key, Object value) { if (value == null) { return null; } for (Pattern pattern : this.keysToSanitize) { if (pattern.matcher(key).matches()) { return "******"; } } return value; }
Sanitize the given value if necessary. @param key the key to sanitize @param value the value @return the potentially sanitized value
public static Tag uri(ClientRequest request) { String uri = (String) request.attribute(URI_TEMPLATE_ATTRIBUTE) .orElseGet(() -> request.url().getPath()); return Tag.of("uri", extractPath(uri)); }
Creates a {@code uri} {@code Tag} for the URI path of the given {@code request}. @param request the request @return the uri tag
public static Tag status(ClientResponse response) { return Tag.of("status", String.valueOf(response.statusCode().value())); }
Creates a {@code status} {@code Tag} derived from the {@link ClientResponse#statusCode()} of the given {@code response}. @param response the response @return the status tag
public static Tag clientName(ClientRequest request) { String host = request.url().getHost(); if (host == null) { return CLIENT_NAME_NONE; } return Tag.of("clientName", host); }
Create a {@code clientName} {@code Tag} derived from the {@link java.net.URI#getHost host} of the {@link ClientRequest#url() URL} of the given {@code request}. @param request the request @return the clientName tag
public static Tag outcome(ClientResponse response) { try { if (response != null) { HttpStatus status = response.statusCode(); if (status.is1xxInformational()) { return OUTCOME_INFORMATIONAL; } if (status.is2xxSuccessful()) { return OUTCOME_SUCCESS; } if (status.is3xxRedirection()) { return OUTCOME_REDIRECTION; } if (status.is4xxClientError()) { return OUTCOME_CLIENT_ERROR; } if (status.is5xxServerError()) { return OUTCOME_SERVER_ERROR; } } return OUTCOME_UNKNOWN; } catch (IllegalArgumentException exc) { return OUTCOME_UNKNOWN; } }
Creates an {@code outcome} {@code Tag} derived from the {@link ClientResponse#statusCode() status} of the given {@code response}. @param response the response @return the outcome tag @since 2.2.0
public static SQLDialect getDialect(DataSource dataSource) { if (dataSource == null) { return SQLDialect.DEFAULT; } try { String url = JdbcUtils.extractDatabaseMetaData(dataSource, "getURL"); SQLDialect sqlDialect = JDBCUtils.dialect(url); if (sqlDialect != null) { return sqlDialect; } } catch (MetaDataAccessException ex) { logger.warn("Unable to determine jdbc url from datasource", ex); } return SQLDialect.DEFAULT; }
Return the most suitable {@link SQLDialect} for the given {@link DataSource}. @param dataSource the source {@link DataSource} @return the most suitable {@link SQLDialect}
public JSONObject putOpt(String name, Object value) throws JSONException { if (name == null || value == null) { return this; } return put(name, value); }
Equivalent to {@code put(name, value)} when both parameters are non-null; does nothing otherwise. @param name the name of the property @param value the value of the property @return this object. @throws JSONException if an error occurs
public JSONObject accumulate(String name, Object value) throws JSONException { Object current = this.nameValuePairs.get(checkName(name)); if (current == null) { return put(name, value); } // check in accumulate, since array.put(Object) doesn't do any checking if (value instanceof Number) { JSON.checkDouble(((Number) value).doubleValue()); } if (current instanceof JSONArray) { JSONArray array = (JSONArray) current; array.put(value); } else { JSONArray array = new JSONArray(); array.put(current); array.put(value); this.nameValuePairs.put(name, array); } return this; }
Appends {@code value} to the array already mapped to {@code name}. If this object has no mapping for {@code name}, this inserts a new mapping. If the mapping exists but its value is not an array, the existing and new values are inserted in order into a new array which is itself mapped to {@code name}. In aggregate, this allows values to be added to a mapping one at a time. @param name the name of the property @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, Integer, Long, Double, {@link #NULL} or null. May not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}. @return this object. @throws JSONException if an error occurs
public boolean isNull(String name) { Object value = this.nameValuePairs.get(name); return value == null || value == NULL; }
Returns true if this object has no mapping for {@code name} or if it has a mapping whose value is {@link #NULL}. @param name the name of the property @return true if this object has no mapping for {@code name}
public Object get(String name) throws JSONException { Object result = this.nameValuePairs.get(name); if (result == null) { throw new JSONException("No value for " + name); } return result; }
Returns the value mapped by {@code name}. @param name the name of the property @return the value @throws JSONException if no such mapping exists.
public boolean getBoolean(String name) throws JSONException { Object object = get(name); Boolean result = JSON.toBoolean(object); if (result == null) { throw JSON.typeMismatch(name, object, "boolean"); } return result; }
Returns the value mapped by {@code name} if it exists and is a boolean or can be coerced to a boolean. @param name the name of the property @return the value @throws JSONException if the mapping doesn't exist or cannot be coerced to a boolean.
public boolean optBoolean(String name, boolean fallback) { Object object = opt(name); Boolean result = JSON.toBoolean(object); return result != null ? result : fallback; }
Returns the value mapped by {@code name} if it exists and is a boolean or can be coerced to a boolean. Returns {@code fallback} otherwise. @param name the name of the property @param fallback a fallback value @return the value or {@code fallback}
public double getDouble(String name) throws JSONException { Object object = get(name); Double result = JSON.toDouble(object); if (result == null) { throw JSON.typeMismatch(name, object, "double"); } return result; }
Returns the value mapped by {@code name} if it exists and is a double or can be coerced to a double. @param name the name of the property @return the value @throws JSONException if the mapping doesn't exist or cannot be coerced to a double.
public double optDouble(String name, double fallback) { Object object = opt(name); Double result = JSON.toDouble(object); return result != null ? result : fallback; }
Returns the value mapped by {@code name} if it exists and is a double or can be coerced to a double. Returns {@code fallback} otherwise. @param name the name of the property @param fallback a fallback value @return the value or {@code fallback}
public int getInt(String name) throws JSONException { Object object = get(name); Integer result = JSON.toInteger(object); if (result == null) { throw JSON.typeMismatch(name, object, "int"); } return result; }
Returns the value mapped by {@code name} if it exists and is an int or can be coerced to an int. @param name the name of the property @return the value @throws JSONException if the mapping doesn't exist or cannot be coerced to an int.
public int optInt(String name, int fallback) { Object object = opt(name); Integer result = JSON.toInteger(object); return result != null ? result : fallback; }
Returns the value mapped by {@code name} if it exists and is an int or can be coerced to an int. Returns {@code fallback} otherwise. @param name the name of the property @param fallback a fallback value @return the value or {@code fallback}
public long getLong(String name) throws JSONException { Object object = get(name); Long result = JSON.toLong(object); if (result == null) { throw JSON.typeMismatch(name, object, "long"); } return result; }
Returns the value mapped by {@code name} if it exists and is a long or can be coerced to a long. Note that JSON represents numbers as doubles, so this is <a href="#lossy">lossy</a>; use strings to transfer numbers via JSON. @param name the name of the property @return the value @throws JSONException if the mapping doesn't exist or cannot be coerced to a long.
public long optLong(String name, long fallback) { Object object = opt(name); Long result = JSON.toLong(object); return result != null ? result : fallback; }
Returns the value mapped by {@code name} if it exists and is a long or can be coerced to a long. Returns {@code fallback} otherwise. Note that JSON represents numbers as doubles, so this is <a href="#lossy">lossy</a>; use strings to transfer numbers via JSON. @param name the name of the property @param fallback a fallback value @return the value or {@code fallback}
public String getString(String name) throws JSONException { Object object = get(name); String result = JSON.toString(object); if (result == null) { throw JSON.typeMismatch(name, object, "String"); } return result; }
Returns the value mapped by {@code name} if it exists, coercing it if necessary. @param name the name of the property @return the value @throws JSONException if no such mapping exists.
public String optString(String name, String fallback) { Object object = opt(name); String result = JSON.toString(object); return result != null ? result : fallback; }
Returns the value mapped by {@code name} if it exists, coercing it if necessary. Returns {@code fallback} if no such mapping exists. @param name the name of the property @param fallback a fallback value @return the value or {@code fallback}
public JSONArray getJSONArray(String name) throws JSONException { Object object = get(name); if (object instanceof JSONArray) { return (JSONArray) object; } else { throw JSON.typeMismatch(name, object, "JSONArray"); } }
Returns the value mapped by {@code name} if it exists and is a {@code JSONArray}. @param name the name of the property @return the value @throws JSONException if the mapping doesn't exist or is not a {@code JSONArray}.
public JSONArray optJSONArray(String name) { Object object = opt(name); return object instanceof JSONArray ? (JSONArray) object : null; }
Returns the value mapped by {@code name} if it exists and is a {@code JSONArray}. Returns null otherwise. @param name the name of the property @return the value or {@code null}
public JSONObject getJSONObject(String name) throws JSONException { Object object = get(name); if (object instanceof JSONObject) { return (JSONObject) object; } else { throw JSON.typeMismatch(name, object, "JSONObject"); } }
Returns the value mapped by {@code name} if it exists and is a {@code JSONObject}. @param name the name of the property @return the value @throws JSONException if the mapping doesn't exist or is not a {@code JSONObject}.
public JSONObject optJSONObject(String name) { Object object = opt(name); return object instanceof JSONObject ? (JSONObject) object : null; }
Returns the value mapped by {@code name} if it exists and is a {@code JSONObject}. Returns null otherwise. @param name the name of the property @return the value or {@code null}
public JSONArray toJSONArray(JSONArray names) { JSONArray result = new JSONArray(); if (names == null) { return null; } int length = names.length(); if (length == 0) { return null; } for (int i = 0; i < length; i++) { String name = JSON.toString(names.opt(i)); result.put(opt(name)); } return result; }
Returns an array with the values corresponding to {@code names}. The array contains null for names that aren't mapped. This method returns null if {@code names} is either null or empty. @param names the names of the properties @return the array
public static String numberToString(Number number) throws JSONException { if (number == null) { throw new JSONException("Number must be non-null"); } double doubleValue = number.doubleValue(); JSON.checkDouble(doubleValue); // the original returns "-0" instead of "-0.0" for negative zero if (number.equals(NEGATIVE_ZERO)) { return "-0"; } long longValue = number.longValue(); if (doubleValue == longValue) { return Long.toString(longValue); } return number.toString(); }
Encodes the number as a JSON string. @param number a finite value. May not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}. @return the encoded value @throws JSONException if an error occurs
public static String quote(String data) { if (data == null) { return "\"\""; } try { JSONStringer stringer = new JSONStringer(); stringer.open(JSONStringer.Scope.NULL, ""); stringer.value(data); stringer.close(JSONStringer.Scope.NULL, JSONStringer.Scope.NULL, ""); return stringer.toString(); } catch (JSONException e) { throw new AssertionError(); } }
Encodes {@code data} as a JSON string. This applies quotes and any necessary character escaping. @param data the string to encode. Null will be interpreted as an empty string. @return the quoted value
public TaskExecutorBuilder taskDecorator(TaskDecorator taskDecorator) { return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize, this.allowCoreThreadTimeOut, this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod, this.threadNamePrefix, taskDecorator, this.customizers); }
Set the {@link TaskDecorator} to use or {@code null} to not use any. @param taskDecorator the task decorator to use @return a new builder instance
public TaskExecutorBuilder customizers(TaskExecutorCustomizer... customizers) { Assert.notNull(customizers, "Customizers must not be null"); return customizers(Arrays.asList(customizers)); }
Set the {@link TaskExecutorCustomizer TaskExecutorCustomizers} that should be applied to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers. @param customizers the customizers to set @return a new builder instance @see #additionalCustomizers(TaskExecutorCustomizer...)
public TaskExecutorBuilder customizers(Iterable<TaskExecutorCustomizer> customizers) { Assert.notNull(customizers, "Customizers must not be null"); return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize, this.allowCoreThreadTimeOut, this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod, this.threadNamePrefix, this.taskDecorator, append(null, customizers)); }
Set the {@link TaskExecutorCustomizer TaskExecutorCustomizers} that should be applied to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers. @param customizers the customizers to set @return a new builder instance @see #additionalCustomizers(TaskExecutorCustomizer...)
public TaskExecutorBuilder additionalCustomizers( TaskExecutorCustomizer... customizers) { Assert.notNull(customizers, "Customizers must not be null"); return additionalCustomizers(Arrays.asList(customizers)); }
Add {@link TaskExecutorCustomizer TaskExecutorCustomizers} that should be applied to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order that they were added after builder configuration has been applied. @param customizers the customizers to add @return a new builder instance @see #customizers(TaskExecutorCustomizer...)
public <T extends ThreadPoolTaskExecutor> T build(Class<T> taskExecutorClass) { return configure(BeanUtils.instantiateClass(taskExecutorClass)); }
Build a new {@link ThreadPoolTaskExecutor} instance of the specified type and configure it using this builder. @param <T> the type of task executor @param taskExecutorClass the template type to create @return a configured {@link ThreadPoolTaskExecutor} instance. @see #build() @see #configure(ThreadPoolTaskExecutor)
public <T extends ThreadPoolTaskExecutor> T configure(T taskExecutor) { PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); map.from(this.queueCapacity).to(taskExecutor::setQueueCapacity); map.from(this.corePoolSize).to(taskExecutor::setCorePoolSize); map.from(this.maxPoolSize).to(taskExecutor::setMaxPoolSize); map.from(this.keepAlive).asInt(Duration::getSeconds) .to(taskExecutor::setKeepAliveSeconds); map.from(this.allowCoreThreadTimeOut).to(taskExecutor::setAllowCoreThreadTimeOut); map.from(this.awaitTermination) .to(taskExecutor::setWaitForTasksToCompleteOnShutdown); map.from(this.awaitTerminationPeriod).asInt(Duration::getSeconds) .to(taskExecutor::setAwaitTerminationSeconds); map.from(this.threadNamePrefix).whenHasText() .to(taskExecutor::setThreadNamePrefix); map.from(this.taskDecorator).to(taskExecutor::setTaskDecorator); if (!CollectionUtils.isEmpty(this.customizers)) { this.customizers.forEach((customizer) -> customizer.customize(taskExecutor)); } return taskExecutor; }
Configure the provided {@link ThreadPoolTaskExecutor} instance using this builder. @param <T> the type of task executor @param taskExecutor the {@link ThreadPoolTaskExecutor} to configure @return the task executor instance @see #build() @see #build(Class)
public void configure(DefaultJmsListenerContainerFactory factory, ConnectionFactory connectionFactory) { Assert.notNull(factory, "Factory must not be null"); Assert.notNull(connectionFactory, "ConnectionFactory must not be null"); factory.setConnectionFactory(connectionFactory); factory.setPubSubDomain(this.jmsProperties.isPubSubDomain()); if (this.transactionManager != null) { factory.setTransactionManager(this.transactionManager); } else { factory.setSessionTransacted(true); } if (this.destinationResolver != null) { factory.setDestinationResolver(this.destinationResolver); } if (this.messageConverter != null) { factory.setMessageConverter(this.messageConverter); } JmsProperties.Listener listener = this.jmsProperties.getListener(); factory.setAutoStartup(listener.isAutoStartup()); if (listener.getAcknowledgeMode() != null) { factory.setSessionAcknowledgeMode(listener.getAcknowledgeMode().getMode()); } String concurrency = listener.formatConcurrency(); if (concurrency != null) { factory.setConcurrency(concurrency); } }
Configure the specified jms listener container factory. The factory can be further tuned and default settings can be overridden. @param factory the {@link DefaultJmsListenerContainerFactory} instance to configure @param connectionFactory the {@link ConnectionFactory} to use
public void add(Collection<ConfigurationMetadataSource> sources) { for (ConfigurationMetadataSource source : sources) { String groupId = source.getGroupId(); ConfigurationMetadataGroup group = this.allGroups.get(groupId); if (group == null) { group = new ConfigurationMetadataGroup(groupId); this.allGroups.put(groupId, group); } String sourceType = source.getType(); if (sourceType != null) { putIfAbsent(group.getSources(), sourceType, source); } } }
Register the specified {@link ConfigurationMetadataSource sources}. @param sources the sources to add
public void add(ConfigurationMetadataProperty property, ConfigurationMetadataSource source) { if (source != null) { putIfAbsent(source.getProperties(), property.getId(), property); } putIfAbsent(getGroup(source).getProperties(), property.getId(), property); }
Add a {@link ConfigurationMetadataProperty} with the {@link ConfigurationMetadataSource source} that defines it, if any. @param property the property to add @param source the source
public void include(ConfigurationMetadataRepository repository) { for (ConfigurationMetadataGroup group : repository.getAllGroups().values()) { ConfigurationMetadataGroup existingGroup = this.allGroups.get(group.getId()); if (existingGroup == null) { this.allGroups.put(group.getId(), group); } else { // Merge properties group.getProperties().forEach((name, value) -> putIfAbsent( existingGroup.getProperties(), name, value)); // Merge sources group.getSources().forEach((name, value) -> putIfAbsent(existingGroup.getSources(), name, value)); } } }
Merge the content of the specified repository to this repository. @param repository the repository to include
@Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { beanFactory.addBeanPostProcessor( new WebApplicationContextServletContextAwareProcessor(this)); beanFactory.ignoreDependencyInterface(ServletContextAware.class); registerWebApplicationScopes(); }
Register ServletContextAwareProcessor. @see ServletContextAwareProcessor
protected ServletWebServerFactory getWebServerFactory() { // Use bean names so that we don't consider the hierarchy String[] beanNames = getBeanFactory() .getBeanNamesForType(ServletWebServerFactory.class); if (beanNames.length == 0) { throw new ApplicationContextException( "Unable to start ServletWebServerApplicationContext due to missing " + "ServletWebServerFactory bean."); } if (beanNames.length > 1) { throw new ApplicationContextException( "Unable to start ServletWebServerApplicationContext due to multiple " + "ServletWebServerFactory beans : " + StringUtils.arrayToCommaDelimitedString(beanNames)); } return getBeanFactory().getBean(beanNames[0], ServletWebServerFactory.class); }
Returns the {@link ServletWebServerFactory} that should be used to create the embedded {@link WebServer}. By default this method searches for a suitable bean in the context itself. @return a {@link ServletWebServerFactory} (never {@code null})
protected void prepareWebApplicationContext(ServletContext servletContext) { Object rootContext = servletContext.getAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (rootContext != null) { if (rootContext == this) { throw new IllegalStateException( "Cannot initialize context because there is already a root application context present - " + "check whether you have multiple ServletContextInitializers!"); } return; } Log logger = LogFactory.getLog(ContextLoader.class); servletContext.log("Initializing Spring embedded WebApplicationContext"); try { servletContext.setAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this); if (logger.isDebugEnabled()) { logger.debug( "Published root WebApplicationContext as ServletContext attribute with name [" + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]"); } setServletContext(servletContext); if (logger.isInfoEnabled()) { long elapsedTime = System.currentTimeMillis() - getStartupDate(); logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms"); } } catch (RuntimeException | Error ex) { logger.error("Context initialization failed", ex); servletContext.setAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); throw ex; } }
Prepare the {@link WebApplicationContext} with the given fully loaded {@link ServletContext}. This method is usually called from {@link ServletContextInitializer#onStartup(ServletContext)} and is similar to the functionality usually provided by a {@link ContextLoaderListener}. @param servletContext the operational servlet context
@Override public void setEnvironment(ConfigurableEnvironment environment) { super.setEnvironment(environment); this.reader.setEnvironment(environment); this.scanner.setEnvironment(environment); }
{@inheritDoc} <p> Delegates given environment to underlying {@link AnnotatedBeanDefinitionReader} and {@link ClassPathBeanDefinitionScanner} members.
public void setBeanNameGenerator(BeanNameGenerator beanNameGenerator) { this.reader.setBeanNameGenerator(beanNameGenerator); this.scanner.setBeanNameGenerator(beanNameGenerator); this.getBeanFactory().registerSingleton( AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR, beanNameGenerator); }
Provide a custom {@link BeanNameGenerator} for use with {@link AnnotatedBeanDefinitionReader} and/or {@link ClassPathBeanDefinitionScanner}, if any. <p> Default is {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}. <p> Any call to this method must occur prior to calls to {@link #register(Class...)} and/or {@link #scan(String...)}. @param beanNameGenerator the bean name generator @see AnnotatedBeanDefinitionReader#setBeanNameGenerator @see ClassPathBeanDefinitionScanner#setBeanNameGenerator
@Override public final void register(Class<?>... annotatedClasses) { Assert.notEmpty(annotatedClasses, "At least one annotated class must be specified"); this.annotatedClasses.addAll(Arrays.asList(annotatedClasses)); }
Register one or more annotated classes to be processed. Note that {@link #refresh()} must be called in order for the context to fully process the new class. <p> Calls to {@code #register} are idempotent; adding the same annotated class more than once has no additional effect. @param annotatedClasses one or more annotated classes, e.g. {@code @Configuration} classes @see #scan(String...) @see #refresh()
protected void configureSsl(SslContextFactory factory, Ssl ssl, SslStoreProvider sslStoreProvider) { factory.setProtocol(ssl.getProtocol()); configureSslClientAuth(factory, ssl); configureSslPasswords(factory, ssl); factory.setCertAlias(ssl.getKeyAlias()); if (!ObjectUtils.isEmpty(ssl.getCiphers())) { factory.setIncludeCipherSuites(ssl.getCiphers()); factory.setExcludeCipherSuites(); } if (ssl.getEnabledProtocols() != null) { factory.setIncludeProtocols(ssl.getEnabledProtocols()); } if (sslStoreProvider != null) { try { factory.setKeyStore(sslStoreProvider.getKeyStore()); factory.setTrustStore(sslStoreProvider.getTrustStore()); } catch (Exception ex) { throw new IllegalStateException("Unable to set SSL store", ex); } } else { configureSslKeyStore(factory, ssl); configureSslTrustStore(factory, ssl); } }
Configure the SSL connection. @param factory the Jetty {@link SslContextFactory}. @param ssl the ssl details. @param sslStoreProvider the ssl store provider
private String getConnectionFactoryName(String beanName) { if (beanName.length() > CONNECTION_FACTORY_SUFFIX.length() && StringUtils.endsWithIgnoreCase(beanName, CONNECTION_FACTORY_SUFFIX)) { return beanName.substring(0, beanName.length() - CONNECTION_FACTORY_SUFFIX.length()); } return beanName; }
Get the name of a ConnectionFactory based on its {@code beanName}. @param beanName the name of the connection factory bean @return a name for the given connection factory
public void sourceResources(SourceSet sourceSet) { setClasspath(getProject() .files(sourceSet.getResources().getSrcDirs(), getClasspath()) .filter((file) -> !file.equals(sourceSet.getOutput().getResourcesDir()))); }
Adds the {@link SourceDirectorySet#getSrcDirs() source directories} of the given {@code sourceSet's} {@link SourceSet#getResources() resources} to the start of the classpath in place of the {@link SourceSet#getOutput output's} {@link SourceSetOutput#getResourcesDir() resources directory}. @param sourceSet the source set
protected String getDescription(HttpServletRequest request) { String pathInfo = (request.getPathInfo() != null) ? request.getPathInfo() : ""; return "[" + request.getServletPath() + pathInfo + "]"; }
Return the description for the given request. By default this method will return a description based on the request {@code servletPath} and {@code pathInfo}. @param request the source request @return the description @since 1.5.0
public void configure( ConcurrentKafkaListenerContainerFactory<Object, Object> listenerFactory, ConsumerFactory<Object, Object> consumerFactory) { listenerFactory.setConsumerFactory(consumerFactory); configureListenerFactory(listenerFactory); configureContainer(listenerFactory.getContainerProperties()); }
Configure the specified Kafka listener container factory. The factory can be further tuned and default settings can be overridden. @param listenerFactory the {@link ConcurrentKafkaListenerContainerFactory} instance to configure @param consumerFactory the {@link ConsumerFactory} to use
protected Identifier getIdentifier(String name, boolean quoted, JdbcEnvironment jdbcEnvironment) { if (isCaseInsensitive(jdbcEnvironment)) { name = name.toLowerCase(Locale.ROOT); } return new Identifier(name, quoted); }
Get an identifier for the specified details. By default this method will return an identifier with the name adapted based on the result of {@link #isCaseInsensitive(JdbcEnvironment)} @param name the name of the identifier @param quoted if the identifier is quoted @param jdbcEnvironment the JDBC environment @return an identifier instance
public Resource resolveConfigLocation() { if (this.config == null) { return null; } Assert.isTrue(this.config.exists(), () -> "Hazelcast configuration does not " + "exist '" + this.config.getDescription() + "'"); return this.config; }
Resolve the config location if set. @return the location or {@code null} if it is not set @throws IllegalArgumentException if the config attribute is set to an unknown location
public Map<String, OriginTrackedValue> load(boolean expandLists) throws IOException { try (CharacterReader reader = new CharacterReader(this.resource)) { Map<String, OriginTrackedValue> result = new LinkedHashMap<>(); StringBuilder buffer = new StringBuilder(); while (reader.read()) { String key = loadKey(buffer, reader).trim(); if (expandLists && key.endsWith("[]")) { key = key.substring(0, key.length() - 2); int index = 0; do { OriginTrackedValue value = loadValue(buffer, reader, true); put(result, key + "[" + (index++) + "]", value); if (!reader.isEndOfLine()) { reader.read(); } } while (!reader.isEndOfLine()); } else { OriginTrackedValue value = loadValue(buffer, reader, false); put(result, key, value); } } return result; } }
Load {@code .properties} data and return a map of {@code String} -> {@link OriginTrackedValue}. @param expandLists if list {@code name[]=a,b,c} shortcuts should be expanded @return the loaded properties @throws IOException on read error
private ArtemisMode deduceMode() { if (this.properties.getEmbedded().isEnabled() && ClassUtils.isPresent(EMBEDDED_JMS_CLASS, null)) { return ArtemisMode.EMBEDDED; } return ArtemisMode.NATIVE; }
Deduce the {@link ArtemisMode} to use if none has been set. @return the mode
private boolean isWithin(JavaVersion runningVersion, Range range, JavaVersion version) { if (range == Range.EQUAL_OR_NEWER) { return runningVersion.isEqualOrNewerThan(version); } if (range == Range.OLDER_THAN) { return runningVersion.isOlderThan(version); } throw new IllegalStateException("Unknown range " + range); }
Determines if the {@code runningVersion} is within the specified range of versions. @param runningVersion the current version. @param range the range @param version the bounds of the range @return if this version is within the specified range
public Map<String, Object> buildConsumerProperties() { Map<String, Object> properties = buildCommonProperties(); properties.putAll(this.consumer.buildProperties()); return properties; }
Create an initial map of consumer properties from the state of this instance. <p> This allows you to add additional properties, if necessary, and override the default kafkaConsumerFactory bean. @return the consumer properties initialized with the customizations defined on this instance
public Map<String, Object> buildProducerProperties() { Map<String, Object> properties = buildCommonProperties(); properties.putAll(this.producer.buildProperties()); return properties; }
Create an initial map of producer properties from the state of this instance. <p> This allows you to add additional properties, if necessary, and override the default kafkaProducerFactory bean. @return the producer properties initialized with the customizations defined on this instance
public Map<String, Object> buildAdminProperties() { Map<String, Object> properties = buildCommonProperties(); properties.putAll(this.admin.buildProperties()); return properties; }
Create an initial map of admin properties from the state of this instance. <p> This allows you to add additional properties, if necessary, and override the default kafkaAdmin bean. @return the admin properties initialized with the customizations defined on this instance
public Map<String, Object> buildStreamsProperties() { Map<String, Object> properties = buildCommonProperties(); properties.putAll(this.streams.buildProperties()); return properties; }
Create an initial map of streams properties from the state of this instance. <p> This allows you to add additional properties, if necessary. @return the streams properties initialized with the customizations defined on this instance
public <T> T execute(long wait, int maxAttempts, Callable<T> callback) throws Exception { getLog().debug("Waiting for spring application to start..."); for (int i = 0; i < maxAttempts; i++) { T result = callback.call(); if (result != null) { return result; } String message = "Spring application is not ready yet, waiting " + wait + "ms (attempt " + (i + 1) + ")"; getLog().debug(message); synchronized (this.lock) { try { this.lock.wait(wait); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new IllegalStateException( "Interrupted while waiting for Spring Boot app to start."); } } } throw new MojoExecutionException( "Spring application did not start before the configured " + "timeout (" + (wait * maxAttempts) + "ms"); }
Execute a task, retrying it on failure. @param <T> the result type @param wait the wait time @param maxAttempts the maximum number of attempts @param callback the task to execute (possibly multiple times). The callback should return {@code null} to indicate that another attempt should be made @return the result @throws Exception in case of execution errors
public void applyTo(Properties properties) { put(properties, LoggingSystemProperties.LOG_PATH, this.path); put(properties, LoggingSystemProperties.LOG_FILE, toString()); }
Apply log file details to {@code LOG_PATH} and {@code LOG_FILE} map entries. @param properties the properties to apply to
public static LogFile get(PropertyResolver propertyResolver) { String file = getLogFileProperty(propertyResolver, FILE_NAME_PROPERTY, FILE_PROPERTY); String path = getLogFileProperty(propertyResolver, FILE_PATH_PROPERTY, PATH_PROPERTY); if (StringUtils.hasLength(file) || StringUtils.hasLength(path)) { return new LogFile(file, path); } return null; }
Get a {@link LogFile} from the given Spring {@link Environment}. @param propertyResolver the {@link PropertyResolver} used to obtain the logging properties @return a {@link LogFile} or {@code null} if the environment didn't contain any suitable properties
public void setInitParameters(Map<String, String> initParameters) { Assert.notNull(initParameters, "InitParameters must not be null"); this.initParameters = new LinkedHashMap<>(initParameters); }
Set init-parameters for this registration. Calling this method will replace any existing init-parameters. @param initParameters the init parameters @see #getInitParameters @see #addInitParameter
public void addInitParameter(String name, String value) { Assert.notNull(name, "Name must not be null"); this.initParameters.put(name, value); }
Add a single init-parameter, replacing any existing parameter with the same name. @param name the init-parameter name @param value the init-parameter value
protected final String getOrDeduceName(Object value) { return (this.name != null) ? this.name : Conventions.getVariableName(value); }
Deduces the name for this registration. Will return user specified name or fallback to convention based naming. @param value the object used for convention based names @return the deduced name
public Object getFieldDefaultValue(TypeElement type, String name) { return this.defaultValues.computeIfAbsent(type, this::resolveFieldValues) .get(name); }
Return the default value of the field with the specified {@code name}. @param type the type to consider @param name the name of the field @return the default value or {@code null} if the field does not exist or no default value has been detected
public Properties asProperties() { Properties properties = new Properties(); set(properties, "service", getService()); set(properties, "max_timeout", getMaxTimeout()); set(properties, "default_jta_timeout", getDefaultJtaTimeout()); set(properties, "max_actives", getMaxActives()); set(properties, "enable_logging", isEnableLogging()); set(properties, "tm_unique_name", getTransactionManagerUniqueName()); set(properties, "serial_jta_transactions", isSerialJtaTransactions()); set(properties, "allow_subtransactions", isAllowSubTransactions()); set(properties, "force_shutdown_on_vm_exit", isForceShutdownOnVmExit()); set(properties, "default_max_wait_time_on_shutdown", getDefaultMaxWaitTimeOnShutdown()); set(properties, "log_base_name", getLogBaseName()); set(properties, "log_base_dir", getLogBaseDir()); set(properties, "checkpoint_interval", getCheckpointInterval()); set(properties, "threaded_2pc", isThreadedTwoPhaseCommit()); Recovery recovery = getRecovery(); set(properties, "forget_orphaned_log_entries_delay", recovery.getForgetOrphanedLogEntriesDelay()); set(properties, "recovery_delay", recovery.getDelay()); set(properties, "oltp_max_retries", recovery.getMaxRetries()); set(properties, "oltp_retry_interval", recovery.getRetryInterval()); return properties; }
Returns the properties as a {@link Properties} object that can be used with Atomikos. @return the properties
public Map<String, Object> determineHibernateProperties( Map<String, String> jpaProperties, HibernateSettings settings) { Assert.notNull(jpaProperties, "JpaProperties must not be null"); Assert.notNull(settings, "Settings must not be null"); return getAdditionalProperties(jpaProperties, settings); }
Determine the configuration properties for the initialization of the main Hibernate EntityManagerFactory based on standard JPA properties and {@link HibernateSettings}. @param jpaProperties standard JPA properties @param settings the settings to apply when determining the configuration properties @return the Hibernate properties to use