release version 1.10.0
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime</groupId>
|
||||
<artifactId>base</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.10.0</version>
|
||||
</parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
|
||||
<artifactId>config-extensions</artifactId>
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* config-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
@ -43,9 +43,9 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* Configuration plugin providing resolving references from one config to others
|
||||
* in a form $PID_OF_OTHER_CONFIG{PROPERTY_NAME}
|
||||
* e.g. $org.ops4j.pax.url.mvn{org.ops4j.pax.url.mvn.localRepository}
|
||||
* Configuration plugin providing resolving references from one config to others in a form
|
||||
* $PID_OF_OTHER_CONFIG{PROPERTY_NAME} e.g.
|
||||
* $org.ops4j.pax.url.mvn{org.ops4j.pax.url.mvn.localRepository}
|
||||
*
|
||||
* If pid or property not found no changes are made
|
||||
*
|
||||
@ -53,59 +53,58 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
*/
|
||||
@Component(service = {ConfigurationPlugin.class}, immediate = true,
|
||||
property = {
|
||||
ConfigurationPlugin.CM_RANKING + "=100"
|
||||
, "config.plugin.id=ConfigLookupConfigurationPlugin"})
|
||||
property = {
|
||||
ConfigurationPlugin.CM_RANKING + "=100", "config.plugin.id=ConfigLookupConfigurationPlugin"})
|
||||
public class ConfigLookupConfigurationPlugin implements ConfigurationPlugin {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ConfigLookupConfigurationPlugin.class);
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
protected ConfigurationAdmin configurationAdmin;
|
||||
|
||||
@Override
|
||||
public void modifyConfiguration(ServiceReference<?> arg0, Dictionary<String, Object> properties) {
|
||||
for (Enumeration<String> keys = properties.keys(); keys.hasMoreElements(); ) {
|
||||
String key = keys.nextElement();
|
||||
Object val = properties.get(key);
|
||||
if (val instanceof String) {
|
||||
|
||||
String text = (String)val;
|
||||
String newValue = (String)val;
|
||||
Pattern pattern = Pattern.compile("\\$([^\\{\\}])+\\{.+?\\}");
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
while (matcher.find()) {
|
||||
log.debug("FOUND :: " + text.substring(matcher.start(), matcher.end()));
|
||||
String placeholder = text.substring(matcher.start(), matcher.end());
|
||||
String pid = placeholder.substring(1, placeholder.indexOf("{"));
|
||||
String propName = placeholder.substring(placeholder.indexOf("{")+1
|
||||
, placeholder.indexOf("}"));
|
||||
log.debug("PARSED :: " + pid + ":" + propName);
|
||||
Configuration conf;
|
||||
try {
|
||||
conf = configurationAdmin.getConfiguration(pid);
|
||||
if (conf != null) {
|
||||
|
||||
Dictionary<String, Object> props = conf.getProperties();
|
||||
Object value = props.get(propName);
|
||||
log.debug("VALUE :: " + placeholder + " = " + value);
|
||||
if (value != null) {
|
||||
newValue = newValue.replace(placeholder, (String)value);
|
||||
log.debug("NEW VALUE :: " + placeholder + " = " + newValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Error with pid: " + pid, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
properties.put(key, newValue);
|
||||
private static final Logger log = LoggerFactory.getLogger(ConfigLookupConfigurationPlugin.class);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
protected ConfigurationAdmin configurationAdmin;
|
||||
|
||||
@Override
|
||||
public void modifyConfiguration(ServiceReference<?> arg0, Dictionary<String, Object> properties) {
|
||||
for (Enumeration<String> keys = properties.keys(); keys.hasMoreElements();) {
|
||||
String key = keys.nextElement();
|
||||
Object val = properties.get(key);
|
||||
if (val instanceof String) {
|
||||
|
||||
String text = (String) val;
|
||||
String newValue = (String) val;
|
||||
Pattern pattern = Pattern.compile("\\$([^\\{\\}])+\\{.+?\\}");
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
while (matcher.find()) {
|
||||
log.debug("FOUND :: " + text.substring(matcher.start(), matcher.end()));
|
||||
String placeholder = text.substring(matcher.start(), matcher.end());
|
||||
String pid = placeholder.substring(1, placeholder.indexOf("{"));
|
||||
String propName = placeholder.substring(placeholder.indexOf("{") + 1, placeholder.indexOf("}"));
|
||||
log.debug("PARSED :: " + pid + ":" + propName);
|
||||
Configuration conf;
|
||||
try {
|
||||
conf = configurationAdmin.getConfiguration(pid);
|
||||
if (conf != null) {
|
||||
|
||||
Dictionary<String, Object> props = conf.getProperties();
|
||||
if (props != null) {
|
||||
Object value = props.get(propName);
|
||||
log.debug("VALUE :: " + placeholder + " = " + value);
|
||||
if (value != null) {
|
||||
newValue = newValue.replace(placeholder, (String) value);
|
||||
log.debug("NEW VALUE :: " + placeholder + " = " + newValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Error with pid: " + pid, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
properties.put(key, newValue);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* configuration-test-1
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* configuration-test-1
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* configuration-test-1
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* configuration-test-1
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* configuration-test-1
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* configuration-test-1
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
|
Reference in New Issue
Block a user