Skip to content

Commit

Permalink
revert format changes
Browse files Browse the repository at this point in the history
Signed-off-by: ac892247 <a.chmelo@gmail.com>
  • Loading branch information
achmelo committed Sep 11, 2024
1 parent 0eb5def commit 57c36e7
Showing 1 changed file with 63 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,52 +34,53 @@
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

/**
* This class implements a facility for loading API ML service on-boarding configuration.
* <p>
* The implementation provides several methods for building the service configuration:
* <ul>
* <li>single filename in YAML format</li>
* <li>two file names in YAML format</li>
* <li>ServletContext initialized with servlet init parameters containing one or two file names under predefined
* keys and/or additional parameters to overwrite some of the properties contained in the configuration files
* </li>
* <li>String containing the YAML as text</li>
* <li>Java System properties which can be provided on the command line at service boot time</li>
* </ul>
* The file names can point to files placed anywhere in the file system, provided that the service has access to them.
* </p>
* This class implements a facility for loading API ML service on-boarding configuration.
* <p>
* The implementation provides several methods for building the service configuration:
* <ul>
* <li>single filename in YAML format</li>
* <li>two file names in YAML format</li>
* <li>ServletContext initialized with servlet init parameters containing one or two file names under predefined
* keys and/or additional parameters to overwrite some of the properties contained in the configuration files
* </li>
* <li>String containing the YAML as text</li>
* <li>Java System properties which can be provided on the command line at service boot time</li>
* </ul>
* The file names can point to files placed anywhere in the file system, provided that the service has access to them.
* </p>
*
* <p>
* The first file is usually internal to the service deployment artifact and should be located on
* the service classpath. It contains basic API ML configuration containing values known at development time.
* Typically it is provided by the service developer and is located in the /resources folder of java project source
* tree. In the deployment artifact it usually can be found under /WEB-INF/classes.
* </p>
* <p>
* The first file is usually internal to the service deployment artifact and should be located on
* the service classpath. It contains basic API ML configuration containing values known at development time.
* Typically it is provided by the service developer and is located in the /resources folder of java project source
* tree. In the deployment artifact it usually can be found under /WEB-INF/classes.
* </p>
*
* <p>
* The second configuration file is used to externalize the configuration. It is populated with values dependent on
* the target deployment environment. The file can be placed in arbitrary location, where the order of searching it is as follows:
* <ul>
* <li>Service classpath</li>
* <li>System classpath classpath</li>
* <li>Absolute path</li>
* <li>Path relative to the Web server home directory</li>
* <li>Path relative to the User home directory</li>
* <li>Path relative to any of the file system roots</li>
* </ul>
* <p>
* When the service web context is initialized, the on-boarding configuration is build from the one or two configurations,
* where the externalized configuration (if provided) has higher priority.
* </p>
* <p>
* The second configuration file is used to externalize the configuration. It is populated with values dependent on
* the target deployment environment. The file can be placed in arbitrary location, where the order of searching it is as follows:
* <ul>
* <li>Service classpath</li>
* <li>System classpath classpath</li>
* <li>Absolute path</li>
* <li>Path relative to the Web server home directory</li>
* <li>Path relative to the User home directory</li>
* <li>Path relative to any of the file system roots</li>
* </ul>
*
* When the service web context is initialized, the on-boarding configuration is build from the one or two configurations,
* where the externalized configuration (if provided) has higher priority.
* </p>
*
* <p>
* The values of the properties configured in both files can be overwritten by Java System properties and/or
* ServletContext parameters. Set a parameter value in the YAML file to ${apiml.your.config.key} and provide the actual
* value under the same key in a servlet context init parameter:
* <Parameter name="apiml.your.very.own.key" value="the-actual-property-value" />
*
* , or in the corresponding Java System property.
* </p>
*
* <p>
* The values of the properties configured in both files can be overwritten by Java System properties and/or
* ServletContext parameters. Set a parameter value in the YAML file to ${apiml.your.config.key} and provide the actual
* value under the same key in a servlet context init parameter:
* <Parameter name="apiml.your.very.own.key" value="the-actual-property-value" />
* <p>
* , or in the corresponding Java System property.
* </p>
*/
@Slf4j
public class ApiMediationServiceConfigReader {
Expand Down Expand Up @@ -147,7 +148,7 @@ public ApiMediationServiceConfig loadConfiguration(String internalConfigurationF
* while the second one provides externalization of deployment environment dependent properties.
* The externalized file has precedence over the basic one, i.e the properties values of the basic YAML file can be rewritten
* by the values of the same properties defined in the externalized configuration file.
* <p>
*
* Note: This method implementation relies on caller to set a map with API ML related System properties and
* context parameters provided by system admin. Service context parameters take precedence over system properties.
*
Expand Down Expand Up @@ -237,7 +238,7 @@ public ApiMediationServiceConfig buildConfiguration(String fileName) throws Serv
* @param fileName
* @return
* @throws ServiceDefinitionException
*/
*/
public ApiMediationServiceConfig buildConfiguration(String fileName, Map<String, String> properties) throws ServiceDefinitionException {
if (fileName == null) {
return null;
Expand Down Expand Up @@ -279,13 +280,13 @@ public Map<String, String> setApiMlServiceContext(ServletContext servletContext)

/**
* Uses {@link ApiMediationServiceConfigReader} to build {@link ApiMediationServiceConfig} configuration.
* <p>
*
* This is the most flexible API ML service configuration method using several configuration sources in the following order:
* - internal configuration file with default name service-config.yml
* - external configuration file if provided as Java system property or servlet context parameter
* - Java system properties prefixed with "apiml."
* - Servlet context parameters prefixed with "apiml."
* <p>
* - internal configuration file with default name service-config.yml
* - external configuration file if provided as Java system property or servlet context parameter
* - Java system properties prefixed with "apiml."
* - Servlet context parameters prefixed with "apiml."
*
* The internal and external service configuration is provided by YAML files. The names of of the configuration files can be set using
* Java system properties or servlet context parameters with following parameter names:
*
Expand All @@ -299,24 +300,24 @@ public Map<String, String> setApiMlServiceContext(ServletContext servletContext)
* Can be placed anywhere on a file system accessible from the service application.
* </li>
* </ul>
* <p>
*
* If the basic configuration file name is not provided, the called API ML enabler configuration loader
* will use "/service-configuration.yml" as default name.
* <p>
*
* The externalized configuration file is optional. The deployer of the service may decide not to use it. Consequently
* the deployment environment dependent configuration values can be provided as additional servlet context
* parameters with key names prefixed by "apiml.". They will be transferred to Java system properties
* and can be used to substitute corresponding service configuration properties. This approach can be used only
* for configuration properties which are tokenized in the YAML configuration file.
* <p>
*
* For example if the service developer would define/tokenize the serviceId parameter as:
* serviceId: ${apiml.serviceId}
* <p>
*
* The service deployer must define following context parameter:
* <Parameter name="apiml.serviceId" value="helloapiml" />
* <p>
*
* The value "helloapiml" will then be used as "serviceId".
* <p>
*
* This properties overwriting mechanism can be also used for the externalized configuration file.
*
* @param context
Expand Down Expand Up @@ -366,8 +367,9 @@ public ApiMediationServiceConfig loadConfiguration(ServletContext context) throw

/**
* Add/Replace all system properties prefixed with "apiml." to the apiml context map stored in ThreadLocal.
* <p>
*
* WARNING: This method could rewrite previously set Servlet context parameters
*
*/
private Map<String, String> setApiMlSystemProperties() {

Expand All @@ -386,9 +388,9 @@ private Map<String, String> setApiMlSystemProperties() {
}

/**
* Because this class is intended to be used mainly in web containers it is expected that
* the thread instances belong to a thread pool.
* We need then to clean the threadConfigurationContext before loading new configuration parameters from servlet context.
* Because this class is intended to be used mainly in web containers it is expected that
* the thread instances belong to a thread pool.
* We need then to clean the threadConfigurationContext before loading new configuration parameters from servlet context.
*/
private void initializeContextMap() {
threadConfigurationContext.remove();
Expand Down

0 comments on commit 57c36e7

Please sign in to comment.