Skip to content

Commit ea7f763

Browse files
committed
[refactor] Use constants for eXist-db System Properties
1 parent 134a8ae commit ea7f763

File tree

15 files changed

+33
-27
lines changed

15 files changed

+33
-27
lines changed

exist-core/src/main/java/org/exist/ExistSystemProperties.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
@ThreadSafe
3838
public class ExistSystemProperties {
3939

40+
public static final String PROP_PRODUCT_NAME = "product-name";
41+
public static final String PROP_PRODUCT_VERSION = "product-version";
42+
public static final String PROP_PRODUCT_BUILD = "product-build";
43+
public static final String PROP_GIT_BRANCH = "git-branch";
44+
public static final String PROP_GIT_COMMIT = "git-commit";
45+
4046
private static final Logger LOG = LogManager.getLogger(ExistSystemProperties.class);
4147
private static final ExistSystemProperties instance = new ExistSystemProperties();
4248

exist-core/src/main/java/org/exist/Version.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public final class Version {
3737
static {
3838

3939
final ExistSystemProperties existSystemProperties = ExistSystemProperties.getInstance();
40-
NAME = existSystemProperties.getExistSystemProperty("product-name", "eXist");
41-
VERSION = existSystemProperties.getExistSystemProperty("product-version");
42-
BUILD = existSystemProperties.getExistSystemProperty("product-build");
43-
GIT_BRANCH = existSystemProperties.getExistSystemProperty("git-branch");
44-
GIT_COMMIT = existSystemProperties.getExistSystemProperty("git-commit");
40+
NAME = existSystemProperties.getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_NAME, "eXist");
41+
VERSION = existSystemProperties.getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_VERSION);
42+
BUILD = existSystemProperties.getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_BUILD);
43+
GIT_BRANCH = existSystemProperties.getExistSystemProperty(ExistSystemProperties.PROP_GIT_BRANCH);
44+
GIT_COMMIT = existSystemProperties.getExistSystemProperty(ExistSystemProperties.PROP_GIT_COMMIT);
4545
}
4646

4747
public static String getProductName() {

exist-core/src/main/java/org/exist/client/ClientFrame.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ protected static Properties getLoginData(final Properties props) {
17241724

17251725
final ConnectionDialog connectionDialog = new ConnectionDialog(null, true, defaultConnectionSettings, Boolean.parseBoolean(props.getProperty(InteractiveClient.LOCAL_MODE, InteractiveClient.LOCAL_MODE_DEFAULT)), Boolean.parseBoolean(props.getProperty(InteractiveClient.NO_EMBED_MODE, InteractiveClient.NO_EMBED_MODE_DEFAULT)));
17261726

1727-
connectionDialog.setTitle(ExistSystemProperties.getInstance().getExistSystemProperty("product-name", "eXist-db") + " " + ExistSystemProperties.getInstance().getExistSystemProperty("product-version", "unknown") + " Database Login");
1727+
connectionDialog.setTitle(ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_NAME, "eXist-db") + " " + ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_VERSION, "unknown") + " Database Login");
17281728

17291729
connectionDialog.addDialogCompleteWithResponseCallback(connection -> {
17301730
properties.setProperty(InteractiveClient.USER, connection.getUsername());

exist-core/src/main/java/org/exist/client/InteractiveClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,12 +2516,12 @@ public void printNotice() {
25162516

25172517
public String getNotice() {
25182518
final StringBuilder builder = new StringBuilder();
2519-
builder.append(ExistSystemProperties.getInstance().getExistSystemProperty("product-name", "eXist-db"));
2519+
builder.append(ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_NAME, "eXist-db"));
25202520
builder.append(" version ");
2521-
builder.append(ExistSystemProperties.getInstance().getExistSystemProperty("product-version", "unknown"));
2522-
if (!"".equals(ExistSystemProperties.getInstance().getExistSystemProperty("git-commit", ""))) {
2521+
builder.append(ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_VERSION, "unknown"));
2522+
if (!"".equals(ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_GIT_COMMIT, ""))) {
25232523
builder.append(" (");
2524-
builder.append(ExistSystemProperties.getInstance().getExistSystemProperty("git-commit", "(unknown Git commit ID)"));
2524+
builder.append(ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_GIT_COMMIT, "(unknown Git commit ID)"));
25252525
builder.append(")");
25262526
}
25272527
builder.append(", Copyright (C) 2001-");

exist-core/src/main/java/org/exist/jetty/JettyStart.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ public synchronized void run(final String[] args, final Observer observer) {
190190

191191
logger.info("Running as user '{}'", System.getProperty("user.name", "(unknown user.name)"));
192192
logger.info("[eXist Home : {}]", System.getProperty("exist.home", "unknown"));
193-
logger.info("[eXist Version : {}]", ExistSystemProperties.getInstance().getExistSystemProperty("product-version", "unknown"));
194-
logger.info("[eXist Build : {}]", ExistSystemProperties.getInstance().getExistSystemProperty("product-build", "unknown"));
195-
logger.info("[Git commit : {}]", ExistSystemProperties.getInstance().getExistSystemProperty("git-commit", "unknown"));
193+
logger.info("[eXist Version : {}]", ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_VERSION, "unknown"));
194+
logger.info("[eXist Build : {}]", ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_BUILD, "unknown"));
195+
logger.info("[Git commit : {}]", ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_GIT_COMMIT, "unknown"));
196196

197197
logger.info("[Operating System : {} {} {}]", System.getProperty("os.name"), System.getProperty("os.version"), System.getProperty("os.arch"));
198198
logger.info("[log4j.configurationFile : {}]", System.getProperty("log4j.configurationFile"));

exist-core/src/main/java/org/exist/launcher/SplashScreen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public SplashScreen(Launcher launcher) {
6969
final ExistSystemProperties sysProps = ExistSystemProperties.getInstance();
7070
final StringBuilder builder = new StringBuilder();
7171
builder.append("Version ");
72-
builder.append(sysProps.getExistSystemProperty("product-version", "unknown"));
73-
final String gitCommit = sysProps.getExistSystemProperty("git-commit");
72+
builder.append(sysProps.getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_VERSION, "unknown"));
73+
final String gitCommit = sysProps.getExistSystemProperty(ExistSystemProperties.PROP_GIT_COMMIT);
7474
if (gitCommit != null && !gitCommit.isEmpty()) {
7575
builder.append(" (");
7676
builder.append(gitCommit, 0, Math.min(7, gitCommit.length()));

exist-core/src/main/java/org/exist/management/impl/SystemInfo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ public class SystemInfo implements SystemInfoMXBean {
3838

3939
@Override
4040
public String getProductName() {
41-
return ExistSystemProperties.getInstance().getExistSystemProperty("product-name","eXist");
41+
return ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_NAME,"eXist");
4242
}
4343

4444
@Override
4545
public String getProductVersion() {
46-
return ExistSystemProperties.getInstance().getExistSystemProperty("product-version","unknown");
46+
return ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_VERSION,"unknown");
4747
}
4848

4949
@Override
5050
public String getProductBuild() {
51-
return ExistSystemProperties.getInstance().getExistSystemProperty("product-build","unknown");
51+
return ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_BUILD,"unknown");
5252
}
5353

5454
@Override
5555
public String getGitCommit() {
56-
return ExistSystemProperties.getInstance().getExistSystemProperty("git-commit", "unknown Git commit ID");
56+
return ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_GIT_COMMIT, "unknown Git commit ID");
5757
}
5858

5959
@Override

exist-core/src/main/java/org/exist/repo/ClasspathHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private static void scanPackages(BrokerPool pool, Classpath classpath) {
108108
private static boolean isCompatible(final Package pkg) throws PackageException {
109109
// determine the eXist-db version this package is compatible with
110110
final Collection<ProcessorDependency> processorDeps = pkg.getProcessorDeps();
111-
final String procVersion = ExistSystemProperties.getInstance().getExistSystemProperty("product-version", "1.0");
111+
final String procVersion = ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_VERSION, "1.0");
112112
PackageLoader.Version requiresExistVersion = null;
113113
for (final ProcessorDependency dependency: processorDeps) {
114114
if (Deployment.PROCESSOR_NAME.equals(dependency.getProcessor())) {

exist-core/src/main/java/org/exist/repo/Deployment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public Optional<String> installAndDeploy(final DBBroker broker, final Txn transa
286286
}
287287

288288
private void checkProcessorVersion(final PackageLoader.Version version) throws PackageException {
289-
final String procVersion = ExistSystemProperties.getInstance().getExistSystemProperty("product-version", "1.0");
289+
final String procVersion = ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_VERSION, "1.0");
290290

291291
final DependencyVersion depVersion = version.getDependencyVersion();
292292
if (!depVersion.isCompatible(procVersion)) {

exist-core/src/main/java/org/exist/webstart/JnlpWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void writeJnlpXML(JnlpJarFiles jnlpFiles, HttpServletRequest request,
101101
writer.writeAttribute("codebase", codeBase);
102102
writer.writeAttribute("href", "exist.jnlp");
103103

104-
String version = ExistSystemProperties.getInstance().getExistSystemProperty("product-version", null);
104+
String version = ExistSystemProperties.getInstance().getExistSystemProperty(ExistSystemProperties.PROP_PRODUCT_VERSION, null);
105105
if(version!=null){
106106
writer.writeAttribute("version", version);
107107
}

0 commit comments

Comments
 (0)