## org.w3c.jigsaw.servlet
Class ServletWrapper

    java.lang.Object
      |
      +--org.w3c.tools.resources.AttributeHolder
            |
            +--org.w3c.tools.resources.Resource
                  |
                  +--org.w3c.tools.resources.FramedResource
                        |
                        +--org.w3c.jigsaw.servlet.ServletWrapper

Direct Known Subclasses:
  RemoteServletWrapper

public class ServletWrapper
extends FramedResource
implements javax.servlet.ServletConfig

Inner Class Summary
`protected class` `ServletWrapper.TimeoutManager`

Field Summary
`protected static int` `ATTR_PARAMETERS` Attribute index - The init parameters for that servlet.
`protected static int` `ATTR_SERVLET_CLASS` Attributes index - The servlet class name.
`protected static int` `ATTR_SERVLET_CONTEXT` Attribute index - Our parent-inherited servlet context.
`protected static int` `ATTR_SERVLET_INSTANCEMAX` Attributes index - The servlet maxinstances for single thread model servlet instance pool size limitation, tk, 20.10.2001
`protected static int` `ATTR_SERVLET_TIMEOUT` Attributes index - The servlet timeout
`protected static int` `ATTR_SESSION_CONTEXT` Attribute index - Our parent-inherited session context.
`protected static boolean` `debug`
`static java.lang.String` `ENDED`
`protected boolean` `inited` Is our servler initialized ?
`static java.lang.String` `RUNNER`
`protected org.w3c.jigsaw.servlet.ServletWrapper.ServletPool` `servletPool` Using a limited pool of servlet instances instead of a single instance, tk, 22.10.2001 protected Servlet servlet = null;
`protected ServletWrapper.TimeoutManager` `timeoutManager`

Fields inherited from class org.w3c.tools.resources.FramedResource
`ATTR_OID, attrListener, debugEvent, event_disabled, framesRef, structListener`

Fields inherited from class org.w3c.tools.resources.Resource
`ATTR_CONTEXT, ATTR_HELP_URL, ATTR_IDENTIFIER, ATTR_LAST_MODIFIED, ATTR_PARENT, ATTR_RESOURCE_FRAMES, ATTR_STORE_ENTRY, ATTR_URL, co, id`

Fields inherited from class org.w3c.tools.resources.AttributeHolder
`attributes, values`

Constructor Summary
`ServletWrapper()`

Method Summary
`boolean` `acceptUnload()` Is that resource willing to be unloaded.
`protected void` `checkServlet()` Check the servlet class, ans try to initialize it.
`protected AutoReloadServletLoader` `createNewLocalServletLoader(boolean keepold)`
`protected void` `destroyServlet()` Destroy the servlet we are wrapping.
`java.lang.String` `getInitParameter(java.lang.String string)` Servlet stub implementation - Get an init parameter value.
`java.util.Enumeration` `getInitParameterNames()` Servlet stub implementation - Get all init parameters.
`protected int` `getInstanceMax()`
`protected AutoReloadServletLoader` `getLocalServletLoader()` Get or create a suitable LocalServletLoader instance to load that servlet.
`javax.servlet.Servlet` `getServlet()` Get the servlet we are wrapping.
`java.lang.String` `getServletClass()` Get the class name of the wrapped servlet.
`javax.servlet.ServletContext` `getServletContext()` Servlet stub implementation - Get that servlet context.
`java.io.File` `getServletDirectory()` The Path where we can find the servlet class file.
`java.lang.String` `getServletName()` Returns the name of this servlet instance.
`ArrayDictionary` `getServletParameters()` Get the init parameters for our wrapped servlet.
`protected long` `getServletTimeout()`
`JigsawHttpSessionContext` `getSessionContext()`
`void` `initialize(java.lang.Object[] values)` Initialize this servlet wrapper resource.
`protected void` `invalidateAllSession()`
`protected boolean` `isInited()`
`boolean` `isServletLoaded()` Check and eventually load the servlet we are wrapping.
`protected boolean` `isWrappingAServlet()` Check if the Servletclass wrapped is a Servlet class without initializing it.
`protected boolean` `launchServlet()` Launch the servlet we are wrapping.
`protected boolean` `launchServlet(java.lang.Class cls)` Initialize our servlet from the given (loaded) class.
`void` `notifyUnload()` This resource is being unloaded.
`protected void` `service(Request request, Reply reply)`
`void` `setValue(int idx, java.lang.Object value)` Catch assignements to the servlet class name attribute.
`protected void` `setValueOfSuperClass(int idx, java.lang.Object value)`

Methods inherited from class org.w3c.tools.resources.FramedResource

`addAttributeChangedListener, addStructureChangedListener, collectFramesReference, delete, disableEvent, displayEvent, enableEvent, eventDisabled, fireAttributeChangeEvent, fireStructureChangedEvent, fireStructureChangedEvent, frameAdded, frameModified, frameRemoved, getClone, getFrame, getFrame, getFrameReference, getFrameReference, getFramesReference, getOid, lookup, markModified, perform, performFrames, postAttributeChangeEvent, postEvent, postStructureChangedEvent, postStructureChangedEvent, processEvent, registerFrame, registerFrameIfNone, removeAttributeChangedListener, removeStructureChangedListener, setSilentValue, setSilentValue, unregisterFrame`

Methods inherited from class org.w3c.tools.resources.Resource
`checkMultipleLock, collectFrames, getContext, getFrame, getFrames, getHelpURL, getHelpURL, getIdentifier, getLastModified, getParent, getResourceReference, getServer, getSpace, getSpaceEntry, getStoreEntry, getURLPath, getValue, getValue, initialize, isInitialized, isUnloaded, pickleValues, setContext, setContext, setValue, unsafeGetContext, unsafeGetIdentifier, unsafeGetValue, updateAttributes`

Methods inherited from class org.w3c.tools.resources.AttributeHolder
`definesAttribute, definesAttribute, getAttributes, getBoolean, getChar, getClone, getClone, getDouble, getFloat, getInt, getLong, getString, getValue, lookupAttribute, print, setBoolean, setChar, setDouble, setFloat, setInt, setLong, setString, setValue, unsafeGetString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### RUNNER

    public static final java.lang.String RUNNER

### ENDED

    public static final java.lang.String ENDED

### timeoutManager

    protected ServletWrapper.TimeoutManager timeoutManager

### debug

    protected static final boolean debug

### ATTR_SERVLET_CLASS

    protected static int ATTR_SERVLET_CLASS

  Attributes index - The servlet class name.

### ATTR_SERVLET_TIMEOUT

    protected static int ATTR_SERVLET_TIMEOUT

  Attributes index - The servlet timeout

### ATTR_SERVLET_INSTANCEMAX

    protected static int ATTR_SERVLET_INSTANCEMAX

  Attributes index - The servlet maxinstances for single thread model servlet instance pool size limitation, tk, 20.10.2001

### ATTR_PARAMETERS

    protected static int ATTR_PARAMETERS

  Attribute index - The init parameters for that servlet.

### ATTR_SERVLET_CONTEXT

    protected static int ATTR_SERVLET_CONTEXT

  Attribute index - Our parent-inherited servlet context.

### ATTR_SESSION_CONTEXT

    protected static int ATTR_SESSION_CONTEXT

  Attribute index - Our parent-inherited session context.

### servletPool

    protected org.w3c.jigsaw.servlet.ServletWrapper.ServletPool servletPool

  Using a limited pool of servlet instances instead of a single instance, tk, 22.10.2001 protected Servlet servlet = null;

### inited

    protected boolean inited

  Is our servler initialized ?

Constructor Detail

### ServletWrapper

    public ServletWrapper()

Method Detail

### getServletDirectory

    public java.io.File getServletDirectory()

  The Path where we can find the servlet class file.

### getInitParameter

    public java.lang.String getInitParameter(java.lang.String string)

  Servlet stub implementation - Get an init parameter value.
  Specified by:
    getInitParameter in interface javax.servlet.ServletConfig

### getInitParameterNames

    public java.util.Enumeration getInitParameterNames()

  Servlet stub implementation - Get all init parameters.
  Specified by:
    getInitParameterNames in interface javax.servlet.ServletConfig

### getServletContext

    public javax.servlet.ServletContext getServletContext()

  Servlet stub implementation - Get that servlet context.
  Specified by:
    getServletContext in interface javax.servlet.ServletConfig

### getSessionContext

    public JigsawHttpSessionContext getSessionContext()

### getServletTimeout

    protected long getServletTimeout()

### getInstanceMax

    protected int getInstanceMax()

### invalidateAllSession

    protected void invalidateAllSession()

### checkServlet

    protected void checkServlet()
                         throws java.lang.ClassNotFoundException,
                                javax.servlet.ServletException

  Check the servlet class, ans try to initialize it.
  Throws:
    java.lang.ClassNotFoundException - if servlet class can't be found.
    javax.servlet.ServletException - if servlet can't be initialized.

### isInited

    protected boolean isInited()

### isServletLoaded

    public boolean isServletLoaded()

  Check and eventually load the servlet we are wrapping. This method was added for replacing getServlet() during access checks in order to do perform checks without accessing a servlet instance.
  Returns:
    true if and only if the sevlet has successfully been loaded

### service

    protected void service(Request request,
                           Reply reply)
                    throws javax.servlet.ServletException,
                           java.io.IOException

### getServletClass

    public java.lang.String getServletClass()

  Get the class name of the wrapped servlet.
  Returns:
    The class name for the servlet if attribute is defined. Otherwise the class name is deduced from the resource identifier.

### getServletParameters

    public ArrayDictionary getServletParameters()

  Get the init parameters for our wrapped servlet.
  Returns:
    An ArrayDictionary instance if the attribute is defined, false otherwise.

### setValueOfSuperClass

    protected void setValueOfSuperClass(int idx,
                                        java.lang.Object value)

### setValue

    public void setValue(int idx,
                         java.lang.Object value)

  Catch assignements to the servlet class name attribute.

  When a change to that attribute is detected, the servlet is automatically reinitialized.

  Overrides:
    setValue in class FramedResource
  Tags copied from class: Resource
  Parameters:
    `idx` - The index of the attribute to modify.
    `value` - The new attribute value.

### destroyServlet

    protected void destroyServlet()

  Destroy the servlet we are wrapping.

### getServlet

    public javax.servlet.Servlet getServlet()

  Get the servlet we are wrapping.
  Returns:
    A servlet instance, if the servlet is alredy running, null otherwise.

### launchServlet

    protected boolean launchServlet(java.lang.Class cls)
                             throws javax.servlet.ServletException

  Initialize our servlet from the given (loaded) class.
  Parameters:
    `cls` - The servlet loaded main class.
  Returns:
    A boolean, true if servlet was successfully initialised, false otherwise.
  Throws:
    javax.servlet.ServletException - if servlet can't be initialized.

### isWrappingAServlet

    protected boolean isWrappingAServlet()

  Check if the Servletclass wrapped is a Servlet class without initializing it. (not the same than checkServlet). used by the ServletIndexer.
  Returns:
    A boolean.
  See Also:
    `ServletIndexer`

### launchServlet

    protected boolean launchServlet()
                             throws java.lang.ClassNotFoundException,
                                    javax.servlet.ServletException

  Launch the servlet we are wrapping.

  This method either succeed, or the wrapper resource itself will fail to initialize, acting as transparently as possible (in some sense).

  Returns:
    A boolean, true if servlet launched.
  Throws:
    java.lang.ClassNotFoundException - if servlet class can't be found.
    javax.servlet.ServletException - if servlet can't be initialized.

### acceptUnload

    public boolean acceptUnload()

  Description copied from class: Resource
  Is that resource willing to be unloaded. This method is a bit tricky to implement. The guideline is that you should not dynamically change the returned value (since you can't control what happens between a call to that method and a call to the `notifyUnload` method).

  Returning false should never be needed, except for very strange resources.

  Overrides:
    acceptUnload in class Resource
  Tags copied from class: Resource
  Returns:
    A boolean true if the resource can be unloaded false otherwise.

### notifyUnload

    public void notifyUnload()

  Description copied from class: FramedResource
  This resource is being unloaded. The resource is being unloaded from memory, perform any additional cleanup required.
  Overrides:
    notifyUnload in class FramedResource

### getLocalServletLoader

    protected AutoReloadServletLoader getLocalServletLoader()

  Get or create a suitable LocalServletLoader instance to load that servlet.
  Returns:
    A LocalServletLoader instance.

### createNewLocalServletLoader

    protected AutoReloadServletLoader createNewLocalServletLoader(boolean keepold)

### getServletName

    public java.lang.String getServletName()

  Returns the name of this servlet instance. The name may be provided via server administration, assigned in the web application deployment descriptor, or for an unregistered (and thus unnamed) servlet instance it will be the servlet's class name.
  Specified by:
    getServletName in interface javax.servlet.ServletConfig
  Returns:
    the name of the servlet instance

### initialize

    public void initialize(java.lang.Object[] values)

  Initialize this servlet wrapper resource. After the wrapper itself is inited, it performs the servlet initialzation.
  Overrides:
    initialize in class FramedResource
  Parameters:
    `values` - The default attribute values.