1 23 24 29 30 package com.sun.enterprise.tools.upgrade.cluster; 31 32 36 import java.util.*; 37 import java.io.File ; 38 import java.io.IOException ; 39 40 import javax.xml.parsers.DocumentBuilder ; 41 import javax.xml.parsers.DocumentBuilderFactory ; 42 import javax.xml.parsers.FactoryConfigurationError ; 43 import javax.xml.parsers.ParserConfigurationException ; 44 45 import org.xml.sax.SAXException ; 46 import org.xml.sax.SAXParseException ; 47 48 import org.w3c.dom.Document ; 49 import org.w3c.dom.DOMException ; 50 import org.w3c.dom.Element ; 51 import org.w3c.dom.Node ; 52 import org.w3c.dom.NodeList ; 53 import com.sun.enterprise.util.i18n.StringManager; 54 55 public class LBInfo { 56 57 private List clusters; 58 private Properties lbProperties; 59 private static java.util.logging.Logger log = com.sun.enterprise.tools.upgrade.common.CommonInfoModel.getDefaultLogger(); 60 private StringManager stringManager = StringManager.getManager("com.sun.enterprise.tools.upgrade.gui"); 61 62 63 public LBInfo() { 64 clusters = new ArrayList(); 65 lbProperties = new Properties(); 66 } 67 public boolean processLoadBalancerFile(String lbFile){ 68 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 69 factory.setNamespaceAware(true); 71 try { 72 DocumentBuilder builder = factory.newDocumentBuilder(); 73 DocumentBuilder builderDomainXml = factory.newDocumentBuilder(); 74 builderDomainXml.setEntityResolver((org.xml.sax.helpers.DefaultHandler )Class.forName 75 ("com.sun.enterprise.config.serverbeans.ServerValidationHandler").newInstance()); 76 Element docEle = builderDomainXml.parse(new File (lbFile)).getDocumentElement(); 77 NodeList clEles = docEle.getElementsByTagName("cluster"); 78 for(int lh =0; lh < clEles.getLength(); lh++){ 79 clusters.add(new LBCluster((Element )clEles.item(lh))); 80 } 81 NodeList propEles = docEle.getElementsByTagName("cluster"); 82 for(int ph =0; ph < propEles.getLength(); ph++){ 83 Element propsEle = (Element )propEles.item(ph); 84 lbProperties.setProperty(propsEle.getAttribute("name"),propsEle.getAttribute("value")); 85 } 86 }catch (Exception ex){ 87 log.severe(stringManager.getString("upgrade.transform.startFailureMessage", ex.getMessage())); 88 log.severe(stringManager.getString("upgrade.transform.startFailureCheckAccessMessage")); 89 return false; 91 } 92 return true; 93 } 94 public java.util.List getClusters() { 95 return clusters; 96 } 97 public java.util.Properties getLbProperties() { 98 return lbProperties; 99 } 100 101 } 102 | Popular Tags |