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

📄 servletwrapper.java

📁 这是一个法律事务所系统源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation.  All rights  * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer.  * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, if *    any, must include the following acknowlegement:   *       "This product includes software developed by the  *        Apache Software Foundation (http://www.apache.org/)." *    Alternately, this acknowlegement may appear in the software itself, *    if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software *    Foundation" must not be used to endorse or promote products derived *    from this software without prior written permission. For written  *    permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" *    nor may "Apache" appear in their names without prior written *    permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation.  For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.core;import org.apache.tomcat.facade.*;import org.apache.tomcat.util.*;import java.io.*;import java.net.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;/** * Class used to represent a servlet inside a Context. *  * @author James Duncan Davidson [duncan@eng.sun.com] * @author Jason Hunter [jch@eng.sun.com] * @author James Todd [gonzo@eng.sun.com] * @author Harish Prabandham * @author costin@dnt.ro */public class ServletWrapper extends Handler {    // servletName is stored in config!    protected String servletName;    protected String servletClassName; // required    protected Class servletClass;    protected Servlet servlet;    // facade    protected ServletConfig configF;    // Jsp pages    private String path = null;    // optional informations    protected String description = null;    // If init() fails, this will keep the reason.    // init may be called when the servlet starts, but we need to    // report the error later, to the client    Exception unavailable=null;    long unavailableTime=-1;        // Usefull info for class reloading    protected boolean isReloadable = false;    // information + make sure destroy is called when no other servlet    // is running ( this have to be revisited !)     protected long lastAccessed;    protected int serviceCount = 0;        boolean loadOnStartup=false;    int loadOnStartupLevel=-1;    Hashtable securityRoleRefs=new Hashtable();    public ServletWrapper() {    }    public void setContext( Context context) {	super.setContext( context );	isReloadable=context.getReloadable();        configF = context.getFacadeManager().createServletConfig( this );    }    public String toString() {	return name + "(" + servletClassName + "/" + path + ")";    }        // -------------------- Servlet specific properties     public void setLoadOnStartUp( int level ) {    loadOnStartupLevel=level;    loadOnStartup=true;    }    public void setLoadOnStartUp( String level ) {    if (level.length() > 0)        loadOnStartupLevel=new Integer(level).intValue();    loadOnStartup=true;    }    public boolean getLoadOnStartUp() {	return loadOnStartup;    }    public int getLoadOnStartUpLevel() {	return loadOnStartupLevel;    }     void setReloadable(boolean reloadable) {	isReloadable = reloadable;    }    public String getServletName() {	if(name!=null) return name;	return path;    }    public void setServletName(String servletName) {        this.servletName=servletName;	name=servletName;    }    public String getServletDescription() {        return this.description;    }    public void setDescription( String d ) {	description=d;    }        public void setServletDescription(String description) {        this.description = description;    }    public String getServletClass() {        return this.servletClassName;    }    public void setServletClass(String servletClassName) {	if( name==null ) name=servletClassName;	this.servletClassName = servletClassName;	servlet=null; // reset the servlet, if it was set	servletClass=null;	initialized=false;    }    /** Security Role Ref represent a mapping between servlet role names and     *  server roles     */    public void addSecurityMapping( String name, String role,				    String description ) {	securityRoleRefs.put( name, role );    }    public String getSecurityRole( String name ) {	return (String)securityRoleRefs.get( name );    }    // -------------------- Jsp specific code    // Will go in JspHandler        public String getPath() {        return this.path;    }    public void setPath(String path) {        this.path = path;    }    // --------------------     public Servlet getServlet() {	if(servlet==null) {	    try {		loadServlet();	    } 	catch( Exception ex ) {		ex.printStackTrace();	    }	}	return servlet;    }    protected void doDestroy() throws TomcatException {	synchronized (this) {	    // Fancy sync logic is to make sure that no threads are in the	    // handlerequest when this is called and, furthermore, that	    // no threads go through handle request after this method starts!	    // Wait until there are no outstanding service calls,	    // or until 30 seconds have passed (to avoid a hang)			    //XXX I don't think it works ( costin )	    	    // XXX Move it to an interceptor!!!!	    while (serviceCount > 0) {		try {		    wait(30000);		    break;		} catch (InterruptedException e) { }	    }	    try {		if( servlet!=null) 		    servlet.destroy();	    } catch(Exception ex) {		// Should never come here...		context.log( "Error in destroy ", ex );	    }	}    }    /** Load and init a the servlet pointed by this wrapper

⌨️ 快捷键说明

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