Hi,

Is it possible to do $subject? I've been playing around with wso2-synapse
code base but couldn't find a way around without overriding ScriptMediator
class which is something I'm trying to avoid.

My requirement is that I've developed some Java Util methods which I would
like to expose as JS native functions. I tried writing a class mediator and
do the bindings but couldn't get it working.

ScriptEngineManager manager = new ScriptEngineManager();
manager.registerEngineExtension("jsEngine", new RhinoScriptEngineFactory());
ScriptEngine scriptEngine = manager.getEngineByExtension("jsEngine");

Bindings bindings = scriptEngine.createBindings();
bindings.put("jsUtils", new JSUtils());

JSUtils Java class has some string operations that should be accessible via
JS. Inside JS script mediator I should be able to something like this;

var result = jsUtils.parseJSON(someJsonVar);


I know this can be done by purely using the class mediator to evaluate the
whole JS source. But I'd much rather use built-in script mediator and only
inject my custom Java classes onto it.

I think this would be a cool feature to have, if it is not already
supported.

Thanks.

-- 
Akila Ravihansa Perera
Software Engineer, WSO2

Blog: http://ravihansa3000.blogspot.com
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to