1 16 package org.apache.commons.chain.config; 17 18 19 import org.apache.commons.chain.Catalog; 20 import org.apache.commons.chain.Chain; 21 import org.apache.commons.chain.Command; 22 import org.apache.commons.digester.Rule; 23 import org.xml.sax.Attributes ; 24 25 26 37 class ConfigRegisterRule extends Rule { 38 39 40 42 43 50 public ConfigRegisterRule(String nameAttribute) { 51 super(); 52 this.nameAttribute = nameAttribute; 53 } 54 55 56 58 59 63 private String nameAttribute = null; 64 65 66 68 69 79 public void begin(String namespace, String name, Attributes attributes) 80 throws Exception { 81 82 Object top = digester.peek(0); 84 if ((top == null) 85 || !(top instanceof Command)) { 86 return; 87 } 88 Command command = (Command) top; 89 90 Object next = digester.peek(1); 92 if (next == null) { 93 return; 94 } 95 96 if (next instanceof Catalog) { 98 Catalog catalog = (Catalog) next; 99 String nameValue = attributes.getValue(nameAttribute); 100 if (nameValue != null) { 101 ((Catalog) next).addCommand(nameValue, command); 102 } 103 } else if (next instanceof Chain) { 104 ((Chain) next).addCommand(command); 105 } 106 107 } 108 109 110 } 111 | Popular Tags |