getsandbox / worker-cli

Sandbox Worker is the core processing component of the Sandbox product
https://getsandbox.com
230 stars 62 forks source link

Java Classpath & Sending emails #4

Closed rmalla1 closed 9 years ago

rmalla1 commented 9 years ago

Hello, I would like to invoke custom Java classes within the JS file. I understand that nashorn supports calling Java APIs. My question is how can I add my custom jars to sandbox classpath? Thanks, Ratnakar

drewstewart commented 9 years ago

Hi Ratnakar,

We lock down the Nashorn engine and restrict access to the Java API and have no plans to change this at the moment. The purpose is to encourage only basic stubbing to be modelled, and to steer clear of over-engineering the stubs.

rmalla1 commented 9 years ago

I see. I have a requirement to send out email, and I was thinking about using java mail api. How can I achieve this?

nhoughto commented 9 years ago

Hey,

Can't achieve that as it stands at the moment, you could extend the runtime yourself to enable the Java APIs and then call out to Java to achieve what you want. However that obviously won't work in the hosted product (on getsandbox.com).

Interesting require though to be able to call out to send an email, something we might consider adding in the future. What is the scenario you are testing that you want to send an email? A user sign up or something?

rmalla1 commented 9 years ago

Yes, this is for user sign up. I will extend the runtime.

nhoughto commented 9 years ago

The line in question is this: https://github.com/getsandbox/sandbox/blob/master/src/main/java/com/sandbox/runtime/config/Context.java#L137

If you remove the --no-java parameter, standard Java apis should be accessible.