FileDocCategorySizeDatePackage
AddOnUtils.javaAPI DocGlassfish v2 API3892Fri May 04 22:30:24 BST 2007com.sun.enterprise.addons.util

AddOnUtils

public class AddOnUtils extends Object
since
9.1
author
sreenivas munnangi, msreddy@dev.java.net

Fields Summary
Constructors Summary
Methods Summary
public static java.util.jar.JarFilegetAddonJarFile(java.lang.String addonName, java.io.File jarDir, java.io.FilenameFilter filter)


        if ((jarDir == null) || (addonName == null) || (filter == null)) {
            throw new Exception("invalid input to getAddonJarFile");
        }

        File[] jars = jarDir.listFiles(filter);
        String str;
        for (File jar:jars) {
            str = jar.getName().split(ConfigurableJarFileFilter.regex)[0];
            if (str.equals(addonName)) {
                return new JarFile(jar);
            }
        }
        return null;
    
public static java.lang.String[]getDependencies(java.util.jar.JarFile jar)


        String [] strArr = null;

        if (jar == null) {
            throw new Exception("invalid input to getDependencies");
        }

        Manifest mf = jar.getManifest();
        if (mf == null) return strArr;

        Attributes attrs = mf.getMainAttributes();
        if (attrs == null) return strArr;

        Set<Map.Entry<Object, Object>> mfattrs = attrs.entrySet();
        String key, val;
        for (Map.Entry<Object,Object> entry : mfattrs) {
            key = ((Attributes.Name) entry.getKey()).toString();
            val = (String) entry.getValue();
            if (! key.equals("Add-On-Dependencies")) continue;
            if (val.contains(",")) {
                strArr = val.split(",");
            } else {
                strArr = new String[1];
                strArr[0] = val;
            }
        }
        return strArr;