forked from fanruan/demo-tabledata-redis
richie
5 years ago
35 changed files with 118 additions and 80 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,36 @@
|
||||
package com.fr.plugin.db.redis.help.client; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.macro.EncodeConstants; |
||||
import com.fanruan.api.util.IOKit; |
||||
import com.fr.plugin.db.redis.help.ScriptBridge; |
||||
|
||||
import javax.script.ScriptEngine; |
||||
import java.io.InputStream; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-17 |
||||
*/ |
||||
public class NashornFiles { |
||||
|
||||
private ScriptEngine scriptEngine; |
||||
|
||||
public NashornFiles(ScriptEngine scriptEngine) { |
||||
this.scriptEngine = scriptEngine; |
||||
} |
||||
|
||||
@ScriptBridge |
||||
public void require(String filePath) { |
||||
InputStream in = IOKit.read(filePath); |
||||
if (in != null) { |
||||
try { |
||||
String text = IOKit.inputStream2String(in, EncodeConstants.ENCODING_UTF_8); |
||||
scriptEngine.eval(text); |
||||
} catch (Exception e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue