org.mortbay.jetty.servlet
Class ServletHolder

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

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.53 2005/11/03 08:52:48 gregwilkins Exp $
Author:
Greg Wilkins
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.mortbay.jetty.servlet.Holder
_class, _className, _displayName, _httpHandler, _initParams, _name
 
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.
 int hashCode()
           
 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, getHttpContext, getHttpHandler, getInitParameter, getInitParameterNames, getInitParameters, getName, isStarted, newInstance, put, setDisplayName, setInitParameter, toString
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, 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

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map
Overrides:
hashCode 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 ServletException
Get the servlet.

Returns:
The servlet
Throws:
ServletException

handle

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

Throws:
ServletException
UnavailableException
java.io.IOException


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.