1 22 package org.objectweb.petals.jbi.transport.util; 23 24 25 30 public class JoramConfigurationBuilder { 31 32 private JoramConfigurationBuilder() { 33 } 35 36 60 public static String buildFullMasterConf(String domain, String id, 61 String name, String host, String username, String password, 62 String domainPort, String tcpPort, String uid) { 63 StringBuffer xml = new StringBuffer (); 64 xml.append("<?xml version=\"1.0\"?>\n"); 65 xml.append("<!-- <!DOCTYPE config SYSTEM \"a3config.dtd\">-->\n"); 66 xml.append("<config>\n"); 67 xml.append("\t<domain name=\"" + domain + "\"/>\n"); 68 xml.append(buildMasterServerConf(domain, id, name, host, username, 72 password, domainPort, tcpPort, uid)); 73 xml.append("</config>\n"); 74 75 return xml.toString(); 76 } 77 78 101 protected static String buildMasterServerConf(String domain, String id, 102 String name, String host, String username, String password, 103 String domainPort, String tcpPort, String uid) { 104 StringBuffer xml = new StringBuffer (); 105 xml.append("\t<server id=\"" + id + "\" name=\"" + name 106 + "\" hostname=\"" + host + "\">\n"); 107 xml.append("\t\t<property name=\"uid\" value=\"" + uid + "\"/>\n"); 108 xml.append("\t\t<network domain=\"" + domain + "\" port=\"" 109 + domainPort + "\"/>\n"); 110 xml 111 .append("\t\t<service class=\"org.objectweb.joram.mom.proxies.ConnectionManager\" args=\"" 112 + username + " " + password + "\"/>\n"); 113 xml 114 .append("\t\t<service class=\"org.objectweb.joram.mom.proxies.tcp.TcpProxyService\" args=\"" 115 + tcpPort + "\"/>\n"); 116 xml.append("\t</server>\n"); 122 return xml.toString(); 123 } 124 125 148 protected static String buildSlaveServerConf(String domain, String id, 149 String name, String host, String username, String password, 150 String domainPort, String tcpPort, String uid) { 151 StringBuffer xml = new StringBuffer (); 152 xml.append("\t<server id=\"" + id + "\" name=\"" + name 153 + "\" hostname=\"" + host + "\">\n"); 154 xml.append("\t\t<property name=\"uid\" value=\"" + uid + "\"/>\n"); 155 xml.append("\t\t<network domain=\"" + domain + "\" port=\"" 156 + domainPort + "\"/>\n"); 157 xml 158 .append("\t\t<service class=\"org.objectweb.joram.mom.proxies.ConnectionManager\" args=\"" 159 + username + " " + password + "\"/>\n"); 160 xml 161 .append("\t\t<service class=\"org.objectweb.joram.mom.proxies.tcp.TcpProxyService\" args=\"" 162 + tcpPort + "\"/>\n"); 163 169 xml.append("\t</server>\n"); 170 return xml.toString(); 171 } 172 173 199 public static String buildFullConfiguration(String masterConf, 200 String domain, String id, String name, String host, String username, 201 String password, String domainPort, String tcpPort, String uid) { 202 StringBuffer xml = new StringBuffer (masterConf); 203 204 if (xml.indexOf("id=\"" + id) == -1) { 206 xml.insert(xml.indexOf("</config>"), buildSlaveServerConf(domain, 207 id, name, host, username, password, domainPort, tcpPort, uid)); 208 } 209 210 return xml.toString(); 211 } 212 213 } 214 | Popular Tags |