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

use explicit nashorn dependency #312

Merged
merged 5 commits into from
Jun 18, 2024
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
22 changes: 17 additions & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@
<artifactId>ehcache</artifactId>
<type>pom</type>
</dependency>
<dependency>
<!-- <dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
</dependency> -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
Expand Down Expand Up @@ -172,17 +176,25 @@
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<scope>test</scope>
</dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<scope>test</scope>
</dependency>

<!-- <dependency>
<groupId>com.github.stephenc.monte</groupId>
<artifactId>monte-screen-recorder</artifactId>
<scope>test</scope>
</dependency> -->



<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>15.4</version>
</dependency>

<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javax.script.ScriptEngine;
import javax.script.ScriptException;

import org.openjdk.nashorn.api.scripting.JSObject;
import org.phoenixctms.ctsms.util.CommonUtil;
import org.phoenixctms.ctsms.util.CoreUtil;
import org.phoenixctms.ctsms.util.DefaultSettings;
Expand All @@ -31,8 +32,6 @@
import org.phoenixctms.ctsms.vo.VisitScheduleItemOutVO;
import org.springframework.core.io.ClassPathResource;

import jdk.nashorn.api.scripting.JSObject;

@SuppressWarnings("restriction")
public class FieldCalculation {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Map;
import java.util.Set;

import jdk.nashorn.api.scripting.AbstractJSObject;
import org.openjdk.nashorn.api.scripting.AbstractJSObject;

//http://stackoverflow.com/questions/7519399/how-to-convert-java-map-to-a-basic-javascript-object
@SuppressWarnings("restriction")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.phoenixctms.ctsms.js;

import jdk.nashorn.api.scripting.JSObject;
import org.openjdk.nashorn.api.scripting.JSObject;

@SuppressWarnings("restriction")
public class ValidationError {
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/java/org/phoenixctms/ctsms/util/CoreUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

import org.apache.commons.codec.binary.Base64;
import org.openjdk.nashorn.api.scripting.NashornScriptEngineFactory;
import org.phoenixctms.ctsms.PrincipalStore;
import org.phoenixctms.ctsms.UserContext;
import org.phoenixctms.ctsms.compare.AlphanumStringComparator;
Expand Down Expand Up @@ -81,7 +81,7 @@ public final class CoreUtil implements ApplicationContextAware {

public final static String OBFUSCATED_STRING = "********";
public final static String RANDOM_ALGORITHM = "SHA1PRNG";
private final static String JAVASCRIPT_ENGINE_NAME = "JavaScript";
//private final static String JAVASCRIPT_ENGINE_NAME = "JavaScript";
public static final String PDF_FILENAME_EXTENSION = "pdf";
public static final String PDF_MIMETYPE_STRING = "application/pdf"; // public for demodataprovider
public static final String EXCEL_FILENAME_EXTENSION = "xls";
Expand Down Expand Up @@ -665,8 +665,10 @@ public static String getInVOClassNameFromEntityName(String entityName) {
}

public static ScriptEngine getJsEngine() {
ScriptEngineManager manager = new ScriptEngineManager();
return manager.getEngineByName(JAVASCRIPT_ENGINE_NAME);
//ScriptEngineManager manager = new ScriptEngineManager();
//return manager.getEngineByName(JAVASCRIPT_ENGINE_NAME);
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
return factory.getScriptEngine();
}

public static Password getLastPassword() {
Expand Down
18 changes: 18 additions & 0 deletions core/src/main/resources/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ if (!String.prototype.trim) {
jQuery.trim = function(str) {
return (str != null ? str.trim() : null);
};
jQuery.grep = function(elems, callback, invert) {
var callbackInverse,
matches = [],
i = 0,
length = elems.length,
callbackExpect = !invert;

// Go through the array, only saving the items
// that pass the validator function
for (; i < length; i++) {
callbackInverse = !callback(elems[i], i);
if (callbackInverse !== callbackExpect) {
matches.push(elems[i]);
}
}

return matches;
};
var console = {
log : function(msg) {
java.lang.System.out.println(msg);
Expand Down
88 changes: 54 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,25 +261,45 @@
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.3.0</version>
<scope>runtime</scope>
</dependency>
<!-- <dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2.2</version>
<version>3.3.0</version>
<scope>runtime</scope>
</dependency> -->

<!-- <dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.7</version>
</dependency>
<!-- Following is necessary for deployment on Payara to avoid version conflicts -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2.2</version>
<scope>runtime</scope>
</dependency> -->
<!-- Following is necessary for deployment on Payara to avoid version conflicts -->
<!-- <dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
</dependency> -->
<!-- <dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
<scope>runtime</scope>
</dependency>
</dependency> -->

<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
Expand Down Expand Up @@ -354,27 +374,27 @@
<scope>test</scope>
</dependency>

<!-- <dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
<scope>test</scope>
</dependency> -->

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<!-- <version>3.141.59</version> -->
<version>4.4.0</version>
<!-- <dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
<scope>test</scope>
</dependency> -->

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<!-- <version>3.141.59</version> -->
<version>4.4.0</version>
<scope>test</scope>
</dependency>

<!-- <dependency>
<groupId>com.github.stephenc.monte</groupId>
<artifactId>monte-screen-recorder</artifactId>
<version>0.7.7.0</version>
<scope>test</scope>
</dependency>

<!-- <dependency>
<groupId>com.github.stephenc.monte</groupId>
<artifactId>monte-screen-recorder</artifactId>
<version>0.7.7.0</version>
<scope>test</scope>
</dependency> -->
</dependency> -->


<dependency>
Expand Down Expand Up @@ -479,15 +499,15 @@
<additionalConfigFilesDir>${project.basedir}/src/main/resources</additionalConfigFilesDir>
</configuration> -->

<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<path>/ctsms-web</path>
</configuration>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>

<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<path>/ctsms-web</path>
</configuration>

</plugin>
<plugin>
Expand Down
Loading