Example #1
0
  public static void deploy(org.apache.catalina.Context context) throws ScriptException {
    ServletContext ctx = context.getServletContext();
    JaggeryContext sharedContext = new JaggeryContext();
    Context cx = Context.getCurrentContext();
    CommonManager.initContext(sharedContext);

    sharedContext.addProperty(Constants.SERVLET_CONTEXT, ctx);
    sharedContext.addProperty(FileHostObject.JAVASCRIPT_FILE_MANAGER, new WebAppFileManager(ctx));
    sharedContext.addProperty(
        Constants.JAGGERY_REQUIRED_MODULES, new HashMap<String, ScriptableObject>());
    String logLevel = (String) ctx.getAttribute(LogHostObject.LOG_LEVEL);
    if (logLevel != null) {
      sharedContext.addProperty(LogHostObject.LOG_LEVEL, logLevel);
    }
    ScriptableObject sharedScope = sharedContext.getScope();
    JavaScriptProperty application = new JavaScriptProperty("application");
    application.setValue(cx.newObject(sharedScope, "Application", new Object[] {ctx}));
    application.setAttribute(ScriptableObject.READONLY);
    RhinoEngine.defineProperty(sharedScope, application);
    ctx.setAttribute(SHARED_JAGGERY_CONTEXT, sharedContext);
  }
Example #2
0
 public static void initContext(Context cx, JaggeryContext context) throws ScriptException {
   CommonManager.initContext(context);
   defineProperties(cx, context, context.getScope());
 }