org.eclipse.jetty.servlet

## Class ServletHolder

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.servlet.Holder<javax.servlet.Servlet>
    - - org.eclipse.jetty.servlet.ServletHolder

- All Implemented Interfaces:
    java.lang.Comparable, UserIdentity.Scope, Dumpable, LifeCycle

      public class ServletHolder
      extends Holder<javax.servlet.Servlet>
      implements UserIdentity.Scope, 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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `ServletHolder.Config`
    `class` | `ServletHolder.Registration`

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.servlet.Holder

      `Holder.HolderConfig, Holder.HolderRegistration`

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `AbstractLifeCycle.AbstractLifeCycleListener`

    - ### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `LifeCycle.Listener`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.util.Map<java.lang.String,java.lang.String>` | `NO_MAPPED_ROLES`

    - ### Fields inherited from class org.eclipse.jetty.servlet.Holder

      `_asyncSupported, _class, _className, _displayName, _extInstance, _initParams, _name, _servletHandler`

    - ### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServletHolder()` Constructor .
    `ServletHolder(java.lang.Class<? extends javax.servlet.Servlet> servlet)` Constructor for servlet class.
    `ServletHolder(javax.servlet.Servlet servlet)` Constructor for existing servlet.
    `ServletHolder(java.lang.String name, java.lang.Class<? extends javax.servlet.Servlet> servlet)` Constructor for servlet class.
    `ServletHolder(java.lang.String name, javax.servlet.Servlet servlet)` Constructor for existing servlet.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkServletType()` Check to ensure class of servlet is acceptable.
    `int` | `compareTo(java.lang.Object o)` Comparitor by init order.
    `void` | `destroyInstance(java.lang.Object o)`
    `void` | `doStart()`
    `void` | `doStop()`
    `boolean` | `equals(java.lang.Object o)`
    `java.lang.String` | `getContextPath()`
    `java.lang.String` | `getForcedPath()`
    `int` | `getInitOrder()`
    `ServletRegistration.Dynamic` | `getRegistration()`
    `java.util.Map<java.lang.String,java.lang.String>` | `getRoleMap()`
    `java.util.Map<java.lang.String,java.lang.String>` | `getRoleRefMap()`
    `java.lang.String` | `getRunAsRole()`
    `javax.servlet.Servlet` | `getServlet()` Get the servlet.
    `javax.servlet.Servlet` | `getServletInstance()` Get the servlet instance (no initialization done).
    `javax.servlet.UnavailableException` | `getUnavailableException()`
    `java.lang.String` | `getUserRoleLink(java.lang.String name)` get a user role link.
    `void` | `handle(Request baseRequest, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)` Service a request with this servlet.
    `int` | `hashCode()`
    `protected void` | `initJspServlet()`
    `boolean` | `isAvailable()`
    `boolean` | `isSetInitOrder()`
    `protected javax.servlet.Servlet` | `newInstance()`
    `protected void` | `postInitJspServlet()`
    `void` | `setForcedPath(java.lang.String forcedPath)`
    `void` | `setInitOrder(int order)` Set the initialize order.
    `void` | `setRunAsRole(java.lang.String role)`
    `void` | `setServlet(javax.servlet.Servlet servlet)`
    `void` | `setUserRoleLink(java.lang.String name, java.lang.String link)` Link a user role.

    - ### Methods inherited from class org.eclipse.jetty.servlet.Holder

      `dump, dump, getClassName, getDisplayName, getHeldClass, getInitParameter, getInitParameterNames, getInitParameters, getName, getServletHandler, illegalStateIfContextStarted, isAsyncSupported, isInstance, setAsyncSupported, setClassName, setDisplayName, setHeldClass, setInitParameter, setInitParameters, setName, setServletHandler, toString`

    - ### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.jetty.server.UserIdentity.Scope

      `getName`

- - ### Field Detail

    - #### NO_MAPPED_ROLES

          public static final java.util.Map<java.lang.String,java.lang.String> NO_MAPPED_ROLES

  - ### Constructor Detail

    - #### ServletHolder

          public ServletHolder()

      Constructor .

    - #### ServletHolder

          public ServletHolder(java.lang.String name,
                       javax.servlet.Servlet servlet)

      Constructor for existing servlet.

    - #### ServletHolder

          public ServletHolder(javax.servlet.Servlet servlet)

      Constructor for existing servlet.

    - #### ServletHolder

          public ServletHolder(java.lang.String name,
                       java.lang.Class<? extends javax.servlet.Servlet> servlet)

      Constructor for servlet class.

    - #### ServletHolder

          public ServletHolder(java.lang.Class<? extends javax.servlet.Servlet> servlet)

      Constructor for servlet class.

  - ### Method Detail

    - #### getUnavailableException

          public javax.servlet.UnavailableException getUnavailableException()

      Returns:
        The unavailable exception or null if not unavailable

    - #### setServlet

          public void setServlet(javax.servlet.Servlet servlet)

    - #### 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.

    - #### isSetInitOrder

          public boolean isSetInitOrder()

    - #### 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)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### 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.

    - #### getRoleMap

          public java.util.Map<java.lang.String,java.lang.String> getRoleMap()

    - #### getForcedPath

          public java.lang.String getForcedPath()

      Returns:
        Returns the forcedPath.

    - #### setForcedPath

          public void setForcedPath(java.lang.String forcedPath)

      Parameters:
        `forcedPath` - The forcedPath to set.

    - #### doStart

          public void doStart()
                       throws java.lang.Exception

      Overrides:
        `doStart` in class `Holder<javax.servlet.Servlet>`
      Throws:
        `java.lang.Exception`

    - #### doStop

          public void doStop()
                      throws java.lang.Exception

      Overrides:
        `doStop` in class `Holder<javax.servlet.Servlet>`
      Throws:
        `java.lang.Exception`

    - #### destroyInstance

          public void destroyInstance(java.lang.Object o)
                               throws java.lang.Exception

      Overrides:
        `destroyInstance` in class `Holder<javax.servlet.Servlet>`
      Throws:
        `java.lang.Exception`

    - #### getServlet

          public javax.servlet.Servlet getServlet()
                                           throws javax.servlet.ServletException

      Get the servlet.
      Returns:
        The servlet
      Throws:
        `javax.servlet.ServletException`

    - #### getServletInstance

          public javax.servlet.Servlet getServletInstance()

      Get the servlet instance (no initialization done).
      Returns:
        The servlet or null

    - #### checkServletType

          public void checkServletType()
                                throws javax.servlet.UnavailableException

      Check to ensure class of servlet is acceptable.
      Throws:
        `javax.servlet.UnavailableException`

    - #### isAvailable

          public boolean isAvailable()

      Returns:
        true if the holder is started and is not unavailable

    - #### initJspServlet

          protected void initJspServlet()
                                 throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### postInitJspServlet

          protected void postInitJspServlet()
                                     throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### getContextPath

          public java.lang.String getContextPath()

      Specified by:
        `getContextPath` in interface `UserIdentity.Scope`
      Returns:
        The context path that the identity is being considered within
      See Also:
        `UserIdentity.Scope.getContextPath()`

    - #### getRoleRefMap

          public java.util.Map<java.lang.String,java.lang.String> getRoleRefMap()

      Specified by:
        `getRoleRefMap` in interface `UserIdentity.Scope`
      Returns:
        A map of role reference names that converts from names used by application code to names used by the context deployment.
      See Also:
        `UserIdentity.Scope.getRoleRefMap()`

    - #### getRunAsRole

          public java.lang.String getRunAsRole()

    - #### setRunAsRole

          public void setRunAsRole(java.lang.String role)

    - #### handle

          public void handle(Request baseRequest,
                    javax.servlet.ServletRequest request,
                    javax.servlet.ServletResponse response)
                      throws javax.servlet.ServletException,
                             javax.servlet.UnavailableException,
                             java.io.IOException

      Service a request with this servlet.
      Throws:
        `javax.servlet.ServletException`
        `javax.servlet.UnavailableException`
        `java.io.IOException`

    - #### getRegistration

          public ServletRegistration.Dynamic getRegistration()

    - #### newInstance

          protected javax.servlet.Servlet newInstance()
                                               throws javax.servlet.ServletException,
                                                      java.lang.IllegalAccessException,
                                                      java.lang.InstantiationException

      Returns:
        the newly created Servlet instance
      Throws:
        `javax.servlet.ServletException`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`

Copyright © 2013 FuseSource, Corp.. All Rights Reserved.