1 16 package org.apache.webapp.balancer; 17 18 import org.apache.tomcat.util.digester.Digester; 19 20 import java.io.InputStream ; 21 22 23 30 public class RulesParser { 31 34 private RuleChain result; 35 36 41 public RulesParser(InputStream input) { 42 try { 43 Digester digester = createDigester(); 44 result = (RuleChain) digester.parse(input); 45 } catch (Exception e) { 46 throw new RuntimeException (e); 47 } 48 } 49 50 55 public RuleChain getResult() { 56 return result; 57 } 58 59 64 protected Digester createDigester() { 65 Digester digester = new Digester(); 66 digester.setUseContextClassLoader(true); 67 68 String rules = "rules"; 69 String rule = "/rule"; 70 71 digester.addObjectCreate(rules, RuleChain.class); 73 74 digester.addObjectCreate(rules + rule, null, "className"); 76 77 digester.addSetProperties(rules + rule); 79 80 digester.addSetNext(rules + rule, "addRule", "org.apache.webapp.balancer.Rule"); 82 83 return digester; 84 } 85 } 86 87 88 | Popular Tags |