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

📄 webappcontext.java

📁 jetty SERVER連接資料庫用的軟體
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    }    /* ------------------------------------------------------------ */    /**     * The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml     * @param defaultsDescriptor The overrideDescritpor to set.     */    public void setOverrideDescriptor(String overrideDescriptor)    {        _overrideDescriptor = overrideDescriptor;    }    /* ------------------------------------------------------------ */    /**     * @return the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists.     */    public String getDescriptor()    {        return _descriptor;    }    /* ------------------------------------------------------------ */    /**     * @param descriptor the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists.     */    public void setDescriptor(String descriptor)    {        _descriptor=descriptor;    }        /* ------------------------------------------------------------ */    /**     * @param distributable The distributable to set.     */    public void setDistributable(boolean distributable)    {        this._distributable = distributable;    }    /* ------------------------------------------------------------ */    public void setEventListeners(EventListener[] eventListeners)    {        if (_sessionHandler!=null)            _sessionHandler.clearEventListeners();                    super.setEventListeners(eventListeners);              for (int i=0; eventListeners!=null && i<eventListeners.length;i ++)        {            EventListener listener = eventListeners[i];                        if ((listener instanceof HttpSessionActivationListener)                            || (listener instanceof HttpSessionAttributeListener)                            || (listener instanceof HttpSessionBindingListener)                            || (listener instanceof HttpSessionListener))            {                if (_sessionHandler!=null)                    _sessionHandler.addEventListener(listener);            }                    }    }    /* ------------------------------------------------------------ */    /** Add EventListener     * Conveniance method that calls {@link #setEventListeners(EventListener[])}     * @param listener     */    public void addEventListener(EventListener listener)    {        setEventListeners((EventListener[])LazyList.addToArray(getEventListeners(), listener, EventListener.class));       }        /* ------------------------------------------------------------ */    /**     * @param extractWAR True if war files are extracted     */    public void setExtractWAR(boolean extractWAR)    {        _extractWAR = extractWAR;    }        /* ------------------------------------------------------------ */    /**     *      * @param copy True if the webdir is copied (to allow hot replacement of jars)     */    public void setCopyWebDir(boolean copy)    {        _copyDir = copy;    }    /* ------------------------------------------------------------ */    /**     * @param java2compliant The java2compliant to set.     */    public void setParentLoaderPriority(boolean java2compliant)    {        _parentLoaderPriority = java2compliant;    }    /* ------------------------------------------------------------ */    /**     * @param permissions The permissions to set.     */    public void setPermissions(PermissionCollection permissions)    {        _permissions = permissions;    }    /* ------------------------------------------------------------ */    /**     * @param serverClasses The serverClasses to set.     */    public void setServerClasses(String[] serverClasses)     {        _serverClasses = serverClasses==null?null:(String[])serverClasses.clone();    }        /* ------------------------------------------------------------ */    /**     * @param systemClasses The systemClasses to set.     */    public void setSystemClasses(String[] systemClasses)    {        _systemClasses = systemClasses==null?null:(String[])systemClasses.clone();    }        /* ------------------------------------------------------------ */    /** Set temporary directory for context.     * The javax.servlet.context.tempdir attribute is also set.     * @param dir Writable temporary directory.     */    public void setTempDirectory(File dir)    {        if (isStarted())            throw new IllegalStateException("Started");        if (dir!=null)        {            try{dir=new File(dir.getCanonicalPath());}            catch (IOException e){Log.warn(Log.EXCEPTION,e);}        }        if (dir!=null && !dir.exists())        {            dir.mkdir();            dir.deleteOnExit();        }        else if (dir != null)            _isExistingTmpDir = true;        if (dir!=null && ( !dir.exists() || !dir.isDirectory() || !dir.canWrite()))            throw new IllegalArgumentException("Bad temp directory: "+dir);        _tmpDir=dir;        setAttribute(ServletHandler.__J_S_CONTEXT_TEMPDIR,_tmpDir);    }        /* ------------------------------------------------------------ */    /**     * @param war The war to set as a file name or URL     */    public void setWar(String war)    {        _war = war;    }    /* ------------------------------------------------------------ */    /**     * @return Comma or semicolon separated path of filenames or URLs     * pointing to directories or jar files. Directories should end     * with '/'.     */    public String getExtraClasspath()    {        return _extraClasspath;    }    /* ------------------------------------------------------------ */    /**     * @param extraClasspath Comma or semicolon separated path of filenames or URLs     * pointing to directories or jar files. Directories should end     * with '/'.     */    public void setExtraClasspath(String extraClasspath)    {        _extraClasspath=extraClasspath;    }    /* ------------------------------------------------------------ */    public boolean isLogUrlOnStart()     {        return _logUrlOnStart;    }    /* ------------------------------------------------------------ */    /**     * Sets whether or not the web app name and URL is logged on startup     *     * @param logOnStart whether or not the log message is created     */    public void setLogUrlOnStart(boolean logOnStart)     {        this._logUrlOnStart = logOnStart;    }    /* ------------------------------------------------------------ */    protected void startContext()        throws Exception    {        // Configure defaults        for (int i=0;i<_configurations.length;i++)            _configurations[i].configureDefaults();                // Is there a WEB-INF work directory        Resource web_inf=getWebInf();        if (web_inf!=null)        {            Resource work= web_inf.addPath("work");            if (work.exists()                            && work.isDirectory()                            && work.getFile() != null                            && work.getFile().canWrite()                            && getAttribute(ServletHandler.__J_S_CONTEXT_TEMPDIR) == null)                setAttribute(ServletHandler.__J_S_CONTEXT_TEMPDIR, work.getFile());        }                // Configure webapp        for (int i=0;i<_configurations.length;i++)            _configurations[i].configureWebApp();                super.startContext();    }        /**     * Create a canonical name for a webapp tmp directory.     * The form of the name is:     *  "Jetty_"+host+"_"+port+"__"+resourceBase+"_"+context+"_"+virtualhost+base36 hashcode of whole string     *       *  host and port uniquely identify the server     *  context and virtual host uniquely identify the webapp     * @return     */    private String getCanonicalNameForWebAppTmpDir ()    {        StringBuffer canonicalName = new StringBuffer();        canonicalName.append("Jetty");               //get the host and the port from the first connector         Connector[] connectors = getServer().getConnectors();                        //Get the host        canonicalName.append("_");        String host = (connectors==null||connectors[0]==null?"":connectors[0].getHost());        if (host == null)            host = "0.0.0.0";        canonicalName.append(host.replace('.', '_'));                //Get the port        canonicalName.append("_");        //try getting the real port being listened on        int port = (connectors==null||connectors[0]==null?0:connectors[0].getLocalPort());        //if not available (eg no connectors or connector not started),         //try getting one that was configured.        if (port < 0)            port = connectors[0].getPort();        canonicalName.append(port);               //Resource  base        canonicalName.append("_");        try        {            Resource resource = super.getBaseResource();            if (resource == null)            {                if (_war==null || _war.length()==0)                    resource=Resource.newResource(getResourceBase());                                // Set dir or WAR                resource= Resource.newResource(_war);            }                            String tmp = URIUtil.decodePath(resource.getURL().getPath());            if (tmp.endsWith("/"))                tmp = tmp.substring(0, tmp.length()-1);            if (tmp.endsWith("!"))                tmp = tmp.substring(0, tmp.length() -1);            //get just the last part which is the filename            int i = tmp.lastIndexOf("/");                        canonicalName.append(tmp.substring(i+1, tmp.length()));        }        catch (Exception e)        {            Log.warn("Can't generate resourceBase as part of webapp tmp dir name", e);        }                    //Context name        canonicalName.append("_");        String contextPath = getContextPath();        contextPath=contextPath.replace('/','_');        contextPath=contextPath.replace('\\','_');        canonicalName.append(contextPath);                //Virtual host (if there is one)        canonicalName.append("_");        String[] vhosts = getVirtualHosts();        canonicalName.append((vhosts==null||vhosts[0]==null?"":vhosts[0]));                //base36 hash of the whole string for uniqueness        String hash = Integer.toString(canonicalName.toString().hashCode(),36);        canonicalName.append("_");        canonicalName.append(hash);                // sanitize        for (int i=0;i<canonicalName.length();i++)        {        	char c=canonicalName.charAt(i);        	if (!Character.isJavaIdentifierPart(c))        		canonicalName.setCharAt(i,'.');        }          return canonicalName.toString();    }}

⌨️ 快捷键说明

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