jfun.yan.web
Class YanLoaderServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by jfun.yan.web.YanLoaderServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class YanLoaderServlet
extends javax.servlet.http.HttpServlet

Major portion of this class is copied from the Spring framework.

Bootstrap servlet to start up Yan's root container. Simply delegates to YanLoader.

This servlet should have a lower load-on-startup value in web.xml than any servlets that access the root web application context.

Note that this class has been deprecated for containers implementing Servlet API 2.4 or higher, in favor of YanLoaderListener.
According to Servlet 2.4, listeners must be initialized before load-on-startup servlets. Many Servlet 2.3 containers already enforce this behavior. If you use such a container, this servlet can be replaced with YanLoaderListener. Else or if working with a Servlet 2.2 container, stick with this servlet.

Servlet 2.3 containers known to work with bootstrap listeners are:

For working with any of them, YanLoaderListener is recommended.

Servlet 2.3 containers known not to work with bootstrap listeners are:

If you happen to work with such a server, this servlet has to be used.

So unfortunately, the only context initialization option that is compatible with all Servlet 2.3 containers is this servlet.

Note that a startup failure of this servlet will not stop the rest of the web application from starting, in contrast to a listener failure. This can lead to peculiar side effects if other servlets get started that depend on initialization of the root web application context.

Author:
Ben Yu.
See Also:
YanLoader, YanLoaderListener, Serialized Form

Constructor Summary
YanLoaderServlet()
           
 
Method Summary
protected  YanLoader createYanLoader()
          Create the YanLoader to use.
 void destroy()
          Close the root web application context.
 java.lang.String getServletInfo()
           
 YanLoader getYanLoader()
          Return the YanLoader used by this servlet.
 void init()
          Initialize the root web application context.
 void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This should never even be called since no mapping to this servlet should ever be created in web.xml.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

YanLoaderServlet

public YanLoaderServlet()
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Initialize the root web application context.

Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

createYanLoader

protected YanLoader createYanLoader()
Create the YanLoader to use. Can be overridden in subclasses.

Returns:
the new YanLoader

getYanLoader

public YanLoader getYanLoader()
Return the YanLoader used by this servlet.


destroy

public void destroy()
Close the root web application context.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

service

public void service(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response)
             throws java.io.IOException
This should never even be called since no mapping to this servlet should ever be created in web.xml. That's why a correctly invoked Servlet 2.3 listener is much more appropriate for initialization work ;-)

Overrides:
service in class javax.servlet.http.HttpServlet
Throws:
java.io.IOException

getServletInfo

public java.lang.String getServletInfo()
Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class javax.servlet.GenericServlet