}
private static void executeScripts(Context context, JSONArray arr) {
if (arr != null) {
try {
JaggeryContext sharedContext = WebAppManager.sharedJaggeryContext(context.getServletContext());
CommonManager.setJaggeryContext(sharedContext);
RhinoEngine engine = sharedContext.getEngine();
org.mozilla.javascript.Context cx = engine.enterContext();
ServletContext servletContext = (ServletContext) sharedContext.getProperty(
org.jaggeryjs.hostobjects.web.Constants.SERVLET_CONTEXT);
ScriptableObject sharedScope = sharedContext.getScope();
Object[] scripts = arr.toArray();
for (Object script : scripts) {
if (!(script instanceof String)) {
log.error("Invalid value for initScripts/destroyScripts in jaggery.conf : " + script);
continue;
}
String path = (String) script;
path = path.startsWith("/") ? path : "/" + path;
Stack<String> callstack = CommonManager.getCallstack(sharedContext);
callstack.push(path);
String[] parts = WebAppManager.getKeys(servletContext.getContextPath(), path, path);
ScriptCachingContext sctx = new ScriptCachingContext(sharedContext.getTenantId(),
parts[0], parts[1], parts[2]);
sctx.setSecurityDomain(new JaggerySecurityDomain(path, servletContext));
engine.exec(new ScriptReader(servletContext.getResourceAsStream(path)) {
@Override
protected void build() throws IOException {