⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 applicationcontext.java

📁 一个工作流设计及定义的系统,可以直接与数据库结合进行系统工作流程的定义及应用.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        {            applicationDirectory += java.io.File.separator;            this.map.put(P_APPLICATION_DIRECTORY, applicationDirectory);        }        return applicationDirectory;    }    /**     * Sets this application context's [root|home] directory     */    public void setApplicationDirectory (final String path)    {        this.map.put(P_APPLICATION_DIRECTORY, path);    }    /**     * Returns the name of the application.     */    public String getApplicationName ()    {        return this.applicationName;    }    /**     * Returns the name of the application.     */    public String getName ()    {        return this.applicationName;    }    public java.util.Iterator serviceIterator ()    {        java.util.List result = new java.util.ArrayList(this.map.size());        java.util.Iterator it = this.map.values().iterator();        while (it.hasNext())        {            Object o = it.next();            if (o instanceof Service) result.add(o);        }        return result.iterator();    }    /**     * Returns the parent context of this context or null if it's a root     * or standalone context.     */    public ApplicationContext getParentContext ()    {        return this.parentContext;    }    /**     * Sets the parent of this application context     */    public void setParentContext (final ApplicationContext ac)    {        this.parentContext = ac;    }    /**     * This method is used by the StatusService to fill its reply     * with the status of all the services in an ApplicationContext     * (and in its subcontexts).     */    public void outputStatus (final org.jdom.Element rootElt)    {        //        // iterate on services        java.util.Iterator it = serviceIterator();        while (it.hasNext())        {            final Service s = (Service)it.next();            rootElt.addContent(s.getStatus());        }        it = this.map.values().iterator();        while (it.hasNext())        {            final Object o = it.next();            if (o instanceof ApplicationContext)            {                final ApplicationContext subContext = (ApplicationContext)o;                final org.jdom.Element subRootElt =                     new org.jdom.Element(subContext.getApplicationName());                subContext.outputStatus(subRootElt);                rootElt.addContent(subRootElt);            }        }        //        // add memory numbers                final org.jdom.Element efm = new org.jdom.Element("free-memory");        efm.addContent            (""+(Runtime.getRuntime().freeMemory() / 1000000.0d)+" MB");        final org.jdom.Element emm = new org.jdom.Element("max-memory");        emm.addContent            (""+(Runtime.getRuntime().maxMemory() / 1000000.0d)+" MB");        rootElt.addContent(efm);        rootElt.addContent(emm);    }    //    // STATIC METHODS    /**     * A static method for looking up a context just knowing its name.     */    public static ApplicationContext lookupContext (final String contextName)    {        return (ApplicationContext)contextMap.get(contextName);    }    /**     * The shared context is an empty context that can be filled with stuff     * shared by services and other instances in the same VM.     */    public static SharedApplicationContext lookupSharedContext ()    {        return (SharedApplicationContext)contextMap.get(SHARED);    }    static    {        SharedApplicationContext sac = new SharedApplicationContext();        contextMap.put(SHARED, sac);    }    /**     * This method shall be removed as of OpenWFE 1.5.0     */    public static Object lookup         (final ApplicationContext context,          final String key,          final String oldKey)    {        //if (context == null) return null;            // commented out as the potential NPE is instructive        final Object o = context.lookup(key);        if (o != null) return o;        return context.lookup(oldKey);    }    //    // METHODS from OwfeRunnable    /**     * Stops the services comprised in this application context      * and stops all the child subcontexts.     */    public void stop ()    {        setState(new StoppedState());        final java.util.Iterator it = this.map.values().iterator();        while (it.hasNext())        {            final Object item = it.next();            if (item instanceof OwfeRunnable)            {                final OwfeRunnable runnable = (OwfeRunnable)item;                try                {                    runnable.stop();                }                catch (ServiceException se)                {                    log.info                        ("stop() had trouble when stopping '"+                         runnable.getName()+"'",                          se);                }            }        }        log.info("stop() context '"+this.applicationName+"' stopped.");    }    /**     * Will start all the services and subcontext (OwfeRunnable instances in     * general) comprised in this context.     */    public void play ()    {        log.info("play() requested for service '"+getName()+"'");        if ( ! this.isRunning())             setState(new RunningState());        else            return;        final java.util.Iterator it = this.map.values().iterator();        while (it.hasNext())        {            final Object item = it.next();            if (item instanceof OwfeRunnable)            {                final OwfeRunnable runnable = (OwfeRunnable)item;                try                {                    runnable.play();                }                catch (ServiceException se)                {                    log.info                        ("play() had trouble when playing '"+                         runnable.getName()+"'",                          se);                }            }        }    }    /**     * Will pause all the services and subcontext (OwfeRunnable instances in     * general) comprised in this context.     */    public void pause ()    {        log.info("pause() requested for service '"+getName()+"'");        if (this.isRunning())             setState(new PausedState());        else            return;        final java.util.Iterator it = this.map.values().iterator();        while (it.hasNext())        {            final Object item = it.next();            if (item instanceof OwfeRunnable)            {                final OwfeRunnable runnable = (OwfeRunnable)item;                try                {                    runnable.pause();                }                catch (ServiceException se)                {                    log.info                        ("pause() had trouble when pausing '"+                         runnable.getName()+"'",                          se);                }            }        }    }    /**     * Returns the state in which the context currently is.     */    public ServiceState getState ()     {        return this.contextState;    }    /**     * Changes the state of the context (but not the state of the OwfeRunnable      * instances it contains).     */    protected void setState (ServiceState state)    {        this.contextState = state;    }    /**     * Will return true if the context is in RunningState (or any of the     * subclasses of this state class).     */    public boolean isRunning ()    {        return getState() instanceof RunningState;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -