Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit c398149

Browse files
committed
Finish 100-tokens
1 parent ae48ad2 commit c398149

File tree

7 files changed

+152
-65
lines changed

7 files changed

+152
-65
lines changed

build.gradle

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ repositories {
1515
}
1616

1717
dependencies {
18-
compile 'com.marklogic:ml-javaclient-util:2.8.0'
18+
compile 'com.marklogic:ml-javaclient-util:2.9.0-RC1'
1919
compile 'jaxen:jaxen:1.1.6'
2020
compile 'org.apache.httpcomponents:httpclient:4.3.5'
2121
compile 'org.springframework:spring-web:4.1.5.RELEASE'
22-
testCompile 'com.marklogic:ml-junit:2.6.0'
22+
testCompile ('com.marklogic:ml-junit:2.6.0') {
23+
exclude module: "ml-javaclient-util"
24+
}
2325
}
2426

2527
// This ensures that Gradle includes in the published jar any non-java files under src/main/java
@@ -42,11 +44,6 @@ publishing {
4244
artifact sourcesJar
4345
}
4446
}
45-
repositories {
46-
maven {
47-
url publishUrl
48-
}
49-
}
5047
}
5148

5249
if (project.hasProperty("myBintrayUser")) {
@@ -60,7 +57,7 @@ if (project.hasProperty("myBintrayUser")) {
6057
licenses = ['Apache-2.0']
6158
vcsUrl = 'https://github.com/rjrudin/' + project.name + '.git'
6259
version {
63-
name = "2.2.0"
60+
name = "2.2.0-RC1"
6461
released = new Date()
6562
}
6663
}

gradle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
group=com.marklogic
2-
publishUrl=file:../gh-pages-marklogic-java/releases
32
javadocsDir=../gh-pages-marklogic-java/javadocs
4-
version=2.2.0
3+
version=2.2.0-RC1

src/main/java/com/marklogic/appdeployer/AppConfig.java

Lines changed: 109 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
package com.marklogic.appdeployer;
22

3-
import java.io.FileFilter;
4-
import java.util.ArrayList;
5-
import java.util.HashMap;
6-
import java.util.List;
7-
import java.util.Map;
8-
9-
import javax.net.ssl.SSLContext;
10-
113
import com.marklogic.client.DatabaseClient;
124
import com.marklogic.client.DatabaseClientFactory;
135
import com.marklogic.client.DatabaseClientFactory.Authentication;
146
import com.marklogic.client.DatabaseClientFactory.SSLHostnameVerifier;
157
import com.marklogic.client.modulesloader.impl.XccAssetLoader;
168
import com.marklogic.client.modulesloader.ssl.SimpleX509TrustManager;
9+
import com.marklogic.client.modulesloader.tokenreplacer.DefaultModuleTokenReplacer;
10+
import com.marklogic.client.modulesloader.tokenreplacer.ModuleTokenReplacer;
11+
import com.marklogic.client.modulesloader.tokenreplacer.PropertiesSource;
12+
import com.marklogic.client.modulesloader.tokenreplacer.RoxyModuleTokenReplacer;
1713
import com.marklogic.client.modulesloader.xcc.DefaultDocumentFormatGetter;
1814

15+
import javax.net.ssl.SSLContext;
16+
import java.io.FileFilter;
17+
import java.util.*;
18+
1919
/**
2020
* Encapsulates common configuration properties for an application deployed to MarkLogic. These properties include not
2121
* just names of application resources - such as app servers and databases - but also connection information for loading
2222
* modules into an application as well as paths for modules and configuration files.
23-
*
23+
* <p>
2424
* An instance of this class is passed in as the main argument to the methods in the {@code AppDeployer} interface,
2525
* meaning that you're free to not just configure this as needed but also subclass it and add anything that you would
2626
* like.
@@ -106,6 +106,13 @@ public class AppConfig {
106106
// Path to use for DeployFlexrepCommand
107107
private String flexrepPath;
108108

109+
// Whether or not to replace tokens in modules
110+
private boolean replaceTokensInModules = true;
111+
// Whether or not to prefix each module token with "@ml."
112+
private boolean useRoxyTokenPrefix = true;
113+
// Additional PropertiesSources instance to use for replacing module tokens
114+
private List<PropertiesSource> moduleTokensPropertiesSources = new ArrayList<>();
115+
109116
private Map<String, Integer> forestCounts = new HashMap<>();
110117

111118
public AppConfig() {
@@ -131,7 +138,7 @@ public void setSimpleSslConfig() {
131138
/**
132139
* Convenience method for constructing a MarkLogic Java API DatabaseClient based on the host, restPort,
133140
* restAdminUsername, restAdminPassword, restAuthentication, restSslContext, and restSslHostnameVerifier properties.
134-
*
141+
*
135142
* @return
136143
*/
137144
public DatabaseClient newDatabaseClient() {
@@ -141,7 +148,7 @@ public DatabaseClient newDatabaseClient() {
141148

142149
/**
143150
* Just like newDatabaseClient, but uses testRestPort.
144-
*
151+
*
145152
* @return
146153
*/
147154
public DatabaseClient newTestDatabaseClient() {
@@ -151,7 +158,7 @@ public DatabaseClient newTestDatabaseClient() {
151158

152159
/**
153160
* Like newDatabaseClient, but connects to schemas database.
154-
*
161+
*
155162
* @return
156163
*/
157164
public DatabaseClient newSchemasDatabaseClient() {
@@ -191,14 +198,39 @@ public XccAssetLoader newXccAssetLoader() {
191198
l.setFileFilter(assetFileFilter);
192199
}
193200

201+
if (isReplaceTokensInModules()) {
202+
l.setModuleTokenReplacer(buildModuleTokenReplacer());
203+
}
204+
194205
return l;
206+
}
195207

208+
protected ModuleTokenReplacer buildModuleTokenReplacer() {
209+
DefaultModuleTokenReplacer r = isUseRoxyTokenPrefix() ? new RoxyModuleTokenReplacer() : new DefaultModuleTokenReplacer();
210+
if (customTokens != null && !customTokens.isEmpty()) {
211+
r.addPropertiesSource(new PropertiesSource() {
212+
@Override
213+
public Properties getProperties() {
214+
Properties p = new Properties();
215+
p.putAll(customTokens);
216+
return p;
217+
}
218+
});
219+
}
220+
221+
if (getModuleTokensPropertiesSources() != null) {
222+
for (PropertiesSource ps : getModuleTokensPropertiesSources()) {
223+
r.addPropertiesSource(ps);
224+
}
225+
}
226+
227+
return r;
196228
}
197229

198230
/**
199231
* @return true if {@code testRestPort} is set and greater than zero. This is used as an indicator that an
200-
* application wants test resources - most likely a separate app server and content database - created as
201-
* part of a deployment.
232+
* application wants test resources - most likely a separate app server and content database - created as
233+
* part of a deployment.
202234
*/
203235
public boolean isTestPortSet() {
204236
return testRestPort != null && testRestPort > 0;
@@ -211,51 +243,79 @@ public String getRestServerName() {
211243
return restServerName != null ? restServerName : name;
212244
}
213245

246+
public void setRestServerName(String restServerName) {
247+
this.restServerName = restServerName;
248+
}
249+
214250
/**
215251
* @return {@code testRestServerName} if it is set; {@code name}-test otherwise
216252
*/
217253
public String getTestRestServerName() {
218254
return testRestServerName != null ? testRestServerName : name + "-test";
219255
}
220256

257+
public void setTestRestServerName(String testRestServerName) {
258+
this.testRestServerName = testRestServerName;
259+
}
260+
221261
/**
222262
* @return {@code contentDatabaseName} if it is set; {@code name}-content otherwise
223263
*/
224264
public String getContentDatabaseName() {
225265
return contentDatabaseName != null ? contentDatabaseName : name + "-content";
226266
}
227267

268+
public void setContentDatabaseName(String contentDatabaseName) {
269+
this.contentDatabaseName = contentDatabaseName;
270+
}
271+
228272
/**
229273
* @return {@code testContentDatabaseName} if it is set; {@code name}-test-content otherwise
230274
*/
231275
public String getTestContentDatabaseName() {
232276
return testContentDatabaseName != null ? testContentDatabaseName : name + "-test-content";
233277
}
234278

279+
public void setTestContentDatabaseName(String testContentDatabaseName) {
280+
this.testContentDatabaseName = testContentDatabaseName;
281+
}
282+
235283
/**
236284
* @return {@code modulesDatabaseName} if it is set; {@code name}-modules otherwise
237285
*/
238286
public String getModulesDatabaseName() {
239287
return modulesDatabaseName != null ? modulesDatabaseName : name + "-modules";
240288
}
241289

290+
public void setModulesDatabaseName(String modulesDatabaseName) {
291+
this.modulesDatabaseName = modulesDatabaseName;
292+
}
293+
242294
/**
243295
* @return {@code triggersDatabaseName} if it is set; {@code name}-triggers otherwise
244296
*/
245297
public String getTriggersDatabaseName() {
246298
return triggersDatabaseName != null ? triggersDatabaseName : name + "-triggers";
247299
}
248300

301+
public void setTriggersDatabaseName(String triggersDatabaseName) {
302+
this.triggersDatabaseName = triggersDatabaseName;
303+
}
304+
249305
/**
250306
* @return {@code schemasDatabaseName} if it is set; {@code name}-schemas otherwise
251307
*/
252308
public String getSchemasDatabaseName() {
253309
return schemasDatabaseName != null ? schemasDatabaseName : name + "-schemas";
254310
}
255311

312+
public void setSchemasDatabaseName(String schemasDatabaseName) {
313+
this.schemasDatabaseName = schemasDatabaseName;
314+
}
315+
256316
/**
257317
* @return the name of the application, which is then used to generate app server and database names unless those
258-
* are set via their respective properties
318+
* are set via their respective properties
259319
*/
260320
public String getName() {
261321
return name;
@@ -311,7 +371,7 @@ public void setRestPort(Integer restPort) {
311371

312372
/**
313373
* @return the post of the REST API server used for loading modules that are specific to a test server (currently,
314-
* just search options)
374+
* just search options)
315375
*/
316376
public Integer getTestRestPort() {
317377
return testRestPort;
@@ -345,7 +405,7 @@ public void setModulePaths(List<String> modulePaths) {
345405

346406
/**
347407
* @return the name of the group in which the application associated with this configuration should have its app
348-
* servers and other group-specific resources
408+
* servers and other group-specific resources
349409
*/
350410
public String getGroupName() {
351411
return groupName;
@@ -357,7 +417,7 @@ public void setGroupName(String groupName) {
357417

358418
/**
359419
* @return the MarkLogic Java Client {@code Authentication} object that is used for authenticating with a REST API
360-
* server for loading modules
420+
* server for loading modules
361421
*/
362422
public Authentication getRestAuthentication() {
363423
return restAuthentication;
@@ -369,8 +429,8 @@ public void setRestAuthentication(Authentication authentication) {
369429

370430
/**
371431
* @return a {@code ConfigDir} instance that defines the location of the configuration directory (where files are
372-
* stored that are then loaded via MarkLogic Management API endpoints) as well as paths to specific
373-
* resources within that directory
432+
* stored that are then loaded via MarkLogic Management API endpoints) as well as paths to specific
433+
* resources within that directory
374434
*/
375435
public ConfigDir getConfigDir() {
376436
return configDir;
@@ -382,8 +442,8 @@ public void setConfigDir(ConfigDir configDir) {
382442

383443
/**
384444
* @return a map of tokens that are intended to be replaced with their associated values in configuration files.
385-
* This map allows for externalized properties to be passed into configuration files - e.g. Gradle
386-
* properties can be swapped in for tokens in configuration files at deploy time.
445+
* This map allows for externalized properties to be passed into configuration files - e.g. Gradle
446+
* properties can be swapped in for tokens in configuration files at deploy time.
387447
*/
388448
public Map<String, String> getCustomTokens() {
389449
return customTokens;
@@ -395,7 +455,7 @@ public void setCustomTokens(Map<String, String> customTokens) {
395455

396456
/**
397457
* @return whether a triggers database should be created by default; defaults to true, as it's very common to need a
398-
* triggers database, such as for CPF, Alerting, custom triggers, etc.
458+
* triggers database, such as for CPF, Alerting, custom triggers, etc.
399459
*/
400460
public boolean isCreateTriggersDatabase() {
401461
return createTriggersDatabase;
@@ -407,7 +467,7 @@ public void setCreateTriggersDatabase(boolean createTriggerDatabase) {
407467

408468
/**
409469
* @return a Java {@code SSLContext} for making an SSL connection with the REST API server for loading modules; null
410-
* if an SSL connection is not required
470+
* if an SSL connection is not required
411471
*/
412472
public SSLContext getRestSslContext() {
413473
return restSslContext;
@@ -419,7 +479,7 @@ public void setRestSslContext(SSLContext restSslContext) {
419479

420480
/**
421481
* @return a MarkLogic Java Client {@code SSLHostnameVerifier} that is used to make an SSL connection to the REST
422-
* API server for loading modules; null if an SSL connection is not required
482+
* API server for loading modules; null if an SSL connection is not required
423483
*/
424484
public SSLHostnameVerifier getRestSslHostnameVerifier() {
425485
return restSslHostnameVerifier;
@@ -429,34 +489,6 @@ public void setRestSslHostnameVerifier(SSLHostnameVerifier restSslHostnameVerifi
429489
this.restSslHostnameVerifier = restSslHostnameVerifier;
430490
}
431491

432-
public void setRestServerName(String restServerName) {
433-
this.restServerName = restServerName;
434-
}
435-
436-
public void setTestRestServerName(String testRestServerName) {
437-
this.testRestServerName = testRestServerName;
438-
}
439-
440-
public void setContentDatabaseName(String contentDatabaseName) {
441-
this.contentDatabaseName = contentDatabaseName;
442-
}
443-
444-
public void setTestContentDatabaseName(String testContentDatabaseName) {
445-
this.testContentDatabaseName = testContentDatabaseName;
446-
}
447-
448-
public void setModulesDatabaseName(String modulesDatabaseName) {
449-
this.modulesDatabaseName = modulesDatabaseName;
450-
}
451-
452-
public void setTriggersDatabaseName(String triggersDatabaseName) {
453-
this.triggersDatabaseName = triggersDatabaseName;
454-
}
455-
456-
public void setSchemasDatabaseName(String schemasDatabaseName) {
457-
this.schemasDatabaseName = schemasDatabaseName;
458-
}
459-
460492
public String[] getAdditionalBinaryExtensions() {
461493
return additionalBinaryExtensions;
462494
}
@@ -520,4 +552,28 @@ public Integer getAppServicesPort() {
520552
public void setAppServicesPort(Integer appServicesPort) {
521553
this.appServicesPort = appServicesPort;
522554
}
555+
556+
public boolean isReplaceTokensInModules() {
557+
return replaceTokensInModules;
558+
}
559+
560+
public void setReplaceTokensInModules(boolean replaceTokensInModules) {
561+
this.replaceTokensInModules = replaceTokensInModules;
562+
}
563+
564+
public boolean isUseRoxyTokenPrefix() {
565+
return useRoxyTokenPrefix;
566+
}
567+
568+
public void setUseRoxyTokenPrefix(boolean useRoxyTokenPrefix) {
569+
this.useRoxyTokenPrefix = useRoxyTokenPrefix;
570+
}
571+
572+
public List<PropertiesSource> getModuleTokensPropertiesSources() {
573+
return moduleTokensPropertiesSources;
574+
}
575+
576+
public void setModuleTokensPropertiesSources(List<PropertiesSource> moduleTokensPropertiesSources) {
577+
this.moduleTokensPropertiesSources = moduleTokensPropertiesSources;
578+
}
523579
}

0 commit comments

Comments
 (0)