forked from fanruan/demo-tabledata-redis
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
925 B
36 lines
925 B
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); |
|
} |
|
} |
|
} |
|
}
|
|
|