-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
43 additions
and
427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 0 additions & 74 deletions
74
src/main/java/com/enonic/lib/react4xp/ssr/engine/EngineBuilderPlatform.java
This file was deleted.
Oops, something went wrong.
39 changes: 34 additions & 5 deletions
39
src/main/java/com/enonic/lib/react4xp/ssr/engine/EngineFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,47 @@ | ||
package com.enonic.lib.react4xp.ssr.engine; | ||
|
||
import javax.script.ScriptEngine; | ||
import javax.script.ScriptEngineManager; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class EngineFactory | ||
{ | ||
private final EngineBuilderPlatform engineBuilder; | ||
private final static Logger LOG = LoggerFactory.getLogger( EngineFactory.class ); | ||
|
||
private static final ScriptEngineManager SCRIPT_ENGINE_MANAGER; | ||
|
||
public EngineFactory( String engineName ) | ||
static | ||
{ | ||
this.engineBuilder = new EngineBuilderPlatform( engineName ); | ||
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | ||
Thread.currentThread().setContextClassLoader( ClassLoader.getSystemClassLoader() ); | ||
try | ||
{ | ||
SCRIPT_ENGINE_MANAGER = new ScriptEngineManager(); | ||
} | ||
finally | ||
{ | ||
Thread.currentThread().setContextClassLoader( classLoader ); | ||
} | ||
} | ||
|
||
public ScriptEngine buildEngine() | ||
public static ScriptEngine buildEngine() | ||
{ | ||
return engineBuilder.buildEngine(); | ||
LOG.debug( "Init script engine"); | ||
final ScriptEngine engineByName; | ||
|
||
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | ||
Thread.currentThread().setContextClassLoader( ClassLoader.getSystemClassLoader() ); | ||
try | ||
{ | ||
engineByName = SCRIPT_ENGINE_MANAGER.getEngineByName( "Graal.js" ); | ||
} | ||
finally | ||
{ | ||
Thread.currentThread().setContextClassLoader( classLoader ); | ||
} | ||
LOG.debug( "Got engine {}", engineByName.getFactory().getEngineName() ); | ||
return engineByName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.