public void init()

in flow/src/java/org/apache/struts/flow/FlowPlugIn.java [169:227]


    public void init(ActionServlet servlet, ModuleConfig config)
             throws ServletException {

        if ((scripts == null || scripts.length() == 0) && scriptBase == null) {
            throw new ServletException("No scripts or script base defined");
        }
        String key = INTERPRETER_KEY+"/"+config.getPrefix();
        context = servlet.getServletContext();
        Factory.setLogger(new CommonsLogger());
        Factory.getContinuationsManager().setDefaultTimeToLive(ttl);

        if (scripts != null && scripts.length() > 0) {
            CompilingInterpreter interp = createInterpreter(config.getPrefix());
            context.setAttribute(key, interp);
            String path = null;
            String paths = scripts;
            try {
                // Process each specified resource path
                while (paths.length() > 0) {
                    int comma = paths.indexOf(',');
                    if (comma >= 0) {
                        path = paths.substring(0, comma).trim();
                        paths = paths.substring(comma + 1);
                    } else {
                        path = paths.trim();
                        paths = "";
                    }
        
                    if (path.length() < 1) {
                        break;
                    }
                    if (log.isInfoEnabled()) {
                        log.info("Registering script '" + path + "'");
                    }
                    interp.register(path);
                }
            } catch (Exception ex) {
                throw new ServletException("Unable to create global JavaScript interpreter and register scripts", ex);
            }
        } else {
            Map map =
                new HashMap() {
                    public Object get(Object key) {
                        CompilingInterpreter interp = (CompilingInterpreter) super.get(key);
                        if (interp == null) {
                            if (log.isDebugEnabled()) {
                                log.debug("Creating interpreter for " + key);
                            }
                            interp = createInterpreter(key.toString());
                            interp.register(scriptBase + key);
                            put(key, interp);
                        }
                        return interp;
                    }
                };
            log.debug("Pushing interpreter map in context: "+key);
            context.setAttribute(key, map);
        }
    }