javax.servlet.Servlet#getServletConfig ( )源码实例Demo

下面列出了javax.servlet.Servlet#getServletConfig ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Advice.OnMethodEnter(suppress = Throwable.class)
@SuppressWarnings("Duplicates") // duplication is fine here as it allows to inline code
private static void onEnter(@Advice.This Servlet servlet) {
    if (alreadyLogged) {
        return;
    }
    alreadyLogged = true;

    ServletConfig servletConfig = servlet.getServletConfig();

    int majorVersion = -1;
    int minorVersion = -1;
    String serverInfo = null;
    if (servletConfig != null) {
        ServletContext servletContext = servletConfig.getServletContext();
        if (null != servletContext) {
            majorVersion = servletContext.getMajorVersion();
            minorVersion = servletContext.getMinorVersion();
            serverInfo = servletContext.getServerInfo();
        }
    }

    logger.info("Servlet container info = {}", serverInfo);
    if (majorVersion < 3) {
        logger.warn("Unsupported servlet version detected: {}.{}, no Servlet transaction will be created", majorVersion, minorVersion);
    }
}
 
源代码2 项目: knopflerfish.org   文件: ServletRegistration.java
public void destroy()
{
  final Servlet servlet = dispatcher.getServlet();
  final ServletConfig cfg = servlet.getServletConfig();
  final ServletContext context = cfg != null ? cfg.getServletContext() : null;
  servlet.destroy();
  if (context != null) {
    contextManager.ungetServletContext(context);
  }
  registrations.removeServlet(servlet);
}
 
源代码3 项目: packagedrone   文件: PageContextImpl.java
private void _initialize(Servlet servlet,
		     ServletRequest request,
		     ServletResponse response,
		     String errorPageURL,
		     boolean needsSession,
		     int bufferSize,
		     boolean autoFlush) throws IOException {

// initialize state
this.servlet = servlet;
this.config = servlet.getServletConfig();
this.context = config.getServletContext();
this.needsSession = needsSession;
this.errorPageURL = errorPageURL;
this.bufferSize = bufferSize;
this.request = request;
	this.response = response;

// Setup session (if required)
if (request instanceof HttpServletRequest && needsSession)
    this.session = ((HttpServletRequest)request).getSession();
if (needsSession && session == null)
    throw new IllegalStateException
               ("Page needs a session and none is available");

       // initialize the initial out ...
       depth = -1;
       if (this.baseOut == null) {
           this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
       } else {
           this.baseOut.init(response, bufferSize, autoFlush);
       }
       this.out = baseOut;

       this.isNametableInitialized = false;
       setAttribute(Constants.FIRST_REQUEST_SEEN, "true", APPLICATION_SCOPE);

   }
 
源代码4 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
@Override
public void initialize(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL,
        boolean needsSession, int bufferSize, boolean autoFlush)
        throws IOException {

    // initialize state
    this.servlet = servlet;
    this.config = servlet.getServletConfig();
    this.context = config.getServletContext();
    this.errorPageURL = errorPageURL;
    this.request = request;
    this.response = response;

    // initialize application context
    this.applicationContext = JspApplicationContextImpl.getInstance(context);

    // Setup session (if required)
    if (request instanceof HttpServletRequest && needsSession)
        this.session = ((HttpServletRequest) request).getSession();
    if (needsSession && session == null)
        throw new IllegalStateException(
                "Page needs a session and none is available");

    // initialize the initial out ...
    depth = -1;
    if (bufferSize == JspWriter.DEFAULT_BUFFER) {
        bufferSize = Constants.DEFAULT_BUFFER_SIZE;
    }
    if (this.baseOut == null) {
        this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
    } else {
        this.baseOut.init(response, bufferSize, autoFlush);
    }
    this.out = baseOut;

    // register names/values as per spec
    setAttribute(OUT, this.out);
    setAttribute(REQUEST, request);
    setAttribute(RESPONSE, response);

    if (session != null)
        setAttribute(SESSION, session);

    setAttribute(PAGE, servlet);
    setAttribute(CONFIG, config);
    setAttribute(PAGECONTEXT, this);
    setAttribute(APPLICATION, context);

    isIncluded = request.getAttribute(
            RequestDispatcher.INCLUDE_SERVLET_PATH) != null;
}
 
源代码5 项目: Tomcat7.0.67   文件: PageContextImpl.java
private void _initialize(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL,
        boolean needsSession, int bufferSize, boolean autoFlush) {

    // initialize state
    this.servlet = servlet;
    this.config = servlet.getServletConfig();
    this.context = config.getServletContext();
    this.errorPageURL = errorPageURL;
    this.request = request;
    this.response = response;
    
    // initialize application context
    this.applicationContext = JspApplicationContextImpl.getInstance(context);

    // Setup session (if required)
    if (request instanceof HttpServletRequest && needsSession)
        this.session = ((HttpServletRequest) request).getSession();
    if (needsSession && session == null)
        throw new IllegalStateException(
                "Page needs a session and none is available");

    // initialize the initial out ...
    depth = -1;
    if (bufferSize == JspWriter.DEFAULT_BUFFER) {
        bufferSize = Constants.DEFAULT_BUFFER_SIZE;
    }
    if (this.baseOut == null) {
        this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
    } else {
        this.baseOut.init(response, bufferSize, autoFlush);
    }
    this.out = baseOut;

    // register names/values as per spec
    setAttribute(OUT, this.out);
    setAttribute(REQUEST, request);
    setAttribute(RESPONSE, response);

    if (session != null)
        setAttribute(SESSION, session);

    setAttribute(PAGE, servlet);
    setAttribute(CONFIG, config);
    setAttribute(PAGECONTEXT, this);
    setAttribute(APPLICATION, context);

    isIncluded = request.getAttribute(
            RequestDispatcher.INCLUDE_SERVLET_PATH) != null;
}
 
源代码6 项目: tomcatsrc   文件: PageContextImpl.java
private void _initialize(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL,
        boolean needsSession, int bufferSize, boolean autoFlush) {

    // initialize state
    this.servlet = servlet;
    this.config = servlet.getServletConfig();
    this.context = config.getServletContext();
    this.errorPageURL = errorPageURL;
    this.request = request;
    this.response = response;
    
    // initialize application context
    this.applicationContext = JspApplicationContextImpl.getInstance(context);

    // Setup session (if required)
    if (request instanceof HttpServletRequest && needsSession)
        this.session = ((HttpServletRequest) request).getSession();
    if (needsSession && session == null)
        throw new IllegalStateException(
                "Page needs a session and none is available");

    // initialize the initial out ...
    depth = -1;
    if (bufferSize == JspWriter.DEFAULT_BUFFER) {
        bufferSize = Constants.DEFAULT_BUFFER_SIZE;
    }
    if (this.baseOut == null) {
        this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
    } else {
        this.baseOut.init(response, bufferSize, autoFlush);
    }
    this.out = baseOut;

    // register names/values as per spec
    setAttribute(OUT, this.out);
    setAttribute(REQUEST, request);
    setAttribute(RESPONSE, response);

    if (session != null)
        setAttribute(SESSION, session);

    setAttribute(PAGE, servlet);
    setAttribute(CONFIG, config);
    setAttribute(PAGECONTEXT, this);
    setAttribute(APPLICATION, context);

    isIncluded = request.getAttribute(
            RequestDispatcher.INCLUDE_SERVLET_PATH) != null;
}
 
/**
 * Create a ServletConfiguration using the initialization parameter of
 * the specified servlet.
 *
 * @param servlet the servlet
 */
public ServletConfiguration(final Servlet servlet)
{
    this(servlet.getServletConfig());
}