Skip to content

Commit

Permalink
Merge pull request #2 from shendepu/run-jackrabbit
Browse files Browse the repository at this point in the history
Added tools.@run-jackrabbit in conf file. And when true, a jackrabbit…
  • Loading branch information
jonesde committed Jan 26, 2016
2 parents 1afcbcb + ff7c572 commit 38bbb4d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
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

0 comments on commit 38bbb4d

Please sign in to comment.