org.mortbay.jetty.servlet
Class ServletHolder

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--org.mortbay.jetty.servlet.Holder
              |
              +--org.mortbay.jetty.servlet.ServletHolder
All Implemented Interfaces:
java.lang.Comparable, LifeCycle, java.util.Map, java.io.Serializable

public class ServletHolder
extends Holder
implements java.lang.Comparable

Servlet Instance and Context Holder. Holds the name, params and some state of a javax.servlet.Servlet instance. It implements the ServletConfig interface. This class will organise the loading of the servlet when needed or requested.

Version:
$Id: ServletHolder.java,v 1.35.2.3 2004/04/27 08:56:19 gregwilkins Exp $
Author:
Greg Wilkins
See Also:
Serialized Form

Constructor Summary
ServletHolder()
          Constructor for Serialization.
ServletHolder(ServletHandler handler, java.lang.String name, java.lang.String className)
          Constructor.
ServletHolder(ServletHandler handler, java.lang.String name, java.lang.String className, java.lang.String forcedPath)
          Constructor.
 
Method Summary
 int compareTo(java.lang.Object o)
          Comparitor by init order.
 boolean equals(java.lang.Object o)
           
 int getInitOrder()
           
 java.lang.String getRunAs()
           
 Servlet getServlet()
          Get the servlet.
 ServletContext getServletContext()
           
 java.lang.String getUserRoleLink(java.lang.String name)
          get a user role link.
 void handle(ServletRequest request, ServletResponse response)
          Service a request with this servlet.
 void setInitOrder(int order)
          Set the initialize order.
 void setRunAs(java.lang.String role)
           
 void setUserRoleLink(java.lang.String name, java.lang.String link)
          Link a user role.
 void start()
          Start the LifeCycle.
 void stop()
          Stop the LifeCycle.
 
Methods inherited from class org.mortbay.jetty.servlet.Holder
entrySet, get, getClassName, getDisplayName, getHttpHandler, getInitParameter, getInitParameterNames, getInitParameters, getName, isStarted, newInstance, put, setDisplayName, setInitParameter, toString
 
Methods inherited from class java.util.AbstractMap
clear, containsKey, containsValue, hashCode, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServletHolder

public ServletHolder()
Constructor for Serialization.


ServletHolder

public ServletHolder(ServletHandler handler,
                     java.lang.String name,
                     java.lang.String className)
Constructor.

Parameters:
handler - The ServletHandler instance for this servlet.
name - The name of the servlet.
className - The class name of the servlet.

ServletHolder

public ServletHolder(ServletHandler handler,
                     java.lang.String name,
                     java.lang.String className,
                     java.lang.String forcedPath)
Constructor.

Parameters:
handler - The ServletHandler instance for this servlet.
name - The name of the servlet.
className - The class name of the servlet.
forcedPath - If non null, the request attribute javax.servlet.include.servlet_path will be set to this path before service is called.
Method Detail

getInitOrder

public int getInitOrder()

setInitOrder

public void setInitOrder(int order)
Set the initialize order. Holders with order<0, are initialized on use. Those with order>=0 are initialized in increasing order when the handler is started.


compareTo

public int compareTo(java.lang.Object o)
Comparitor by init order.

Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map
Overrides:
equals in class java.util.AbstractMap

getServletContext

public ServletContext getServletContext()

setUserRoleLink

public void setUserRoleLink(java.lang.String name,
                            java.lang.String link)
Link a user role. Translate the role name used by a servlet, to the link name used by the container.

Parameters:
name - The role name as used by the servlet
link - The role name as used by the container.

getUserRoleLink

public java.lang.String getUserRoleLink(java.lang.String name)
get a user role link.

Parameters:
name - The name of the role
Returns:
The name as translated by the link. If no link exists, the name is returned.

setRunAs

public void setRunAs(java.lang.String role)
Parameters:
role - Role name that is added to UserPrincipal when this servlet is called.

getRunAs

public java.lang.String getRunAs()

start

public void start()
           throws java.lang.Exception
Description copied from interface: LifeCycle
Start the LifeCycle.

Specified by:
start in interface LifeCycle
Overrides:
start in class Holder
Throws:
java.lang.Exception - An arbitrary exception may be thrown.

stop

public void stop()
Description copied from interface: LifeCycle
Stop the LifeCycle. The LifeCycle may wait for current activities to complete normally, but it can be interrupted.

Specified by:
stop in interface LifeCycle
Overrides:
stop in class Holder

getServlet

public Servlet getServlet()
                   throws UnavailableException
Get the servlet.

Returns:
The servlet
UnavailableException

handle

public void handle(ServletRequest request,
                   ServletResponse response)
            throws ServletException,
                   UnavailableException,
                   java.io.IOException
Service a request with this servlet.

ServletException
UnavailableException
java.io.IOException


Copyright ? 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.