FileDocCategorySizeDatePackage
ExtractDomainRoots.javaAPI DocGlassfish v2 API4076Fri May 04 22:34:08 BST 2007com.sun.enterprise.admin.snmp

ExtractDomainRoots

public class ExtractDomainRoots extends Object

Fields Summary
Constructors Summary
Methods Summary
public java.lang.String[]getAllDomainRoots()

		Vector vt = new Vector();
        String[] domains = null;
        try
        {
            DomainRegistry domainRegistry = DomainRegistry.newInstance();
            Iterator it = domainRegistry.iterator();
            while (it.hasNext())
            {
                DomainEntry entry = (DomainEntry)it.next();
                vt.addElement(entry.getRoot().getPath());
            }
			domains = new String[vt.size()];
			domains = (String[])vt.toArray(domains);
        }
        catch (DomainRegistryException e)
        {
			System.err.println("ExtractDomainRoots: Exception caught, while parsing the domain registry");
			e.printStackTrace();
        }
       	return domains;
	
public static voidmain(java.lang.String[] args)

		ExtractDomainRoots droot = new ExtractDomainRoots();
		String[] dInfo = droot.getAllDomainRoots();
		droot.writeDomainInfo(dInfo);
	
public voidwriteDomainInfo(java.lang.String[] domains)

		String fileName = new String("/tmp/appserv_domainInfo.txt"); 
		try {
			File domainFile = new File(fileName);
			FileWriter domainFileWriter = new FileWriter(domainFile);
			for(int i = 0; i< domains.length; i++)
			{
				domainFileWriter.write(domains[i]);
				domainFileWriter.write("\n");
				System.out.println(domains[i]);
			}
			domainFileWriter.flush();
			domainFileWriter.close();
		}
		catch(IOException e) {
			System.out.println("ExtractDomainRoots: IOException caught while writing domain information to file");
			e.printStackTrace();
		}
		catch(Exception e) {
			System.out.println("ExtractDomainRoots: Exception caught while writing domain information to file");
			e.printStackTrace();
		}