/* Generated by Together */

package cobalt.deployment.descriptor.xml;

import java.util.Iterator;
import java.io.File;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;

import org.w3c.dom.Node;
import org.apache.xerces.dom.NodeImpl;
import org.w3c.dom.Element;
import org.apache.xerces.dom.ElementImpl;
import org.w3c.dom.Document;
import org.apache.xerces.dom.DocumentImpl;

import cobalt.deployment.descriptor.*;
import cobalt.deployment.util.XmlUtil;

/**
 * Title:        Enterprise application xml
 * Description:  J2EE standard enterprise application xml description
 * Copyright:    Copyright (c) 2001
 * Company:      ETRI
 * @author YeonJun Choi
 * @version 1.0
 */

public class ApplicationNode extends ElementNode {
	public ApplicationNode(Document doc) {
        super((DocumentImpl)doc, "application");
    }
    public ApplicationDescriptor getApplicationDescriptor() {
        return null;
    }
    public void setApplicationDescriptor(ApplicationDescriptor descriptor) {
        Document doc = getOwnerDocument();
        XmlUtil.appendApplicationDescriptorNode((DocumentImpl)doc, this, descriptor);
        XmlUtil.appendModuleDescriptorNode((DocumentImpl)doc, this, "ejb", descriptor.getEjbBundleFileNames().iterator());
        XmlUtil.appendModuleDescriptorNode((DocumentImpl)doc, this, "java", descriptor.getClientModuleFileNames().iterator());
        XmlUtil.appendSecurityRealmNode((DocumentImpl)doc, this, descriptor.getSecurityRoles());

    }

    public void writeNodeToFile(File file) throws IOException {
		BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
		fos.write(getXmlString().getBytes());
        fos.close();
    }
}
