Package org.wso2.carbon.webapp.mgt.utils
Class GhostWebappDeployerUtils
java.lang.Object
org.wso2.carbon.webapp.mgt.utils.GhostWebappDeployerUtils
Utility class for handling lazy loading of webapps
-
Method Summary
Modifier and TypeMethodDescriptionstatic WebApplicationaddGhostWebApp(File ghostFile, File originalFile, TomcatGenericWebappsDeployer applicationDeployer, org.apache.axis2.context.ConfigurationContext configContext) Creates the Ghost webapplication by reading the ghost metadata file.static StringcalculateGhostFileName(String fileName, String repoPath) Calculate the ghost file name using the original file name.static WebApplicationdeployActualWebApp(WebApplication ghostWebapp, org.apache.axis2.context.ConfigurationContext configurationContext) Removes the given ghostWebapp and deploys the actual webapp.static voiddeployGhostArtifacts(org.apache.axis2.context.ConfigurationContext configContext) static WebApplicationdispatchWebAppFromTransitGhosts(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 WebApplicationfindDeployedWebapp(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 StringgetDummyContextDirectoryPath(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/ directorystatic FilegetDummyContextFile(String fileName, org.apache.axis2.engine.AxisConfiguration axisConfig) Calculate the dummy context file name using the original file name.static FilegetGhostFile(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 booleanisGhostWebApp(WebApplication webApplication) Checks if the given webapp is a ghost webapp.static StringseparatorsToUnix(String path) static voidserializeWebApp(WebApplication webApplication, org.apache.axis2.engine.AxisConfiguration axisConfig, String webappPath) Creates the ghost file for the current web application.static booleanskipUndeploy(String fileName) Method to check if the undeploying of ghost related files needs to be skippedstatic voidupdateLastUsedTime(WebApplication webApplication) Updates the last used timestamp of the given webapp.static voidwaitForWebAppToLeaveTransit(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.
-
Method Details
-
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 WebappconfigurationContext- ConfigurationContext instance- Returns:
- newly deployed real webapp
-
updateLastUsedTime
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 webappcfgContext- - 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 ghostTransitMapcfgContext- - ConfigurationContext to get the transitGhost webapps map
-
isGhostWebApp
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 fileoriginalFile- - original webapp fileconfigContext- - 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 serializedaxisConfig- - AxisConfiguration instancewebappPath- - 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 nameaxisConfig- - AxisConfiguration instance- Returns:
- - File instance created
-
calculateGhostFileName
Calculate the ghost file name using the original file name.- Parameters:
fileName- - original file namerepoPath- - 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 propertywebappFilePath- - 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 nameaxisConfig- - 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 nameaxisConfig- - axisConfig- Returns:
- - derived context file
-
skipUndeploy
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
-