Class WebAppUtils

java.lang.Object
org.wso2.carbon.webapp.mgt.utils.WebAppUtils

public class WebAppUtils extends Object
  • Field Details

  • Constructor Details

    • WebAppUtils

      public WebAppUtils()
  • Method Details

    • checkJaxApplication

      public static String checkJaxApplication(WebApplication webApplication)
      This util method is used to check if the given application is a Jax-RS/WS app
      Parameters:
      webApplication - application object
      Returns:
      relevant servlet mapping of the cxf servlet if its a Jax-RS/WS application. Null, if its not a Jax-RS/WS application.
    • validateWebappFileName

      public static boolean validateWebappFileName(String filename)
    • getWebappDirPath

      public static String getWebappDirPath(String webappFilePath)
      This util method is used to return file path of base dir. eg: for input "/deployment/server/webapps/calenda.war" will return "/deployment/server/webapps"
      Parameters:
      webappFilePath - path to webapp
      Returns:
      absolute path to base dir
    • getMatchingHostName

      public static String getMatchingHostName(String filePath)
      Parameters:
      filePath - web app base dir path
      Returns:
      virtual host name for web app dir
    • getMatchingVirtualHost

      public static org.apache.catalina.Host getMatchingVirtualHost(String baseDir)
      Parameters:
      baseDir - web application directory path
      Returns:
      host name that matches the directory path
    • isWebappUploadedToVirtualAppBase

      public static boolean isWebappUploadedToVirtualAppBase(String webAppBaseDir, String appBase)
      Parameters:
      webAppBaseDir - path to the webapp
      appBase - virtual host path
      Returns:
      true if Webapp is uploaded to Virtual Host, else false
    • getHost

      public static org.apache.catalina.Host getHost(String webappFilePath) throws org.wso2.carbon.tomcat.CarbonTomcatException
      Parameters:
      webappFilePath - Webapp path
      Returns:
      virtualHost if webapp is uploaded to Virtual Host else defaultHost
      Throws:
      org.wso2.carbon.tomcat.CarbonTomcatException
    • getWebappKey

      public static String getWebappKey(File webappFile)
      This will return a key with pair hostname:webappFileName
      Parameters:
      webappFile - web application file
      Returns:
      :invalid input: '<'webapp-name>
    • getVhostNames

      public static List<String> getVhostNames()
      Returns:
      List of virtual hosts
    • getAppbase

      public static String getAppbase(String hostName)
      This util method will return appbase value of matching host name from catalina-server.xml
      Parameters:
      hostName - hostname of Host element
      Returns:
      relevant appBase for the host
    • getAllWebappHolders

      public static Map<String,WebApplicationsHolder> getAllWebappHolders(org.apache.axis2.context.ConfigurationContext configurationContext)
      Parameters:
      configurationContext - ConfigurationContext instance
      Returns:
      list of web application holders
    • getWebappHolder

      public static WebApplicationsHolder getWebappHolder(String webappFilePath, org.apache.axis2.context.ConfigurationContext configurationContext)
      This util method will return the web application holder of the given web app file
      Parameters:
      webappFilePath - AbsolutePath of webapp
      configurationContext - ConfigurationContext instance
      Returns:
      relevant webapplication holder
    • getWebappDir

      public static String getWebappDir(String webappFilePath)
      This util method is used to return base dir name of webapp. eg: for input "/deployment/server/webapps/calenda.war" will return "webapps"
      Parameters:
      webappFilePath - path to web app
      Returns:
      parent dir of web application
    • getWebappName

      public static String getWebappName(String webappFilePath)
      Parameters:
      webappFilePath - path to webapp
      Returns:
      web application name
    • getDefaultWebappHolder

      public static WebApplicationsHolder getDefaultWebappHolder(org.apache.axis2.context.ConfigurationContext configurationContext)
    • getDefaultHost

      public static String getDefaultHost()
      Returns:
      default host of engine element
    • getServerConfigHostName

      public static String getServerConfigHostName()
      This will read "HostName" value from carbon.xml and will return default host (from catalina-server.xml) if the value is null (or not defined)
      Returns:
      host name read from carbon.xml
    • getAppBases

      public static List<String> getAppBases()
    • generateMetaFileDirName

      public static String generateMetaFileDirName(String webappFilePath, org.apache.axis2.context.ConfigurationContext configurationContext)
    • getWebappResourcePath

      public static String getWebappResourcePath(WebApplication webApplication)
      Returns the registry path for the webapp
      Parameters:
      webApplication - WebApplication instance
      Returns:
    • isSharedEnvClassLoaderDisabled

      public static boolean isSharedEnvClassLoaderDisabled()
      Check whether the shared environment class loader is disabled.
      Returns:
      Whether shared environment class loader is disabled.