Package org.glassfish.loader.util
Class ASClassLoaderUtil
- java.lang.Object
-
- org.glassfish.loader.util.ASClassLoaderUtil
-
public class ASClassLoaderUtil extends Object
Utils to get information about classes or libraries to load. This class does not actually load the classes itself.
-
-
Field Summary
Fields Modifier and Type Field Description static Logger
deplLogger
-
Constructor Summary
Constructors Constructor Description ASClassLoaderUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static URL[]
convertURLListToArray(List<URL> list)
Converts a list of a URLs to an arraystatic URL[]
getAppLibDirLibraries(File appRoot, String appLibDir, String compatibilityProp)
add all the libraries packaged in the application library directorystatic List<URL>
getAppLibDirLibrariesAsList(File appRoot, String appLibDir, String compatibilityProp)
Gets a list of all the libraries packaged in the application library directorystatic URL[]
getDeployParamLibrariesAsURLs(String librariesStr, ServerEnvironment env)
converts libraries specified via the --libraries deployment option to URL[].static List<URI>
getLibDirectoryJarURIs(File moduleLibDirectory)
Returns all jar files if the directorystatic URL[]
getLibrariesAsURLs(Set<String> librariesStr, ServerEnvironment env)
converts libraries specified via EXTENSION_LIST entry in MANIFEST.MF of all of the libraries of the deployed archive to The libraries are made available to the application in the order specified.static Manifest
getManifest(String rootPath)
Returns the manifest file for the given root path.static List<URL>
getManifestClassPathAsURLs(Manifest manifest, String rootPath)
Returns the class path (if any) from the given manifest file as an URL list.static String
getModuleClassPath(org.glassfish.hk2.api.ServiceLocator habitat, String moduleId, String deploymentLibs)
Gets the classpath associated with a module, suffixing libraries defined [if any] for the applicationstatic String
getModuleClassPath(org.glassfish.hk2.api.ServiceLocator habitat, DeploymentContext context)
static URL[]
getURLs(File[] dirs, File[] jarDirs, boolean ignoreZip)
Returns an array of urls that contains ..static List<URL>
getURLsAsList(File[] dirs, File[] jarDirs, boolean ignoreZip)
Returns a list of urls that contains ..static List<URL>
getURLsFromClasspath(String classpath, String delimiter, String rootPath)
get URL list from classpath
-
-
-
Field Detail
-
deplLogger
public static final Logger deplLogger
-
-
Method Detail
-
getModuleClassPath
public static String getModuleClassPath(org.glassfish.hk2.api.ServiceLocator habitat, String moduleId, String deploymentLibs)
Gets the classpath associated with a module, suffixing libraries defined [if any] for the application- Parameters:
habitat
- the habitat the application resides in.moduleId
- Module id of the moduledeploymentLibs
- libraries option passed through deployment- Returns:
- A
File.pathSeparator
separated list of classpaths for the passed in module, including the module specified "libraries" defined for the module.
-
getModuleClassPath
public static String getModuleClassPath(org.glassfish.hk2.api.ServiceLocator habitat, DeploymentContext context)
- Parameters:
habitat
-context
-- Returns:
-
getLibrariesAsURLs
public static URL[] getLibrariesAsURLs(Set<String> librariesStr, ServerEnvironment env)
converts libraries specified via EXTENSION_LIST entry in MANIFEST.MF of all of the libraries of the deployed archive to The libraries are made available to the application in the order specified.- Parameters:
librariesStr
- is a comma-separated list of library JAR filesenv
- the server environment- Returns:
- array of URL
-
getDeployParamLibrariesAsURLs
public static URL[] getDeployParamLibrariesAsURLs(String librariesStr, ServerEnvironment env)
converts libraries specified via the --libraries deployment option to URL[]. The library JAR files are specified by either relative or absolute paths. The relative path is relative to instance-root/lib/applibs. The libraries are made available to the application in the order specified.- Parameters:
librariesStr
- is a comma-separated list of library JAR filesenv
- the server environment- Returns:
- array of URL
-
getURLs
public static URL[] getURLs(File[] dirs, File[] jarDirs, boolean ignoreZip) throws IOException
Returns an array of urls that contains ..i. all the valid directories from the given directory (dirs) array ii. all jar files from the given directory (jarDirs) array iii. all zip files from the given directory (jarDirs) array if not ignoring zip file (ignoreZip is false).
- Parameters:
dirs
- array of directory path namesjarDirs
- array of path name to directories that contains JAR & ZIP files.ignoreZip
- whether to ignore zip files- Returns:
- an array of urls that contains all the valid dirs, *.jar & *.zip
- Throws:
IOException
- if an i/o error while constructing the urls
-
getURLsAsList
public static List<URL> getURLsAsList(File[] dirs, File[] jarDirs, boolean ignoreZip) throws IOException
Returns a list of urls that contains ..i. all the valid directories from the given directory (dirs) array ii. all jar files from the given directory (jarDirs) array iii. all zip files from the given directory (jarDirs) array if not ignoring zip file (ignoreZip is false).
- Parameters:
dirs
- array of directory path namesjarDirs
- array of path name to directories that contains JAR & ZIP files.ignoreZip
- whether to ignore zip files- Returns:
- an array of urls that contains all the valid dirs, *.jar & *.zip
- Throws:
IOException
- if an i/o error while constructing the urls
-
convertURLListToArray
public static URL[] convertURLListToArray(List<URL> list)
Converts a list of a URLs to an array- Parameters:
list
-- Returns:
- an empty array if list is null
-
getURLsFromClasspath
public static List<URL> getURLsFromClasspath(String classpath, String delimiter, String rootPath)
get URL list from classpath- Parameters:
classpath
- classpath string containing the classpathsdelimiter
- delimiter to separate the classpath components in the classpath stringrootPath
- root path of the classpath if the paths are relative- Returns:
- urlList URL list from the given classpath
-
getManifest
public static Manifest getManifest(String rootPath)
Returns the manifest file for the given root path.Example: |--repository/ | |--applications/ | |--converter/ | |--ejb-jar-ic_jar/ <---- rootPath | |--META-INF/ | |--MANIFEST.MF - Parameters:
rootPath
- absolute path to the module- Returns:
- the manifest file for the given module
-
getManifestClassPathAsURLs
public static List<URL> getManifestClassPathAsURLs(Manifest manifest, String rootPath)
Returns the class path (if any) from the given manifest file as an URL list.- Parameters:
manifest
- manifest file of an archiverootPath
- root path to the module- Returns:
- a list of URLs an empty list if given manifest is null
-
getAppLibDirLibraries
public static URL[] getAppLibDirLibraries(File appRoot, String appLibDir, String compatibilityProp) throws IOException
add all the libraries packaged in the application library directory- Parameters:
appRoot
- the application rootappLibDir
- the Application library directorycompatibilityProp
- the version of the release that we need to maintain backward compatibility- Returns:
- an array of URLs
- Throws:
IOException
-
getAppLibDirLibrariesAsList
public static List<URL> getAppLibDirLibrariesAsList(File appRoot, String appLibDir, String compatibilityProp) throws IOException
Gets a list of all the libraries packaged in the application library directory- Parameters:
appRoot
- the application rootappLibDir
- the Application library directorycompatibilityProp
- if this is "v2" then Glassfish v2 library locations will also be added- Returns:
- a List of the URLs
- Throws:
IOException
-
-