org.wso2.carbon.webapp.mgt.utils
Class GhostWebappDeployerUtils

java.lang.Object
  extended by org.wso2.carbon.webapp.mgt.utils.GhostWebappDeployerUtils

public class GhostWebappDeployerUtils
extends Object

Utility class for handling lazy loading of webapps


Method Summary
static WebApplication addGhostWebApp(File ghostFile, File originalFile, TomcatGenericWebappsDeployer applicationDeployer, org.apache.axis2.context.ConfigurationContext configContext)
          Creates the Ghost webapplication by reading the ghost metadata file.
static String calculateGhostFileName(String fileName, String repoPath)
          Calculate the ghost file name using the original file name.
static WebApplication deployActualWebApp(WebApplication ghostWebapp, org.apache.axis2.context.ConfigurationContext configurationContext)
          Removes the given ghostWebapp and deploys the actual webapp.
static void deployGhostArtifacts(org.apache.axis2.context.ConfigurationContext configContext)
           
static WebApplication dispatchWebAppFromTransitGhosts(String ctxName, org.apache.axis2.context.ConfigurationContext cfgContext)
          When a ghost webapp is removed from the webappsholder and the corresponding actual webapp is deployed, there's a time interval in which there's no Webapp in the webapps holder for the particular webapp context.
static WebApplication findDeployedWebapp(org.apache.axis2.context.ConfigurationContext configurationContext, String webappFilePath)
          This method is used to find a webapplication from the webapps holder by comparing the webapp file absolute path.
static String getDummyContextDirectoryPath(String contextName, org.apache.axis2.engine.AxisConfiguration axisConfig)
          Method which will return the dummy context directory path for current tenant which will be created in /tmp/tenants/ directory
static File getDummyContextFile(String fileName, org.apache.axis2.engine.AxisConfiguration axisConfig)
          Calculate the dummy context file name using the original file name.
static File getGhostFile(String fileName, org.apache.axis2.engine.AxisConfiguration axisConfig)
          Creates a File instance for the ghost service according to the original file name..
static Map<String,WebApplication> getTransitGhostWebAppsMap(org.apache.axis2.context.ConfigurationContext cfgContext)
          Get the map of services which are in transit.
static boolean isGhostWebApp(WebApplication webApplication)
          Checks if the given webapp is a ghost webapp.
static String separatorsToUnix(String path)
           
static void serializeWebApp(WebApplication webApplication, org.apache.axis2.engine.AxisConfiguration axisConfig, String webappPath)
          Creates the ghost file for the current web application.
static boolean skipUndeploy(String fileName)
          Method to check if the undeploying of ghost related files needs to be skipped
static void updateLastUsedTime(WebApplication webApplication)
          Updates the last used timestamp of the given webapp.
static void waitForWebAppToLeaveTransit(String contextName, org.apache.axis2.context.ConfigurationContext cfgContext)
          When a ghost webapp is removed from the WebappsHolder, context name of that webapp is kept temporary in a map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

deployActualWebApp

public static WebApplication deployActualWebApp(WebApplication ghostWebapp,
                                                org.apache.axis2.context.ConfigurationContext configurationContext)
Removes the given ghostWebapp and deploys the actual webapp. Before deploying the actual webapp this method will check whether the webapp of interest is already deployed and return it if found.

Parameters:
ghostWebapp - Existing ghost Webapp
configurationContext - ConfigurationContext instance
Returns:
newly deployed real webapp

updateLastUsedTime

public static void updateLastUsedTime(WebApplication webApplication)
Updates the last used timestamp of the given webapp. A new Paramter is created if it doesn't already exists..

Parameters:
webApplication - to be updated

getTransitGhostWebAppsMap

public static Map<String,WebApplication> getTransitGhostWebAppsMap(org.apache.axis2.context.ConfigurationContext cfgContext)
Get the map of services which are in transit. A particular service will be in this map from the time the ghost service is removed from AxisConfig and the actual service is deployed..

Parameters:
cfgContext - - ConfigurationContext that holds the transitMap property
Returns:
returns a map of strings which are the context names of the webapps

dispatchWebAppFromTransitGhosts

public static WebApplication dispatchWebAppFromTransitGhosts(String ctxName,
                                                             org.apache.axis2.context.ConfigurationContext cfgContext)
When a ghost webapp is removed from the webappsholder and the corresponding actual webapp is deployed, there's a time interval in which there's no Webapp in the webapps holder for the particular webapp context. Within this interval, if a request comes in to the webapp, we have to somehow dispatch the webapp. Within the above mentioned time interval, webapp is kept in a map. This method checks whether the relevant webapp is available in that map and if it is found, returns the name of the context of the webapp.

Parameters:
ctxName - - contextName of webapp
cfgContext - - ConfigurationContext to get the transitGhost webapps map
Returns:
the webapp

waitForWebAppToLeaveTransit

public static void waitForWebAppToLeaveTransit(String contextName,
                                               org.apache.axis2.context.ConfigurationContext cfgContext)
When a ghost webapp is removed from the WebappsHolder, context name of that webapp is kept temporary in a map. This method waits until the provided contrext name is removed from that map. In other words, it waits until the actual webapp is deployed. After the actual webapp is deployed, it is safe to forward the request further..

Parameters:
contextName - - contextName to bec checked with the ghostTransitMap
cfgContext - - ConfigurationContext to get the transitGhost webapps map

isGhostWebApp

public static boolean isGhostWebApp(WebApplication webApplication)
Checks if the given webapp is a ghost webapp.

Parameters:
webApplication - - the webapp to be checked for ghost param
Returns:
true if the webapp is ghost

addGhostWebApp

public static WebApplication addGhostWebApp(File ghostFile,
                                            File originalFile,
                                            TomcatGenericWebappsDeployer applicationDeployer,
                                            org.apache.axis2.context.ConfigurationContext configContext)
Creates the Ghost webapplication by reading the ghost metadata file. The created object will contain the basic metadata of the webapplication that are enough to show in the webapp info page.

Parameters:
ghostFile - - ghost metadata file
originalFile - - original webapp file
configContext - - configContext to get tenant details and webapp deployer instance
Returns:
- WebApplication which is created

serializeWebApp

public static void serializeWebApp(WebApplication webApplication,
                                   org.apache.axis2.engine.AxisConfiguration axisConfig,
                                   String webappPath)
Creates the ghost file for the current web application. This file will contain basic meadata such as Webapp name, context name, display name, war file name, last modified time and noOf active sessions. These information for a webapp is enough to show it in the webapp info page

Parameters:
webApplication - - Webapplication to be serialized
axisConfig - - AxisConfiguration instance
webappPath - - Absolute path to the webapp artifact

getGhostFile

public static File getGhostFile(String fileName,
                                org.apache.axis2.engine.AxisConfiguration axisConfig)
Creates a File instance for the ghost service according to the original file name..

Parameters:
fileName - - original service file name
axisConfig - - AxisConfiguration instance
Returns:
- File instance created

calculateGhostFileName

public static String calculateGhostFileName(String fileName,
                                            String repoPath)
Calculate the ghost file name using the original file name.

Parameters:
fileName - - original file name
repoPath - - path of the axis2 repository
Returns:
- derived ghost file name

findDeployedWebapp

public static WebApplication findDeployedWebapp(org.apache.axis2.context.ConfigurationContext configurationContext,
                                                String webappFilePath)
This method is used to find a webapplication from the webapps holder by comparing the webapp file absolute path.

Parameters:
configurationContext - - configurationContext instance that has the webapps holder property
webappFilePath - - absolute path of the webapp to be compared with other webapps in the holder
Returns:
webapplicatioon found by the comparison or null

getDummyContextDirectoryPath

public static String getDummyContextDirectoryPath(String contextName,
                                                  org.apache.axis2.engine.AxisConfiguration axisConfig)
Method which will return the dummy context directory path for current tenant which will be created in /tmp/tenants/ directory

Parameters:
contextName - - context name
axisConfig - - axisConfig used to get tenant info
Returns:
- dummyContextDirPath

getDummyContextFile

public static File getDummyContextFile(String fileName,
                                       org.apache.axis2.engine.AxisConfiguration axisConfig)
Calculate the dummy context file name using the original file name.

Parameters:
fileName - - original file name
axisConfig - - axisConfig
Returns:
- derived context file

skipUndeploy

public static boolean skipUndeploy(String fileName)
Method to check if the undeploying of ghost related files needs to be skipped

Parameters:
fileName - name of the webapp file
Returns:
true or false

deployGhostArtifacts

public static void deployGhostArtifacts(org.apache.axis2.context.ConfigurationContext configContext)

separatorsToUnix

public static String separatorsToUnix(String path)


Copyright © 2015 WSO2. All rights reserved.