FileDocCategorySizeDatePackage
FacesConfigDescriptor.javaAPI DocGlassfish v2 API4805Fri May 04 22:34:18 BST 2007com.sun.enterprise.tools.verifier.web

FacesConfigDescriptor

public class FacesConfigDescriptor extends Object
Class which represents WEB-INF/faces-config.xml
author
bshankar@sun.com

Fields Summary
private final String
MANAGED_BEAN_CLASS
private final String
facesConfigFileName
private com.sun.enterprise.tools.verifier.Context
context
private Document
facesConfigDocument
Constructors Summary
public FacesConfigDescriptor(com.sun.enterprise.tools.verifier.Context context, com.sun.enterprise.deployment.WebBundleDescriptor descriptor)

    
         
        try {
            this.context = context;
            readFacesConfigDocument(descriptor);
        } catch(Exception ex) {
            facesConfigDocument = null;
        }
    
Methods Summary
public java.util.ListgetManagedBeanClasses()

        if (facesConfigDocument == null) {
            return new ArrayList<String>();
        }
        NodeList nl = facesConfigDocument.getElementsByTagName(MANAGED_BEAN_CLASS);
        List<String> classes = new ArrayList<String>();
        if (nl != null) {
            int size = nl.getLength();
            for (int i = 0; i < size; i++) {
                classes.add(nl.item(i).getFirstChild().getNodeValue().trim());
            }
        }
        return classes;
    
private voidreadFacesConfigDocument(com.sun.enterprise.deployment.WebBundleDescriptor webd)

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setValidating(false);
        DocumentBuilder builder = factory.newDocumentBuilder();
        ModuleDescriptor moduleDesc = webd.getModuleDescriptor();
        String archBase = context.getAbstractArchive().getArchiveUri();
        String uri = null;
        if(moduleDesc.isStandalone()){
            uri = archBase;
        } else {
            uri = archBase + File.separator +
                    FileUtils.makeFriendlyFileName(moduleDesc.getArchiveUri());
        }
        FileArchive arch = new FileArchive();
        arch.open(uri);
        InputStream is = arch.getEntry(facesConfigFileName);
        InputSource source = new InputSource(is);
        try {
            facesConfigDocument = builder.parse(source);
        } finally {
            try{
                if(is != null)
                    is.close();
            } catch(Exception e) {}
        }