Fix compilazione statica drools
This commit is contained in:
@@ -490,6 +490,12 @@
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
<version>${drools.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
@@ -497,6 +503,12 @@
|
||||
<version>${drools.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.4.10</version>
|
||||
</dependency>
|
||||
|
||||
<!-- log4j -->
|
||||
<dependency>
|
||||
<groupId>com.lmax</groupId>
|
||||
|
||||
@@ -2,7 +2,7 @@ package it.integry.ems_model.rulescompleting;
|
||||
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems.utility.UtilityFile;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems_model.base.EntityInterface;
|
||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||
import it.integry.ems_model.exception.RulesNotCompiledException;
|
||||
@@ -26,6 +26,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.Connection;
|
||||
|
||||
@Service
|
||||
@@ -65,10 +66,10 @@ public class DroolsDataCompleting {
|
||||
KieServices kieServices = KieServices.Factory.get();
|
||||
KieFileSystem kFileSystem = kieServices.newKieFileSystem();
|
||||
|
||||
String compiledRulesPath = getBaseAppFolder() + "drools" + pathS;
|
||||
String compiledRulesPath = getCompiledDroolsFolder();
|
||||
|
||||
String compiledRulesFileName = "compiled_kie_base.ckie";
|
||||
File compiledDrlFile = new File(compiledRulesPath + compiledRulesFileName);
|
||||
File compiledDrlFile = new File(compiledRulesPath, compiledRulesFileName);
|
||||
|
||||
|
||||
//System.out.println("AIO: " + compiledRulesPath);
|
||||
@@ -77,11 +78,14 @@ public class DroolsDataCompleting {
|
||||
System.setProperty("drools.dialect.mvel.strict", "false");
|
||||
|
||||
|
||||
if (!compiledDrlFile.exists()) {
|
||||
if (!shouldSkipDroolsCompile() || !compiledDrlFile.exists()) {
|
||||
File directory = new File(compiledRulesPath);
|
||||
if (!directory.exists()) {
|
||||
if (!directory.exists())
|
||||
directory.mkdirs();
|
||||
}
|
||||
|
||||
|
||||
if(compiledDrlFile.exists())
|
||||
compiledDrlFile.delete();
|
||||
|
||||
for (String drl : dlrs) {
|
||||
String resourcePath = pathS + "rules" + pathS + drl;
|
||||
@@ -124,12 +128,6 @@ public class DroolsDataCompleting {
|
||||
KieContainer kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId());
|
||||
kieBase = kieContainer.getKieBase();
|
||||
serialize(kieBase, compiledDrlFile);
|
||||
|
||||
if (UtilityDebug.isDebugExecution()) {
|
||||
String fullPath = getDebugPath() + "drools" + pathS;
|
||||
UtilityFile.directoryCreate(fullPath);
|
||||
serialize(kieBase, new File(fullPath + compiledRulesFileName));
|
||||
}
|
||||
} else {
|
||||
kieBase = deserialize(KieBase.class, compiledDrlFile);
|
||||
}
|
||||
@@ -140,30 +138,36 @@ public class DroolsDataCompleting {
|
||||
|
||||
}
|
||||
|
||||
private String getBaseAppFolder() {
|
||||
|
||||
if (UtilityDebug.isDebugExecution() && "TRUE".equalsIgnoreCase(System.getProperty("DISABLE_DROOLS_COMPILE"))) {
|
||||
return getDebugPath();
|
||||
private boolean shouldSkipDroolsCompile() {
|
||||
boolean enableDroolCompileParam = !"TRUE".equalsIgnoreCase(System.getProperty("DISABLE_DROOLS_COMPILE"));
|
||||
return !enableDroolCompileParam || !UtilityDebug.isDebugExecution();
|
||||
}
|
||||
|
||||
String fullPath = getClass().getResource("").toString();
|
||||
String[] singleElemsOfPath = fullPath.split("/");
|
||||
private String getCompiledDroolsFolder() {
|
||||
|
||||
|
||||
String currentFolderName = "";
|
||||
|
||||
for (String aSingleElemsOfPath : singleElemsOfPath) {
|
||||
if (aSingleElemsOfPath.contains("-api")) {
|
||||
currentFolderName = aSingleElemsOfPath;
|
||||
}
|
||||
return Paths.get(UtilityDirs.getWebAppPath(), "drools").toString();
|
||||
//
|
||||
// if (UtilityDebug.isDebugExecution() && "TRUE".equalsIgnoreCase(System.getProperty("DISABLE_DROOLS_COMPILE"))) {
|
||||
// return getDebugPath();
|
||||
// }
|
||||
//
|
||||
// String fullPath = getClass().getResource("").toString();
|
||||
// String[] singleElemsOfPath = fullPath.split("/");
|
||||
//
|
||||
//
|
||||
// String currentFolderName = "";
|
||||
//
|
||||
// for (String aSingleElemsOfPath : singleElemsOfPath) {
|
||||
// if (aSingleElemsOfPath.contains("-api")) {
|
||||
// currentFolderName = aSingleElemsOfPath;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return System.getProperty("catalina.base") + File.separator + "webapps" + File.separator + currentFolderName + File.separator;
|
||||
}
|
||||
|
||||
return System.getProperty("catalina.base") + File.separator + "webapps" + File.separator + currentFolderName + File.separator;
|
||||
}
|
||||
|
||||
private String getDebugPath() {
|
||||
return "C:\\Work\\Prod_Java\\";
|
||||
}
|
||||
// private String getDebugPath() {
|
||||
// }
|
||||
|
||||
private <T> void serialize(T o, File outputFile) throws IOException {
|
||||
ObjectOutputStream out = new ObjectOutputStream(Files.newOutputStream(outputFile.toPath()));
|
||||
|
||||
@@ -59,12 +59,14 @@
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<inherited>false</inherited>
|
||||
<configuration>
|
||||
<cleanupDaemonThreads>false</cleanupDaemonThreads>
|
||||
<mainClass>it.integry.ems_model.rulescompleting.KieStaticCompiler</mainClass>
|
||||
<skip>false</skip>
|
||||
<arguments>
|
||||
@@ -74,7 +76,7 @@
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>post-clean</phase>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
|
||||
20
pom.xml
20
pom.xml
@@ -96,26 +96,6 @@
|
||||
</toolchains>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
<mainClass>it.integry.ems_model.rulescompleting.KieStaticCompiler</mainClass>
|
||||
<arguments>
|
||||
<argument>src/main/webapp/drools/</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>post-clean</phase>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user