code_junkie

How can you run Javascript using Rhino for Java in a sandbox?

Nov 10th, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. protected void observeInstructionCount(Context cx, int instructionCount)
  2. {
  3. MyContext mcx = (MyContext)cx;
  4. long currentTime = System.currentTimeMillis();
  5. if (currentTime - mcx.startTime > 10*1000) {
  6. // More then 10 seconds from Context creation time:
  7. // it is time to stop the script.
  8. // Throw Error instance to ensure that script will never
  9. // get control back through catch or finally.
  10. throw new Error();
  11. }
  12. }
Add Comment
Please, Sign In to add comment