public String parseZoneName(Document systemConfig) throws ParseException { Element root = systemConfig.getDocumentElement(); NodeList nodes = root.getElementsByTagName("zoneName"); if (nodes.getLength() == 1) { Element node = (Element) nodes.item(0); String name = node.getTextContent(); if (name != null) { name = name.trim(); } return name; } else if (nodes.getLength() == 0) { return DEFAULT_ZONE; } throw new ParseException("Invalid system configuration: more than one <runtime> element specified"); }
/** * Returns the product name. If not configured, "Fabric3" will be returned. * * @param systemConfig the system configuration * @return the product name * @throws ParseException if there is an error parsing the domain name */ public String parseProductName(Document systemConfig) throws ParseException { Element root = systemConfig.getDocumentElement(); NodeList nodes = root.getElementsByTagName("runtime"); if (nodes.getLength() == 1) { Element node = (Element) nodes.item(0); String name = node.getAttribute("product"); if (name.length() > 0) { return name; } else { return "Fabric3"; } } else if (nodes.getLength() == 0) { return "Fabric3"; } throw new ParseException("Invalid system configuration: more than one <runtime> element specified"); }
URI uri = new URI("fabric3://" + name); if (uri.getHost() == null) { throw new ParseException("Invalid domain name specified in system configuration. Domain names must be a valid URI host."); throw new ParseException("Invalid domain name specified in system configuration", e); return DEFAULT_DOMAIN; throw new ParseException("Invalid system configuration: more than one <runtime> element specified");
@Property(required = false) public void setSecurity(String level) throws ParseException { try { security = JmxSecurity.valueOf(level.toUpperCase()); } catch (IllegalArgumentException e) { throw new ParseException("Invalid JMX security setting:" + level); } }
@Property(required = false) public void setSecurity(String level) throws ParseException { try { security = JmxSecurity.valueOf(level.toUpperCase()); } catch (IllegalArgumentException e) { throw new ParseException("Invalid JMX security setting:" + level); } }
/** * Loads the system configuration value from a systemConfig.xml file or creates a default value if the file does not exist. * * @param configDirectory the directory where the file is located * @return the loaded value * @throws ParseException if an error parsing the file contents is encountered */ public Document loadSystemConfig(File configDirectory) throws ParseException { File systemConfig = new File(configDirectory, "systemConfig.xml"); if (systemConfig.exists()) { try { URL url = systemConfig.toURI().toURL(); Source source = new UrlSource(url); return loadSystemConfig(source); } catch (MalformedURLException e) { throw new ParseException(e); } } return createDefaultSystemConfig(); }
throw new ParseException(e); } catch (SAXException e) { throw new ParseException(e);