FileDocCategorySizeDatePackage
AddonClassPath.javaAPI DocGlassfish v2 API5474Fri May 04 22:30:24 BST 2007com.sun.enterprise.addons

AddonClassPath

public class AddonClassPath extends Object
Utility class that computes the classpath setting for the addon. Classpath is AS_HOME/lib/*.jar;AS_HOME/lib/ant/lib/*.jar
since
9.1
author
binod@dev.java.net

Fields Summary
private static final String
CONFIG
private static final String
ASENVCONF
private static final String
ASENVBAT
private static final String
ASANTREGEX
private static Logger
logger
Constructors Summary
Methods Summary
private static java.io.FilegetAntLib(java.lang.String installDir)

        BufferedReader bf = null;
        FileInputStream in = null;
        try {
            String asenv="";
            if(isUnix()) {
                asenv = installDir + File.separator + CONFIG + File.separator + 
                        ASENVCONF;
            } else {
                asenv = installDir + File.separator + CONFIG + File.separator + 
                        ASENVBAT;
            }
        
            logger.log(Level.FINER, asenv);

            in = new FileInputStream(asenv);
            String antLib = "";
            bf = new BufferedReader(new InputStreamReader(in));
            String line = bf.readLine();
            while(line != null) {
                logger.log(Level.FINER,line);
                String[] asantLine = line.split(ASANTREGEX);
                if (asantLine.length > 1) {
                    if (isUnix()) {
                       asantLine = asantLine[1].split("\"");
                    } 
                    antLib = asantLine[1];
                    logger.log(Level.FINER,"antLib "+antLib);
                    return new File(antLib);
                }
                line = bf.readLine();
             }
             return null;
        }catch(Exception e) {
            logger.log(Level.SEVERE,e.getMessage(), e);
            throw new AddonFatalException(e);
        } finally {
            try {
                if(bf != null)  
                    bf.close();
                if(in != null)
                    in.close();  
            } catch (Exception e) {
                logger.log(Level.WARNING,e.getMessage(), e);
            }
        }
    
static java.net.URL[]getClassPath(java.net.URL jar, java.lang.String installRoot, java.util.logging.Logger logr)


            
      
        logger = logr;
        File asLib = new File (installRoot + File.separator + "lib");
        File antLib = getAntLib(installRoot);

        File[] asLibJars = asLib.listFiles(new JarFileFilter());
        File[] antLibJars = antLib.listFiles(new JarFileFilter());

        URL[] urls = new URL[asLibJars.length + antLibJars.length+1];
        int i = 0;
        try {
            for (File asLibJar : asLibJars ) {
                urls[i] = asLibJar.toURI().toURL();
                i++;
            }

            for (File antLibJar : antLibJars ) {
                urls[i] = antLibJar.toURI().toURL();
                i++;
            }
        } catch (Exception e) {
            throw new AddonFatalException(e);
        }

        urls[i] = jar;
        return urls;
    
private static booleanisUnix()

        return OS.isUnix();