org.wso2.carbon.webapp.mgt

## Class WebApplication

- java.lang.Object
- - org.wso2.carbon.webapp.mgt.WebApplication

-     public class WebApplication
      extends Object

  Represents a Tomcat Web Application

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `WebApplication.HttpSession` Represents an HTTP session
    `class` | `WebApplication.Statistics` Represents statistics corresponding to this webapp

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `ENABLE_SAAS` Key for the enable SAAS context parameter

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebApplication(TomcatGenericWebappsDeployer tomcatGenericWebappsDeployer, org.apache.catalina.Context context, File webappFile)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addParameter(String name, String value)`
    `void` | `delete()` Completely delete & destroy this Web application
    `void` | `expireAllSessions()` Expire all sessions of this webapp
    `void` | `expireSessions(long maxLifetimeMillis)` Expire sessions whose lifetime is greater than or equal to `maxLifetimeMillis`
    `void` | `expireSessions(String[] sessionIDs)` Expire all specified sessions
    `String` | `findParameter(String contextParamName)`
    `String[]` | `findParameters()`
    `protected File` | `getAppBase()` Return a File object representing the "application root" directory for our associated Host.
    `protected String` | `getBamEnableFromWebappMetaData()` Reads from webappmeta files and return wether bam enabled.
    `org.apache.catalina.Context` | `getContext()` This method will return the Catalina Context for a particular webapp
    `String` | `getContextName()`
    `String` | `getDisplayName()`
    `boolean` | `getDistributable()`
    `String` | `getDocBase()`
    `Exception` | `getFaultReason()`
    `String` | `getHostName()`
    `long` | `getLastModifiedTime()`
    `Object` | `getProperty(String key)`
    `String` | `getServiceListPath()`
    `WebApplication.HttpSession` | `getSession(String sessionId)` Get the session corresponding to the `sessionId`
    `List<WebApplication.HttpSession>` | `getSessions()` Get all the current sessions for this webapp
    `String` | `getState()`
    `WebApplication.Statistics` | `getStatistics()`
    `TomcatGenericWebappsDeployer` | `getTomcatGenericWebappsDeployer()`
    `String` | `getVersion()`
    `File` | `getWebappFile()`
    `void` | `lazyUnload()` Lazily unload this Web application.
    `boolean` | `reload()`
    `void` | `removeParameter(String name)`
    `void` | `setDisplayName(String name)`
    `void` | `setDistributable(boolean distributable)`
    `void` | `setDocBase(String docBase)`
    `void` | `setFaultReason(Exception faultReason)`
    `void` | `setHostName(String hostName)`
    `void` | `setIsGhostWebapp(boolean isThisGhost)` We need this method in ghost mode because, this will set a static variable which indicates whether this Webapp is a ghost.
    `void` | `setLastModifiedTime(long lastModifiedTime)`
    `void` | `setProperty(String key, Object value)`
    `void` | `setServiceListPath(String serviceListPath)`
    `void` | `setServletContextParameters(List<WebContextParameter> parameters)` Set ServletContext parameters for this webapp
    `void` | `setState(String state)`
    `void` | `setVersion(String version)`
    `void` | `setWebappFile(File webappFile)`
    `boolean` | `start()` Start a webapp which was stopped
    `boolean` | `stop()` Temporarilly stop this Web application.
    `String` | `toString()`
    `void` | `undeploy()` Completely delete & destroy this Web application.
    `protected void` | `updateWebappMetaDataforBam(String value)`

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

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

- - ### Field Detail

    - #### ENABLE_SAAS

          public static final String ENABLE_SAAS

      Key for the enable SAAS context parameter
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### WebApplication

          public WebApplication(TomcatGenericWebappsDeployer tomcatGenericWebappsDeployer,
                                org.apache.catalina.Context context,
                                File webappFile)

  - ### Method Detail

    - #### setServletContextParameters

          public void setServletContextParameters(List<WebContextParameter> parameters)

      Set ServletContext parameters for this webapp
      Parameters:
        `parameters` - ServletContext attributes for this webapp

    - #### getWebappFile

          public File getWebappFile()

    - #### setWebappFile

          public void setWebappFile(File webappFile)

    - #### getContextName

          public String getContextName()

    - #### getDisplayName

          public String getDisplayName()

    - #### setDisplayName

          public void setDisplayName(String name)

    - #### setLastModifiedTime

          public void setLastModifiedTime(long lastModifiedTime)

    - #### getLastModifiedTime

          public long getLastModifiedTime()

    - #### setState

          public void setState(String state)

    - #### getState

          public String getState()

    - #### getFaultReason

          public Exception getFaultReason()

    - #### setFaultReason

          public void setFaultReason(Exception faultReason)

    - #### setProperty

          public void setProperty(String key,
                                  Object value)

    - #### getProperty

          public Object getProperty(String key)

    - #### getDistributable

          public boolean getDistributable()

    - #### setDistributable

          public void setDistributable(boolean distributable)

    - #### getDocBase

          public String getDocBase()

    - #### setDocBase

          public void setDocBase(String docBase)

    - #### addParameter

          public void addParameter(String name,
                                   String value)

    - #### removeParameter

          public void removeParameter(String name)

    - #### findParameter

          public String findParameter(String contextParamName)

    - #### findParameters

          public String[] findParameters()

    - #### getTomcatGenericWebappsDeployer

          public TomcatGenericWebappsDeployer getTomcatGenericWebappsDeployer()

    - #### reload

          public boolean reload()

    - #### getBamEnableFromWebappMetaData

          protected String getBamEnableFromWebappMetaData()
                                                   throws org.apache.axis2.AxisFault,
                                                          org.wso2.carbon.core.persistence.metadata.ArtifactMetadataException

      Reads from webappmeta files and return wether bam enabled.
      Returns:
      Throws:
        `org.apache.axis2.AxisFault`
        `org.wso2.carbon.core.persistence.metadata.ArtifactMetadataException`

    - #### updateWebappMetaDataforBam

          protected void updateWebappMetaDataforBam(String value)

    - #### stop

          public boolean stop()
                       throws org.wso2.carbon.CarbonException

      Temporarilly stop this Web application. When a request is made to a stopped webapp resource, an HTTP 503 (Temporarilly Unavailable) will be returned.
      Returns:
        true - If hte webapp was successfully stopped
      Throws:
        `org.wso2.carbon.CarbonException` - If an error occurs while stopping this webapp

    - #### start

          public boolean start()
                        throws org.wso2.carbon.CarbonException

      Start a webapp which was stopped
      Returns:
        true - if the webapp was successfully started
      Throws:
        `org.wso2.carbon.CarbonException` - If an error occurs while starting this webapp

    - #### lazyUnload

          public void lazyUnload()
                          throws org.wso2.carbon.CarbonException

      Lazily unload this Web application.
      Throws:
        `org.wso2.carbon.CarbonException` - If an error occurs while lazy unloading

    - #### undeploy

          public void undeploy()
                        throws org.wso2.carbon.CarbonException

      Completely delete & destroy this Web application. When a request is made to an undeployed webapp resource, an HTTP 404 (Not Found) will be returned.
      Throws:
        `org.wso2.carbon.CarbonException` - If an error occurs while undeploying this webapp

    - #### delete

          public void delete()
                      throws org.wso2.carbon.CarbonException

      Completely delete & destroy this Web application
      Throws:
        `org.wso2.carbon.CarbonException` - If an error occurs while undeploying this webapp

    - #### getAppBase

          protected File getAppBase()

      Return a File object representing the "application root" directory for our associated Host.
      Returns:
        The AppBase //TODO - when webapp exploding is supported for stratos, this should return the tenant's webapp dir

    - #### expireAllSessions

          public void expireAllSessions()

      Expire all sessions of this webapp

    - #### expireSessions

          public void expireSessions(long maxLifetimeMillis)

      Expire sessions whose lifetime is greater than or equal to `maxLifetimeMillis`
      Parameters:
        `maxLifetimeMillis` - The maximum session lifetime in milliseconds

    - #### expireSessions

          public void expireSessions(String[] sessionIDs)
                              throws org.wso2.carbon.CarbonException

      Expire all specified sessions
      Parameters:
        `sessionIDs` - The IDs of the sessions to be expired
      Throws:
        `org.wso2.carbon.CarbonException` - If an error occurs while getting the session

    - #### getSessions

          public List<WebApplication.HttpSession> getSessions()

      Get all the current sessions for this webapp
      Returns:
        the current sessions for this webapp

    - #### getSession

          public WebApplication.HttpSession getSession(String sessionId)
                                                throws org.wso2.carbon.CarbonException

      Get the session corresponding to the `sessionId`
      Parameters:
        `sessionId` - The session ID
      Returns:
        the session corresponding to the `sessionId`
      Throws:
        `org.wso2.carbon.CarbonException` - If an error occurs while retrieving the session

    - #### getStatistics

          public WebApplication.Statistics getStatistics()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getServiceListPath

          public String getServiceListPath()

    - #### setServiceListPath

          public void setServiceListPath(String serviceListPath)

    - #### getVersion

          public String getVersion()

    - #### setVersion

          public void setVersion(String version)

    - #### getHostName

          public String getHostName()

    - #### setHostName

          public void setHostName(String hostName)

    - #### getContext

          public org.apache.catalina.Context getContext()

      This method will return the Catalina Context for a particular webapp
      Returns:
        Context

    - #### setIsGhostWebapp

          public void setIsGhostWebapp(boolean isThisGhost)

      We need this method in ghost mode because, this will set a static variable which indicates whether this Webapp is a ghost. We need a static variable to use it in the Statistics inner class, which is a static class.
      Parameters:
        `isThisGhost` - boolean parameter to set the static variable

Copyright © 2019 WSO2. All rights reserved.