diff --git a/appserver/admingui/microprofile-console-plugin/src/main/resources/fish/payara/admingui/microprofile/Strings.properties b/appserver/admingui/microprofile-console-plugin/src/main/resources/fish/payara/admingui/microprofile/Strings.properties
index 7b521d4277a..f21e43859ba 100644
--- a/appserver/admingui/microprofile-console-plugin/src/main/resources/fish/payara/admingui/microprofile/Strings.properties
+++ b/appserver/admingui/microprofile-console-plugin/src/main/resources/fish/payara/admingui/microprofile/Strings.properties
@@ -156,6 +156,10 @@ config.property.configuration.moduleNameHelp=The name of the module when the Con
config.secretsDirectory.configuration.directory=Directory
config.secretsDirectory.configuration.directoryHelp=Full path to the directory containing configuration files.
+config.toml.configuration.enabledLabel=Enabled
+config.toml.configuration.enabledHelpText=Enable the config source, which fetches data from the specified TOML file
+config.toml.configuration.dynamicLabel=Dynamic
+config.toml.configuration.dynamicHelpText=Configure the config source dynamically, which will not require a restart
config.toml.configuration.path=Path
config.toml.configuration.pathHelp=Full path to the TOML configuration file.
config.toml.configuration.depth=Depth
diff --git a/appserver/admingui/microprofile-console-plugin/src/main/resources/microprofile/specs/configAPI/tomlConfiguration.jsf b/appserver/admingui/microprofile-console-plugin/src/main/resources/microprofile/specs/configAPI/tomlConfiguration.jsf
index 9d5765d585a..0985b43d57c 100644
--- a/appserver/admingui/microprofile-console-plugin/src/main/resources/microprofile/specs/configAPI/tomlConfiguration.jsf
+++ b/appserver/admingui/microprofile-console-plugin/src/main/resources/microprofile/specs/configAPI/tomlConfiguration.jsf
@@ -53,13 +53,20 @@
getRequestValue(key="configName" value="#{pageSession.configName}");
setPageSessionAttribute(key="MICROPROFILE_CONFIG_URL",
value="#{sessionScope.REST_URL}/configs/config/#{pageSession.configName}/microprofile-config");
- gf.restRequest(endpoint="#{pageSession.MICROPROFILE_CONFIG_URL}/get-toml-configuration?target=#{pageSession.configName}"
+ gf.restRequest(endpoint="#{pageSession.MICROPROFILE_CONFIG_URL}/get-toml-config-source-configuration?target=#{pageSession.configName}"
method="GET" result="#{requestScope.resp}");
setPageSessionAttribute(key="valueMap",
- value="#{requestScope.resp.data.extraProperties.toml}");
+ value="#{requestScope.resp.data.extraProperties.configSourceConfiguration}");
mapPut(map="#{pageSession.valueMap}" key="target" value="#{pageSession.configName}");
- />
+
+ setPageSessionAttribute(key="convertToFalseList", value={"enabled"});
+
+ if (#{pageSession.valueMap['enabled']}=true) {
+ setPageSessionAttribute(key="enabledSelected", value="true");
+ }
+ setPageSessionAttribute(key="dynamic", value="true");
+ />
@@ -75,9 +82,11 @@
onClick="if (guiValidate('#{reqMsg}','#{reqInt}','#{reqPort}'))
submitAndDisable(this, '$resource{i18n.button.Processing}'); return false;" >
@@ -86,17 +95,29 @@
#include "/common/shared/configNameSection.inc"
+
+
+
+
+
+
-
+
-
+
diff --git a/appserver/packager/appserver-core/pom.xml b/appserver/packager/appserver-core/pom.xml
index f710b649acc..89e2a05d53a 100644
--- a/appserver/packager/appserver-core/pom.xml
+++ b/appserver/packager/appserver-core/pom.xml
@@ -277,7 +277,7 @@
fish.payara.server.internal.packager
tomlj-repackaged
- 6.2024.10-SNAPSHOT
+ ${project.version}
diff --git a/appserver/packager/external/tomlj-repackaged/pom.xml b/appserver/packager/external/tomlj-repackaged/pom.xml
index 76bcdb02a75..08a19c8d003 100644
--- a/appserver/packager/external/tomlj-repackaged/pom.xml
+++ b/appserver/packager/external/tomlj-repackaged/pom.xml
@@ -54,6 +54,10 @@
tomlj repackaged as a module
jar
+
+ 1.1.1
+
+
@@ -105,6 +109,7 @@
org.tomlj
tomlj
+ ${tomlj.version}
org.antlr
diff --git a/appserver/payara-appserver-modules/microprofile/config-extensions/pom.xml b/appserver/payara-appserver-modules/microprofile/config-extensions/pom.xml
index ad8f7a33973..9ff3a1d5fc7 100644
--- a/appserver/payara-appserver-modules/microprofile/config-extensions/pom.xml
+++ b/appserver/payara-appserver-modules/microprofile/config-extensions/pom.xml
@@ -2,7 +2,7 @@
diff --git a/nucleus/payara-modules/nucleus-microprofile/config-service/src/main/java/fish/payara/nucleus/microprofile/config/source/TOMLConfigSource.java b/appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/TOMLConfigSource.java
similarity index 85%
rename from nucleus/payara-modules/nucleus-microprofile/config-service/src/main/java/fish/payara/nucleus/microprofile/config/source/TOMLConfigSource.java
rename to appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/TOMLConfigSource.java
index 57e58b98b90..8357678ab48 100644
--- a/nucleus/payara-modules/nucleus-microprofile/config-service/src/main/java/fish/payara/nucleus/microprofile/config/source/TOMLConfigSource.java
+++ b/appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/TOMLConfigSource.java
@@ -37,8 +37,12 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
-package fish.payara.nucleus.microprofile.config.source;
+package fish.payara.microprofile.config.extensions.toml;
+import fish.payara.nucleus.microprofile.config.source.extension.ConfiguredExtensionConfigSource;
+import fish.payara.nucleus.microprofile.config.spi.MicroprofileConfigConfiguration;
+import jakarta.inject.Inject;
+import org.jvnet.hk2.annotations.Service;
import org.tomlj.Toml;
import org.tomlj.TomlArray;
import org.tomlj.TomlParseResult;
@@ -54,12 +58,15 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-public class TOMLConfigSource extends PayaraConfigSource {
+@Service(name = "toml-config-source")
+public class TOMLConfigSource extends ConfiguredExtensionConfigSource {
private static final Logger LOGGER = Logger.getLogger(TOMLConfigSource.class.getName());
private final Map properties = new ConcurrentHashMap<>();
private long lastModified;
+ @Inject
+ MicroprofileConfigConfiguration mpConfig;
@Override
public String getValue(String s) {
@@ -68,21 +75,17 @@ public String getValue(String s) {
@Override
public String getName() {
- return "TOML";
+ return "toml";
}
@Override
public int getOrdinal() {
- String storedOrdinal = getValue("config_ordinal");
- if (storedOrdinal != null) {
- return Integer.parseInt(storedOrdinal);
- }
- return Integer.parseInt(configService.getMPConfig().getTomlOrdinality());
+ return Integer.parseInt(mpConfig.getTomlOrdinality());
}
@Override
public Map getProperties() {
- Path tomlFilePath = getTomlFilePath();
+ Path tomlFilePath = getFilePath();
if (tomlFilePath == null) {
return properties;
}
@@ -99,7 +102,7 @@ public Map getProperties() {
LOGGER.log(Level.WARNING, "Error parsing TOML file: {0}", tomlParseResult.errors().toString());
return properties;
}
- flattenToml(tomlParseResult, "", properties, 0, Integer.parseInt(configService.getMPConfig().getTomlDepth()));
+ flattenToml(tomlParseResult, "", properties, 0, Integer.parseInt(configuration.getDepth()));
} catch (IOException e) {
throw new RuntimeException(e);
@@ -112,8 +115,23 @@ public Set getPropertyNames() {
return getProperties().keySet();
}
- private Path getTomlFilePath() {
- String path = configService.getMPConfig().getTomlPath();
+ @Override
+ public boolean setValue(String name, String value) {
+ return false;
+ }
+
+ @Override
+ public boolean deleteValue(String name) {
+ return false;
+ }
+
+ @Override
+ public String getSource() {
+ return "toml";
+ }
+
+ private Path getFilePath() {
+ String path = configuration.getPath();
if (path == null || path.isEmpty()) {
return null;
}
diff --git a/appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/TOMLConfigSourceConfiguration.java b/appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/TOMLConfigSourceConfiguration.java
new file mode 100644
index 00000000000..864007326bd
--- /dev/null
+++ b/appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/TOMLConfigSourceConfiguration.java
@@ -0,0 +1,18 @@
+package fish.payara.microprofile.config.extensions.toml;
+
+import fish.payara.nucleus.microprofile.config.spi.ConfigSourceConfiguration;
+import org.jvnet.hk2.config.Attribute;
+import org.jvnet.hk2.config.Configured;
+
+@Configured(name = "toml-config-source-configuration")
+
+public interface TOMLConfigSourceConfiguration extends ConfigSourceConfiguration {
+
+ @Attribute(required = true)
+ String getPath();
+ void setPath(String tomlPath);
+
+ @Attribute(required = true, dataType = Integer.class)
+ String getDepth();
+ void setDepth(String depth);
+}
diff --git a/nucleus/payara-modules/nucleus-microprofile/config-service/src/main/java/fish/payara/nucleus/microprofile/config/admin/GetTOMLConfiguration.java b/appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/admin/GetTOMLConfigurationCommand.java
similarity index 55%
rename from nucleus/payara-modules/nucleus-microprofile/config-service/src/main/java/fish/payara/nucleus/microprofile/config/admin/GetTOMLConfiguration.java
rename to appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/admin/GetTOMLConfigurationCommand.java
index 496ab661be8..64580cc2151 100644
--- a/nucleus/payara-modules/nucleus-microprofile/config-service/src/main/java/fish/payara/nucleus/microprofile/config/admin/GetTOMLConfiguration.java
+++ b/appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/admin/GetTOMLConfigurationCommand.java
@@ -37,28 +37,22 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
-package fish.payara.nucleus.microprofile.config.admin;
+package fish.payara.microprofile.config.extensions.toml.admin;
-import com.sun.enterprise.config.serverbeans.Config;
-import com.sun.enterprise.util.ColumnFormatter;
+import fish.payara.microprofile.config.extensions.toml.TOMLConfigSourceConfiguration;
+import fish.payara.nucleus.microprofile.config.source.extension.BaseGetConfigSourceConfigurationCommand;
import fish.payara.nucleus.microprofile.config.spi.MicroprofileConfigConfiguration;
-import jakarta.inject.Inject;
-import org.glassfish.api.ActionReport;
-import org.glassfish.api.Param;
-import org.glassfish.api.admin.AdminCommand;
-import org.glassfish.api.admin.AdminCommandContext;
+import org.glassfish.api.admin.CommandLock;
import org.glassfish.api.admin.ExecuteOn;
import org.glassfish.api.admin.RestEndpoint;
import org.glassfish.api.admin.RestEndpoints;
import org.glassfish.api.admin.RuntimeType;
+import org.glassfish.config.support.CommandTarget;
import org.glassfish.config.support.TargetType;
import org.glassfish.hk2.api.PerLookup;
-import org.glassfish.internal.api.Target;
import org.jvnet.hk2.annotations.Service;
-import java.util.HashMap;
import java.util.Map;
-import java.util.Properties;
/**
* asAdmin command to the get the configuration for the TOML Config Source
@@ -66,54 +60,27 @@
* @since 6.2024.11
* @author Kalin Chan (Payara Foundation)
*/
-@Service(name = "get-toml-configuration")
+@Service(name = "get-toml-config-source-configuration")
@PerLookup
-@ExecuteOn(RuntimeType.DAS)
-@TargetType()
+@CommandLock(CommandLock.LockType.NONE)
+@ExecuteOn(value = {RuntimeType.DAS, RuntimeType.INSTANCE})
+@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG, CommandTarget.DEPLOYMENT_GROUP})
@RestEndpoints({
@RestEndpoint(configBean = MicroprofileConfigConfiguration.class,
opType = RestEndpoint.OpType.GET,
- path = "get-toml-configuration",
- description = "Gets the configuration for the TOML Config Source")
+ path = "get-toml-config-source-configuration",
+ description = "List TOML Config Source Configuration")
})
-public class GetTOMLConfiguration implements AdminCommand {
-
- @Param(optional = true, defaultValue = "server")
- String target;
-
- @Inject
- Target targetUtil;
-
- private final String[] OUTPUT_HEADERS = {"Path", "Depth"};
+public class GetTOMLConfigurationCommand extends BaseGetConfigSourceConfigurationCommand {
@Override
- public void execute(AdminCommandContext context) {
- final ActionReport actionReport = context.getActionReport();
+ protected Map getConfigSourceConfiguration(TOMLConfigSourceConfiguration configuration) {
+ Map config = super.getConfigSourceConfiguration(configuration);
- final Config targetConfig = targetUtil.getConfig(target);
- if (targetConfig == null) {
- actionReport.setMessage("No such config named: " + target);
- actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
- return;
+ if (configuration != null) {
+ config.put("Path", configuration.getPath());
+ config.put("Depth", configuration.getDepth());
}
-
- MicroprofileConfigConfiguration microprofileConfigConfiguration = targetConfig
- .getExtensionByType(MicroprofileConfigConfiguration.class);
-
- ColumnFormatter columnFormatter = new ColumnFormatter(OUTPUT_HEADERS);
- Object[] outputValues = {
- microprofileConfigConfiguration.getTomlPath(),
- microprofileConfigConfiguration.getTomlDepth()
- };
- columnFormatter.addRow(outputValues);
- actionReport.appendMessage(columnFormatter.toString());
-
- Map extraPropertiesMap = new HashMap<>();
- extraPropertiesMap.put("path", microprofileConfigConfiguration.getTomlPath());
- extraPropertiesMap.put("depth", microprofileConfigConfiguration.getTomlDepth());
-
- Properties extraProperties = new Properties();
- extraProperties.put("toml", extraPropertiesMap);
- actionReport.setExtraProperties(extraProperties);
+ return config;
}
}
diff --git a/nucleus/payara-modules/nucleus-microprofile/config-service/src/main/java/fish/payara/nucleus/microprofile/config/admin/SetTOMLConfiguration.java b/appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/admin/SetTOMLConfigurationCommand.java
similarity index 58%
rename from nucleus/payara-modules/nucleus-microprofile/config-service/src/main/java/fish/payara/nucleus/microprofile/config/admin/SetTOMLConfiguration.java
rename to appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/admin/SetTOMLConfigurationCommand.java
index 9dde2b7e1df..4143cf4527e 100644
--- a/nucleus/payara-modules/nucleus-microprofile/config-service/src/main/java/fish/payara/nucleus/microprofile/config/admin/SetTOMLConfiguration.java
+++ b/appserver/payara-appserver-modules/microprofile/config-extensions/src/main/java/fish/payara/microprofile/config/extensions/toml/admin/SetTOMLConfigurationCommand.java
@@ -37,31 +37,27 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
-package fish.payara.nucleus.microprofile.config.admin;
+package fish.payara.microprofile.config.extensions.toml.admin;
-import com.sun.enterprise.config.serverbeans.Config;
+import fish.payara.microprofile.config.extensions.toml.TOMLConfigSourceConfiguration;
+import fish.payara.nucleus.microprofile.config.source.extension.BaseSetConfigSourceConfigurationCommand;
import fish.payara.nucleus.microprofile.config.spi.MicroprofileConfigConfiguration;
-import jakarta.inject.Inject;
import org.glassfish.api.ActionReport;
import org.glassfish.api.Param;
-import org.glassfish.api.admin.AdminCommand;
-import org.glassfish.api.admin.AdminCommandContext;
+import org.glassfish.api.admin.CommandLock;
import org.glassfish.api.admin.ExecuteOn;
import org.glassfish.api.admin.RestEndpoint;
import org.glassfish.api.admin.RestEndpoints;
-import org.glassfish.api.admin.ServerEnvironment;
+import org.glassfish.api.admin.RuntimeType;
+import org.glassfish.config.support.CommandTarget;
import org.glassfish.config.support.TargetType;
import org.glassfish.hk2.api.PerLookup;
-import org.glassfish.internal.api.Target;
import org.jvnet.hk2.annotations.Service;
-import org.jvnet.hk2.config.ConfigSupport;
-import org.jvnet.hk2.config.TransactionFailure;
+import java.beans.PropertyVetoException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* asAdmin command to the set the configuration for the TOML Config Source
@@ -69,63 +65,55 @@
* @since 6.2024.11
* @author Kalin Chan (Payara Foundation)
*/
-@Service(name = "set-toml-configuration")
+@Service(name = "set-toml-config-source-configuration")
@PerLookup
-@ExecuteOn()
-@TargetType()
+@CommandLock(CommandLock.LockType.NONE)
+@ExecuteOn({RuntimeType.DAS, RuntimeType.INSTANCE})
+@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG, CommandTarget.DEPLOYMENT_GROUP})
@RestEndpoints({
@RestEndpoint(configBean = MicroprofileConfigConfiguration.class,
opType = RestEndpoint.OpType.POST,
- path = "set-toml-configuration",
- description = "Sets the configuration for the TOML Config Source")
+ path = "set-toml-config-source-configuration",
+ description = "Configures TOML Config Source")
})
-public class SetTOMLConfiguration implements AdminCommand {
+public class SetTOMLConfigurationCommand extends BaseSetConfigSourceConfigurationCommand {
@Param
- String path;
+ private String path;
+
+ @Param
+ private int depth;
- @Param(defaultValue = "5")
- int depth;
-
- @Param(optional = true, defaultValue = "server")
- String target;
-
- @Inject
- Target targetUtil;
-
- @Inject
- ServerEnvironment env;
@Override
- public void execute(AdminCommandContext context) {
+ protected void applyValues(ActionReport report, TOMLConfigSourceConfiguration configuration) throws PropertyVetoException {
// do validation
Path tomlPath = Paths.get(path);
if (!Files.exists(tomlPath) || !Files.isReadable(tomlPath)) {
- // ok try relative to the server root
- context.getActionReport().appendMessage("Could not find readable file at " + tomlPath + "\n");
- Path instanceRoot = env.getInstanceRoot().toPath();
+ // try relative to the server root
+ report.appendMessage("Could not find readable file at " + tomlPath + "\n");
+ if (tomlPath.isAbsolute()) {
+ report.setActionExitCode(ActionReport.ExitCode.FAILURE);
+ return;
+ }
+ Path instanceRoot = server.getInstanceRoot().toPath();
Path relative = Paths.get(instanceRoot.toString(), path);
if (!Files.exists(relative) || !Files.isReadable(relative)) {
- context.getActionReport().appendMessage("Could not find readable file at " + relative + "\n");
- context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
+ report.appendMessage("Could not find readable file at " + relative + "\n");
+ report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
tomlPath = relative;
}
- context.getActionReport().appendMessage("Using readable file at " + tomlPath + "\n");
+ report.appendMessage("Using readable file at " + tomlPath + "\n");
+
+ super.applyValues(report, configuration);
+ if (depth > 0) {
+ configuration.setDepth(String.valueOf(depth));
+ }
- Config configVal = targetUtil.getConfig(target);
- MicroprofileConfigConfiguration serviceConfig = configVal.getExtensionByType(MicroprofileConfigConfiguration.class);
- try {
- final Path toSet = tomlPath;
- ConfigSupport.apply(t -> {
- t.setTomlPath(toSet.toString());
- t.setTomlDepth(String.valueOf(depth));
- return null;
- }, serviceConfig);
- } catch (TransactionFailure ex) {
- Logger.getLogger(SetTOMLConfiguration.class.getName()).log(Level.SEVERE, "Could not set configuration", ex);
- context.getActionReport().failure(Logger.getLogger(this.getClass().getName()), "Could not set configuration", ex);
+ if (path != null) {
+ configuration.setPath(String.valueOf(tomlPath));
}
}
diff --git a/core/pom.xml b/core/pom.xml
index a64228e416a..f20a77338f6 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -138,7 +138,6 @@
2.0.2
1.11
1.0
- 1.1.1
3.30.2-GA
2.1.0
diff --git a/nucleus/payara-modules/nucleus-microprofile/config-service/pom.xml b/nucleus/payara-modules/nucleus-microprofile/config-service/pom.xml
index 4148d2716e5..18ba82ffefa 100644
--- a/nucleus/payara-modules/nucleus-microprofile/config-service/pom.xml
+++ b/nucleus/payara-modules/nucleus-microprofile/config-service/pom.xml
@@ -2,7 +2,7 @@