running = true;   typemgr = new TypeManager(this); try { typemgr.createPrototypes(); } catch (Exception x) { logError("Error creating prototypes", x); }     Thread.currentThread().setContextClassLoader(typemgr.getClassLoader());  if (Server.getServer() != null) { Vector extensions = Server.getServer().getExtensions();  for (int i = 0; i < extensions.size(); i++) { HelmaExtension ext = (HelmaExtension) extensions.get(i);  try { ext.applicationStarted(this); } catch (ConfigurationException e) { logEvent("couldn't init extension " + ext.getName() + ": " + e.toString()); } } }   freeThreads = new Stack(); allThreads = new Vector();   int minThreads = 0;  try { minThreads = Integer.parseInt(props.getProperty("minThreads")); } catch (Exception ignore) {  }  if (minThreads > 0) { logEvent("Starting "+minThreads+" evaluator(s) for " + name); }  for (int i = 0; i < minThreads; i++) { RequestEvaluator ev = new RequestEvaluator(this);  if (i == 0) { ev.initScriptingEngine(); } freeThreads.push(ev); allThreads.addElement(ev); }  activeRequests = new Hashtable(); activeCronJobs = new WeakHashMap(); customCronJobs = new Hashtable();   skinmgr = new SkinManager(this);   rootId = props.getProperty("rootid", "0"); rootPrototype = props.getProperty("rootprototype", "root"); userPrototype = props.getProperty("userprototype", "user");  rootMapping = getDbMapping(rootPrototype); if (rootMapping == null) throw new RuntimeException("rootPrototype does not exist: " + rootPrototype); userMapping = getDbMapping(userPrototype); if (userMapping == null) throw new RuntimeException("userPrototype does not exist: " + userPrototype);    ResourceProperties p = new ResourceProperties(); String usernameField = (userMapping != null) ? userMapping.getNameField() : null;  if (usernameField == null) { usernameField = "name"; }  p.put("_children", "collection(" + userPrototype + ")"); p.put("_children.accessname", usernameField); userRootMapping = new DbMapping(this, "__userroot__", p); userRootMapping.update();   nmgr = new NodeManager(this); nmgr.init(dbDir.getAbsoluteFile(), props);   String sessionMgrImpl = props.getProperty("sessionManagerImpl", "helma.framework.core.SessionManager"); sessionMgr = (SessionManager) Class.forName(sessionMgrImpl).newInstance(); logEvent("Using session manager class " + sessionMgrImpl); sessionMgr.init(this);   if ("true".equalsIgnoreCase(getProperty("persistentSessions"))) { sessionMgr.loadSessionData(null); }   Thread.currentThread().setContextClassLoader(typemgr.getClassLoader().getParent());
init(null);
    public synchronized void init()            throws DatabaseException, IllegalAccessException,                   InstantiationException, ClassNotFoundException {        running = true;        // create and init type mananger        typemgr = new TypeManager(this);        try {            typemgr.createPrototypes();        } catch (Exception x) {            logError("Error creating prototypes", x);        }        // set the context classloader. Note that this must be done before        // using the logging framework so that a new LogFactory gets created        // for this app.        Thread.currentThread().setContextClassLoader(typemgr.getClassLoader());        if (Server.getServer() != null) {            Vector extensions = Server.getServer().getExtensions();            for (int i = 0; i < extensions.size(); i++) {                HelmaExtension ext = (HelmaExtension) extensions.get(i);                try {                    ext.applicationStarted(this);                } catch (ConfigurationException e) {                    logEvent("couldn't init extension " + ext.getName() + ": " +                             e.toString());                }            }        }        // create and init evaluator/thread lists        freeThreads = new Stack();        allThreads = new Vector();        // preallocate minThreads request evaluators        int minThreads = 0;        try {            minThreads = Integer.parseInt(props.getProperty("minThreads"));        } catch (Exception ignore) {            // not parsable as number, keep 0        }        if (minThreads > 0) {            logEvent("Starting "+minThreads+" evaluator(s) for " + name);        }        for (int i = 0; i < minThreads; i++) {            RequestEvaluator ev = new RequestEvaluator(this);            if (i == 0) {                ev.initScriptingEngine();            }            freeThreads.push(ev);            allThreads.addElement(ev);        }        activeRequests = new Hashtable();        activeCronJobs = new WeakHashMap();        customCronJobs = new Hashtable();        // create the skin manager        skinmgr = new SkinManager(this);        // read in root id, root prototype, user prototype        rootId = props.getProperty("rootid", "0");        rootPrototype = props.getProperty("rootprototype", "root");        userPrototype = props.getProperty("userprototype", "user");        rootMapping = getDbMapping(rootPrototype);        if (rootMapping == null)            throw new RuntimeException("rootPrototype does not exist: " + rootPrototype);        userMapping = getDbMapping(userPrototype);        if (userMapping == null)            throw new RuntimeException("userPrototype does not exist: " + userPrototype);        // The whole user/userroot handling is basically old        // ugly obsolete crap. Don't bother.        ResourceProperties p = new ResourceProperties();        String usernameField = (userMapping != null) ? userMapping.getNameField() : null;        if (usernameField == null) {            usernameField = "name";        }        p.put("_children", "collection(" + userPrototype + ")");        p.put("_children.accessname", usernameField);        userRootMapping = new DbMapping(this, "__userroot__", p);        userRootMapping.update();        // create the node manager        nmgr = new NodeManager(this);        nmgr.init(dbDir.getAbsoluteFile(), props);        // create and init session manager        String sessionMgrImpl = props.getProperty("sessionManagerImpl",                                                  "helma.framework.core.SessionManager");        sessionMgr = (SessionManager) Class.forName(sessionMgrImpl).newInstance();        logEvent("Using session manager class " + sessionMgrImpl);        sessionMgr.init(this);        // read the sessions if wanted        if ("true".equalsIgnoreCase(getProperty("persistentSessions"))) {            sessionMgr.loadSessionData(null);        }        // reset the classloader to the parent/system/server classloader.        Thread.currentThread().setContextClassLoader(typemgr.getClassLoader().getParent());    }