Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```scala
- lass CustomStrategy extends BaseStrategy with LazyLogging {
- override def format(value: String, strategyParam: String): String = {
- val manager = new ScriptEngineManager()
- val engine = manager.getEngineByName(CustomStrategy.ENGINE_NAME)
- try {
- engine.put(CustomStrategy.JS_FUNCTION_PARAM, value)
- engine.eval(strategyParam)
- } catch {
- case e: ScriptException =>
- logger.warn("Script execute failure", e)
- }
- value
- }
- }
- object CustomStrategy {
- val JS_FUNCTION_PARAM = "value"
- val ENGINE_NAME = "javascript"
- }
- ```
Add Comment
Please, Sign In to add comment