Skip to content

Commit a1b6475

Browse files
committed
[feature] Add a '-a' and '--no-auto-deploy' argument to the Java Admin Client and Jetty Server startup so that Auto Deployment of EXPath packages can be disabled from the CLI
1 parent fc6c968 commit a1b6475

4 files changed

Lines changed: 43 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ public class CommandlineOptions {
108108
.description("do not make embedded mode available")
109109
.defaultValue(false)
110110
.build();
111+
private static final Argument<Boolean> noAutoDeployArg = optionArgument("-a", "--no-auto-deploy")
112+
.description("Disable auto-deployment of EXPath Packages")
113+
.defaultValue(false)
114+
.build();
111115

112116

113117
/* gui arguments */
@@ -193,7 +197,7 @@ private static Optional<XmldbURI> optUri(final ParsedArguments parsedArguments,
193197

194198
public static CommandlineOptions parse(final String[] args) throws ArgumentException, URISyntaxException {
195199
final ParsedArguments arguments = CommandLineParser
196-
.withArguments(userArg, passwordArg, useSslArg, embeddedArg, embeddedConfigArg, noEmbeddedModeArg)
200+
.withArguments(userArg, passwordArg, useSslArg, embeddedArg, embeddedConfigArg, noEmbeddedModeArg, noAutoDeployArg)
197201
.andArguments(noGuiArg, guiQueryDialogArg)
198202
.andArguments(mkColArg, rmColArg, setColArg)
199203
.andArguments(parseDocsArg, getDocArg, rmDocArg)
@@ -215,6 +219,7 @@ public static CommandlineOptions parse(final String[] args) throws ArgumentExcep
215219
final boolean embedded = getBool(arguments, embeddedArg);
216220
final Optional<Path> embeddedConfig = getPathOpt(arguments, embeddedConfigArg);
217221
final boolean noEmbeddedMode = getBool(arguments, noEmbeddedModeArg);
222+
final boolean noAutoDeploy = getBool(arguments, noAutoDeployArg);
218223

219224
final boolean startGUI = !getBool(arguments, noGuiArg);
220225
final boolean openQueryGUI = getBool(arguments, guiQueryDialogArg);
@@ -259,6 +264,7 @@ public static CommandlineOptions parse(final String[] args) throws ArgumentExcep
259264
embedded,
260265
embeddedConfig,
261266
noEmbeddedMode,
267+
noAutoDeploy,
262268
startGUI,
263269
openQueryGUI,
264270
mkCol,
@@ -278,7 +284,7 @@ public static CommandlineOptions parse(final String[] args) throws ArgumentExcep
278284
);
279285
}
280286

281-
public CommandlineOptions(boolean quiet, boolean verbose, Optional<Path> outputFile, Map<String, String> options, Optional<String> username, Optional<String> password, boolean useSSL, boolean embedded, Optional<Path> embeddedConfig, boolean noEmbeddedMode, boolean startGUI, boolean openQueryGUI, Optional<XmldbURI> mkCol, Optional<XmldbURI> rmCol, Optional<XmldbURI> setCol, List<Path> parseDocs, Optional<XmldbURI> getDoc, Optional<String> rmDoc, Optional<String> xpath, List<Path> queryFiles, Optional<Integer> howManyResults, Optional<Path> traceQueriesFile, Optional<String> setDoc, Optional<Path> xupdateFile, boolean reindex, boolean reindexRecurse) {
287+
public CommandlineOptions(boolean quiet, boolean verbose, Optional<Path> outputFile, Map<String, String> options, Optional<String> username, Optional<String> password, boolean useSSL, boolean embedded, Optional<Path> embeddedConfig, boolean noEmbeddedMode, boolean noAutoDeploy, boolean startGUI, boolean openQueryGUI, Optional<XmldbURI> mkCol, Optional<XmldbURI> rmCol, Optional<XmldbURI> setCol, List<Path> parseDocs, Optional<XmldbURI> getDoc, Optional<String> rmDoc, Optional<String> xpath, List<Path> queryFiles, Optional<Integer> howManyResults, Optional<Path> traceQueriesFile, Optional<String> setDoc, Optional<Path> xupdateFile, boolean reindex, boolean reindexRecurse) {
282288
this.quiet = quiet;
283289
this.verbose = verbose;
284290
this.outputFile = outputFile;
@@ -289,6 +295,7 @@ public CommandlineOptions(boolean quiet, boolean verbose, Optional<Path> outputF
289295
this.embedded = embedded;
290296
this.embeddedConfig = embeddedConfig;
291297
this.noEmbeddedMode = noEmbeddedMode;
298+
this.noAutoDeploy = noAutoDeploy;
292299
this.startGUI = startGUI;
293300
this.openQueryGUI = openQueryGUI;
294301
this.mkCol = mkCol;
@@ -318,6 +325,7 @@ public CommandlineOptions(boolean quiet, boolean verbose, Optional<Path> outputF
318325
final boolean embedded;
319326
final Optional<Path> embeddedConfig;
320327
final boolean noEmbeddedMode;
328+
final boolean noAutoDeploy;
321329

322330
final boolean startGUI;
323331
final boolean openQueryGUI;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public class InteractiveClient {
161161
public static final String CREATE_DATABASE = "create-database";
162162
public static final String LOCAL_MODE = "local-mode-opt";
163163
public static final String NO_EMBED_MODE = "NO_EMBED_MODE";
164+
public static final String NO_AUTO_DEPLOY = "no-autodeploy";
164165

165166
// values
166167
protected static final String EDIT_CMD = "emacsclient -t $file";
@@ -169,6 +170,7 @@ public class InteractiveClient {
169170
protected static final String SSL_ENABLE_DEFAULT = "FALSE";
170171
protected static final String LOCAL_MODE_DEFAULT = "FALSE";
171172
protected static final String NO_EMBED_MODE_DEFAULT = "FALSE";
173+
protected static final String NO_AUTO_DEPLOY_DEFAULT = "FALSE";
172174
protected static final String USER_DEFAULT = SecurityManager.DBA_USER;
173175
protected static final String DRIVER_IMPL_CLASS = "org.exist.xmldb.DatabaseImpl";
174176

@@ -188,6 +190,7 @@ public class InteractiveClient {
188190
DEFAULT_PROPERTIES.setProperty(PERMISSIONS, "false");
189191
DEFAULT_PROPERTIES.setProperty(EXPAND_XINCLUDES, "true");
190192
DEFAULT_PROPERTIES.setProperty(SSL_ENABLE, SSL_ENABLE_DEFAULT);
193+
DEFAULT_PROPERTIES.setProperty(NO_AUTO_DEPLOY, NO_AUTO_DEPLOY_DEFAULT);
191194
}
192195
protected static final int[] COL_SIZES = new int[]{10, 10, 10, -1};
193196

@@ -334,6 +337,7 @@ protected void connect() throws Exception {
334337
// Configure database
335338
database.setProperty(CREATE_DATABASE, "true");
336339
database.setProperty(SSL_ENABLE, properties.getProperty(SSL_ENABLE));
340+
database.setProperty(NO_AUTO_DEPLOY, properties.getProperty(NO_AUTO_DEPLOY));
337341

338342
// secure empty configuration
339343
final String configProp = properties.getProperty(InteractiveClient.CONFIGURATION);
@@ -1882,6 +1886,9 @@ protected void setPropertiesFromCommandLine(final CommandlineOptions options, fi
18821886
if (options.noEmbeddedMode) {
18831887
props.setProperty(NO_EMBED_MODE, "TRUE");
18841888
}
1889+
if (options.noAutoDeploy) {
1890+
props.setProperty(NO_AUTO_DEPLOY, "TRUE");
1891+
}
18851892
}
18861893

18871894
/**

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import se.softhouse.jargo.Argument;
7575
import se.softhouse.jargo.ArgumentException;
7676
import se.softhouse.jargo.CommandLineParser;
77+
import se.softhouse.jargo.ParsedArguments;
7778

7879
import java.io.IOException;
7980
import java.io.LineNumberReader;
@@ -85,9 +86,10 @@
8586
import java.util.*;
8687
import java.util.stream.Collectors;
8788

89+
import static org.exist.repo.AutoDeploymentTrigger.AUTODEPLOY_PROPERTY;
90+
import static org.exist.util.ArgumentUtil.getBool;
8891
import static org.exist.util.ThreadUtils.newGlobalThread;
89-
import static se.softhouse.jargo.Arguments.helpArgument;
90-
import static se.softhouse.jargo.Arguments.stringArgument;
92+
import static se.softhouse.jargo.Arguments.*;
9193

9294
/**
9395
* This class provides a main method to start Jetty with eXist. It registers shutdown
@@ -119,6 +121,10 @@ public class JettyStart extends Observable implements LifeCycle.Listener {
119121
private static final Argument<String> existConfigFilePath = stringArgument()
120122
.description("Path to Elemental Config File")
121123
.build();
124+
private static final Argument<Boolean> noAutoDeployArg = optionArgument("-a", "--no-auto-deploy")
125+
.description("Disable auto-deployment of EXPath Packages")
126+
.defaultValue(false)
127+
.build();
122128
private static final Argument<?> helpArg = helpArgument("-h", "--help");
123129

124130
@GuardedBy("this") private int status = STATUS_STOPPED;
@@ -130,12 +136,17 @@ public static void main(final String[] args) {
130136
try {
131137
CompatibleJavaVersionCheck.checkForCompatibleJavaVersion();
132138

133-
CommandLineParser
139+
final ParsedArguments arguments = CommandLineParser
134140
.withArguments(jettyConfigFilePath, existConfigFilePath)
135-
.andArguments(helpArg)
141+
.andArguments(noAutoDeployArg, helpArg)
136142
.programName("startup" + (OSUtil.IS_WINDOWS ? ".bat" : ".sh"))
137143
.parse(args);
138144

145+
final boolean noAutoDeploy = getBool(arguments, noAutoDeployArg);
146+
if (noAutoDeploy) {
147+
System.setProperty(AUTODEPLOY_PROPERTY, "off");
148+
}
149+
139150
} catch (final StartException e) {
140151
if (e.getMessage() != null && !e.getMessage().isEmpty()) {
141152
System.err.println(e.getMessage());

exist-core/src/main/java/org/exist/xmldb/DatabaseImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
import java.util.Map;
5151
import java.util.Optional;
5252

53+
import static org.exist.repo.AutoDeploymentTrigger.AUTODEPLOY_PROPERTY;
54+
5355
/**
5456
* The XMLDB driver class for eXist. This driver manages two different
5557
* internal implementations. The first communicates with a remote
@@ -100,6 +102,8 @@ public class DatabaseImpl implements Database {
100102
private Boolean ssl_allow_self_signed = true;
101103
private Boolean ssl_verify_hostname = false;
102104

105+
private Boolean no_autodeploy = false;
106+
103107
public DatabaseImpl() {
104108
final String initdb = System.getProperty("exist.initdb");
105109
if (initdb != null) {
@@ -122,6 +126,10 @@ private void configure(final String instanceName) throws XMLDBException {
122126
config.setProperty(Journal.PROPERTY_RECOVERY_JOURNAL_DIR, Paths.get(journalDir));
123127
}
124128

129+
if (no_autodeploy) {
130+
System.setProperty(AUTODEPLOY_PROPERTY, "off");
131+
}
132+
125133
BrokerPool.configure(instanceName, 1, 5, config);
126134
if (shutdown != null) {
127135
BrokerPool.getInstance(instanceName).registerShutdownListener(shutdown);
@@ -368,6 +376,7 @@ public String getName() throws XMLDBException {
368376
public final static String DATA_DIR = "data-dir";
369377
public final static String JOURNAL_DIR = "journal-dir";
370378
public final static String SSL_ENABLE = "ssl-enable";
379+
public final static String NO_AUTODEPLOY = "no-autodeploy";
371380
public final static String SSL_ALLOW_SELF_SIGNED = "ssl-allow-self-signed";
372381
public final static String SSL_VERIFY_HOSTNAME = "ssl-verify-hostname";
373382

@@ -387,6 +396,7 @@ public String getProperty(final String property, final String defaultValue) thro
387396
case SSL_ENABLE -> ssl_enable.toString();
388397
case SSL_ALLOW_SELF_SIGNED -> ssl_allow_self_signed.toString();
389398
case SSL_VERIFY_HOSTNAME -> ssl_verify_hostname.toString();
399+
case NO_AUTODEPLOY -> no_autodeploy.toString();
390400
default -> defaultValue;
391401
};
392402
return value;
@@ -403,6 +413,7 @@ public void setProperty(final String property, final String value) throws XMLDBE
403413
case SSL_ENABLE -> this.ssl_enable = Boolean.valueOf(value);
404414
case SSL_ALLOW_SELF_SIGNED -> this.ssl_allow_self_signed = Boolean.valueOf(value);
405415
case SSL_VERIFY_HOSTNAME -> this.ssl_verify_hostname = Boolean.valueOf(value);
416+
case NO_AUTODEPLOY -> this.no_autodeploy = Boolean.valueOf(value);
406417
default -> LOG.warn("Ignoring unknown property: {}, value: {} ", property, value);
407418
}
408419
}

0 commit comments

Comments
 (0)