Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tools.@run-jackrabbit in conf file. And when true, a jackrabbit… #2

Merged
merged 1 commit into from
Jan 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class ExecutionContextFactoryImpl implements ExecutionContextFactory {
org.elasticsearch.node.Node elasticSearchNode
Client elasticSearchClient

/* Jackrabbit fields */
Process jackrabbitProcess

/* KIE fields */
protected final Cache kieComponentReleaseIdCache
protected final Cache kieSessionComponentCache
Expand Down Expand Up @@ -258,6 +261,9 @@ class ExecutionContextFactoryImpl implements ExecutionContextFactory {
// everything else ready to go, init Camel
initCamel()

// init Jackrabbit standalone instance
initJackrabbit()

// init KIE (build modules for all components)
initKie()

Expand Down Expand Up @@ -378,6 +384,9 @@ class ExecutionContextFactoryImpl implements ExecutionContextFactory {
// stop ElasticSearch
if (elasticSearchNode != null) elasticSearchNode.close()

// Stop Jackrabbit process
if (jackrabbitProcess != null) jackrabbitProcess.destroy()

// persist any remaining bins in artifactHitBinByType
Timestamp currentTimestamp = new Timestamp(System.currentTimeMillis())
List<ArtifactStatsInfo> asiList = new ArrayList<>(artifactStatsInfoByType.values())
Expand Down Expand Up @@ -552,6 +561,42 @@ class ExecutionContextFactoryImpl implements ExecutionContextFactory {
}
}

protected void initJackrabbit() {
if (confXmlRoot."tools"[0]."@run-jackrabbit" == "true") {
Properties jackrabbitProperties = new Properties()
URL jackrabbitProps = this.class.getClassLoader().getResource("jackrabbit_moqui.properties")
if (jackrabbitProps != null) {
InputStream is = jackrabbitProps.openStream(); jackrabbitProperties.load(is); is.close();
}

String jackrabbitWorkingDir = System.getProperty("moqui.jackrabbit_working_dir")
if (!jackrabbitWorkingDir) jackrabbitWorkingDir = jackrabbitProperties.getProperty("moqui.jackrabbit_working_dir")
if (!jackrabbitWorkingDir) jackrabbitWorkingDir = "jackrabbit"

String jackrabbitJar = System.getProperty("moqui.jackrabbit_jar")
if (!jackrabbitJar) jackrabbitJar = jackrabbitProperties.getProperty("moqui.jackrabbit_jar")
if (!jackrabbitJar) throw new IllegalArgumentException(
"No moqui.jackrabbit_jar property found in jackrabbit_moqui.ini or in a system property (with: -Dmoqui.jackrabbit_jar=... on the command line)")
String jackrabbitJarFullPath = this.runtimePath + "/" + jackrabbitWorkingDir + "/" + jackrabbitJar

String jackrabbitConfFile = System.getProperty("moqui.jackrabbit_configuration_file")
if (!jackrabbitConfFile)
jackrabbitConfFile = jackrabbitProperties.getProperty("moqui.jackrabbit_configuration_file")
if (!jackrabbitConfFile) jackrabbitConfFile = "repository.xml"
String jackrabbitConfFileFullPath = this.runtimePath + "/" + jackrabbitWorkingDir + "/" + jackrabbitConfFile

String jackrabbitPort = System.getProperty("moqui.jackrabbit_port")
if (!jackrabbitPort)
jackrabbitPort = jackrabbitProperties.getProperty("moqui.jackrabbit_port")
if (!jackrabbitPort) jackrabbitPort = "8081"

logger.info("Starting Jackrabbit")

ProcessBuilder pb = new ProcessBuilder("java", "-jar", jackrabbitJarFullPath, "-p", jackrabbitPort, "-c", jackrabbitConfFileFullPath)
pb.directory(new File(this.runtimePath + "/" + jackrabbitWorkingDir))
jackrabbitProcess = pb.start();
}
}

// =============== KIE Methods ===============
protected void initKie() {
Expand Down
2 changes: 1 addition & 1 deletion framework/src/main/resources/MoquiDefaultConf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<!-- Settings in this file can be overridden in a runtime conf file that has a any of the desired sub-elements. -->

<tools enable-elasticsearch="true" enable-camel="true"/>
<tools enable-elasticsearch="true" enable-camel="true" run-jackrabbit="false"/>

<cache-list warm-on-start="true">
<!-- Production mode by default - No expiration of conf and impl artifacts. -->
Expand Down
1 change: 1 addition & 0 deletions framework/xsd/moqui-conf-1.6.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ along with this software (see the LICENSE.md file). If not, see
<xs:complexType>
<xs:attribute name="enable-elasticsearch" type="boolean" default="true"/>
<xs:attribute name="enable-camel" type="boolean" default="true"/>
<xs:attribute name="run-jackrabbit" type="boolean" default="false"/>
</xs:complexType>
</xs:element>

Expand Down