1 package com.protomatter.syslog.xml; 2 3 52 53 import java.io.*; 54 import java.net.*; 55 import java.util.*; 56 import java.text.*; 57 58 import com.protomatter.xml.*; 59 import com.protomatter.syslog.*; 60 import org.jdom.*; 61 62 65 public class JMSLog_Helper 66 extends BasicLogger_Helper 67 { 68 180 public void configure(Object o, Element e) 181 throws SyslogInitException 182 { 183 super.configure(o, e); 184 JMSLog log = (JMSLog)o; 185 186 if (Syslog.getLocalHostName() == null) 187 Syslog.setLocalHostName(); 188 189 String tmp = null; 190 191 tmp = e.getChildTextTrim("topicName", e.getNamespace()); 192 if (tmp != null) 193 log.setTopicName(tmp); 194 else 195 throw new IllegalArgumentException (MessageFormat.format( 196 Syslog.getResourceString(MessageConstants.XML_MUST_SPECIFY_PARAM_MESSAGE), 197 new Object [] { "topicName" } )); 198 199 tmp = e.getChildTextTrim("factoryName", e.getNamespace()); 200 if (tmp != null) 201 log.setFactoryName(tmp); 202 else 203 throw new IllegalArgumentException (MessageFormat.format( 204 Syslog.getResourceString(MessageConstants.XML_MUST_SPECIFY_PARAM_MESSAGE), 205 new Object [] { "factoryName" } )); 206 207 tmp = e.getChildTextTrim("connectionUser", e.getNamespace()); 208 if (tmp != null) 209 log.setUser(tmp); 210 211 tmp = e.getChildTextTrim("connectionPass", e.getNamespace()); 212 if (tmp != null) 213 log.setPass(tmp); 214 215 tmp = e.getChildTextTrim("persistent"); 216 if (tmp != null) 217 log.setPersistent(tmp.equalsIgnoreCase("true")); 218 219 tmp = e.getChildTextTrim("ttl"); 220 if (tmp != null) 221 log.setTTL(Integer.parseInt(tmp)); 222 223 tmp = e.getChildTextTrim("priority"); 224 if (tmp != null) 225 log.setPriority(Integer.parseInt(tmp)); 226 227 log.start(); 228 } 229 230 public Element getConfiguration(Object o, Element element) 231 { 232 Element e = super.getConfiguration(o, element); 233 JMSLog log = (JMSLog)o; 234 235 e.getChildren().add( 236 (new Element("topicName")).setText(log.getTopicName())); 237 e.getChildren().add( 238 (new Element("factoryName")).setText(log.getFactoryName())); 239 240 if (log.getUser() != null) 241 { 242 e.getChildren().add( 243 (new Element("connectionUser")).setText(log.getUser())); 244 e.getChildren().add( 245 (new Element("connectionPass")).setText(log.getPass())); 246 } 247 248 e.getChildren().add((new Element("persistent")) 249 .setText(String.valueOf(log.getPersistent()))); 250 e.getChildren().add((new Element("priority")) 251 .setText(String.valueOf(log.getPriority()))); 252 e.getChildren().add((new Element("ttl")) 253 .setText(String.valueOf(log.getTTL()))); 254 return e; 255 } 256 } 257 | Popular Tags |