Skip to content

Commit

Permalink
- Nashorn support
Browse files Browse the repository at this point in the history
- Improve thread model
  • Loading branch information
rahmanusta committed Aug 24, 2015
1 parent 2d363c9 commit 53800e6
Show file tree
Hide file tree
Showing 25 changed files with 729 additions and 489 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/kodcu/boot/AppStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class AppStarter extends Application {
@Override
public void start(final Stage stage) {

// System.setProperty("nashorn.typeInfo.maxFiles", "5");

// http://bit.ly/1Euk8hh
System.setProperty("jsse.enableSNIExtension", "false");

Expand Down
21 changes: 18 additions & 3 deletions src/main/java/com/kodcu/boot/SpringAppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
Expand All @@ -49,6 +47,23 @@ public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(applicationController, "/ws", "/ws**", "/ws/**").withSockJS();
}

@Bean
@Lazy
public NashornScriptEngineFactory nashornScriptEngineFactory() {
NashornScriptEngineFactory nashornScriptEngineFactory = new NashornScriptEngineFactory();
return nashornScriptEngineFactory;
}

@Bean
@Scope("prototype")
@Lazy
public ScriptEngine scriptEngine() {
ScriptEngine scriptEngine = nashornScriptEngineFactory()
.getScriptEngine();
// .getScriptEngine(new String[]{"--persistent-code-cache", "--class-cache-size=50"});
return scriptEngine;
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/kodcu/component/PreviewTab.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.kodcu.component;

import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Tab;

import java.util.Objects;
Expand All @@ -21,6 +23,21 @@ public PreviewTab(String text, Node content) {
public PreviewTab() {
}

public void setChild(Node node) {

if (!Platform.isFxApplicationThread()) {
Platform.runLater(() -> {
setChild(node);
});
return;
}

if (super.getContent() == node)
return;

super.setContent(node);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/kodcu/config/JSPlatform.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.kodcu.config;

/**
* Created by usta on 24.08.2015.
*/
public enum JSPlatform {

Webkit("webkit"),
Nashorn("nashorn"),;

private final String value;

JSPlatform(String value) {
this.value = value;
}

}
Loading

0 comments on commit 53800e6

Please sign in to comment.