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