/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
public class ASClassLoaderUtil {
final private static Logger _logger = LogDomains.getLogger(DeploymentUtils.class, LogDomains.DPL_LOGGER);
/** The manifest file name from an archive. */
/**
* Gets the classpath associated with a module, suffixing libraries
* defined [if any] for the application
*
* @param habitat the habitat the application resides in.
* @param moduleId Module id of the module
* @param deploymentLibs libraries option passed through deployment
* @return A <code>File.pathSeparator</code> separated list of classpaths
* for the passed in module, including the module specified
* "libraries" defined for the module.
*/
"for module Id : " + moduleId);
}
}
}
}
}
}
if (deploymentLibs == null) {
// this might be an internal container app,
// like _default_web_app, ignore.
return;
}
}
}
}
}
}
/**
* 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.
*
* @param librariesStr is a comma-separated list of library JAR files
* @param env the server environment
* @return array of URL
*/
if(librariesStr == null)
return null;
}
/**
* 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.
*
* @param librariesStr is a comma-separated list of library JAR files
* @param env the server environment
* @return array of URL
*/
if(librariesStr == null)
return null;
}
private static URL[] getDeployParamLibrariesAsURLs(ServerEnvironment env, String[] librariesStrArray,
int i=0;
try {
if(!f.isAbsolute())
} catch (MalformedURLException malEx) {
}
}
return urls;
}
synchronized (ASClassLoaderUtil.class) {
if (modulesClassPath == null) {
}
}
}
//set shared classpath for module so that it doesn't need to be
//recomputed for every other invocation
}
}
return modulesClassPath;
}
/**
* Returns an array of urls that contains ..
* <pre>
* 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).
* </pre>
*
* @param dirs array of directory path names
* @param jarDirs array of path name to directories that contains
* JAR & ZIP files.
* @param ignoreZip whether to ignore zip files
* @return an array of urls that contains all the valid dirs,
* *.jar & *.zip
*
* @throws IOException if an i/o error while constructing the urls
*/
boolean ignoreZip) throws IOException {
}
/**
* Returns a list of urls that contains ..
* <pre>
* 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).
* </pre>
*
* @param dirs array of directory path names
* @param jarDirs array of path name to directories that contains
* JAR & ZIP files.
* @param ignoreZip whether to ignore zip files
* @return an array of urls that contains all the valid dirs,
* *.jar & *.zip
*
* @throws IOException if an i/o error while constructing the urls
*/
boolean ignoreZip) throws IOException {
// adds all directories
}
}
}
}
// adds all the jars
}
}
}
}
}
}
return list;
}
// converts the list to an array
}
return urls;
}
/**
* get URL list from classpath
* @param classpath classpath string containing the classpaths
* @param delimiter delimiter to separate the classpath components
* in the classpath string
* @param rootPath root path of the classpath if the paths are relative
* @return urlList URL list from the given classpath
*/
return urls;
}
// tokenize classpath
while (st.hasMoreTokens()) {
try {
try {
// try to see if the path is absolute
if (uri.isAbsolute()) {
continue;
}
// ignore
}
}
} catch(Exception e) {
"unexpected error in getting urls",e);
}
}
return urls;
}
/**
* Returns the manifest file for the given root path.
*
* <xmp>
* Example:
* |--repository/
* | |--applications/
* | |--converter/
* | |--ejb-jar-ic_jar/ <---- rootPath
* | |--META-INF/
* | |--MANIFEST.MF
* </xmp>
*
* @param rootPath absolute path to the module
*
* @return the manifest file for the given module
*/
// gets the input stream to the MANIFEST.MF file
try {
}
} catch (IOException ioe) {
// ignore
} finally {
try {
} catch (IOException ioe) {
// Ignore
}
}
}
return mf;
}
/**
* Returns the class path (if any) from the given manifest file as an
* URL list.
*
* @param manifest manifest file of an archive
* @param rootPath root path to the module
*
* @return a list of URLs
* an empty list if given manifest is null
*/
rootPath);
}
}
}
return urlList;
}
/**
* add all the libraries packaged in the application library directory
*
* @param appRoot the application root
* @param appLibDir the Application library directory
* @param compatibilityProp the version of the release that we need to
* maintain backward compatibility
* @return an array of URL
*/
throws IOException {
return convertURLListToArray(
}
public static List<URL> getAppLibDirLibrariesAsList(File appRoot, String appLibDir, String compatibilityProp)
throws IOException {
// get all the app lib dir libraries
}
}
// if the compatibility property is set to "v2", we should add all the
// jars under the application root to maintain backward compatibility
// of v2 jar visibility
}
return allLibDirLibraries;
}
}