1 17 18 19 package org.apache.catalina.startup; 20 21 22 import java.lang.reflect.Constructor ; 23 24 import org.apache.catalina.Container; 25 import org.apache.catalina.Loader; 26 import org.apache.tomcat.util.digester.Digester; 27 import org.apache.tomcat.util.digester.Rule; 28 import org.apache.tomcat.util.digester.RuleSetBase; 29 import org.xml.sax.Attributes ; 30 31 32 40 41 public class ContextRuleSet extends RuleSetBase { 42 43 44 46 47 50 protected String prefix = null; 51 52 53 56 protected boolean create = true; 57 58 59 61 62 66 public ContextRuleSet() { 67 68 this(""); 69 70 } 71 72 73 80 public ContextRuleSet(String prefix) { 81 82 super(); 83 this.namespaceURI = null; 84 this.prefix = prefix; 85 86 } 87 88 89 96 public ContextRuleSet(String prefix, boolean create) { 97 98 super(); 99 this.namespaceURI = null; 100 this.prefix = prefix; 101 this.create = create; 102 103 } 104 105 106 108 109 118 public void addRuleInstances(Digester digester) { 119 120 if (create) { 121 digester.addObjectCreate(prefix + "Context", 122 "org.apache.catalina.core.StandardContext", "className"); 123 digester.addSetProperties(prefix + "Context"); 124 } else { 125 digester.addRule(prefix + "Context", new SetContextPropertiesRule()); 126 } 127 128 if (create) { 129 digester.addRule(prefix + "Context", 130 new LifecycleListenerRule 131 ("org.apache.catalina.startup.ContextConfig", 132 "configClass")); 133 digester.addSetNext(prefix + "Context", 134 "addChild", 135 "org.apache.catalina.Container"); 136 } 137 digester.addCallMethod(prefix + "Context/InstanceListener", 138 "addInstanceListener", 0); 139 140 digester.addObjectCreate(prefix + "Context/Listener", 141 null, "className"); 143 digester.addSetProperties(prefix + "Context/Listener"); 144 digester.addSetNext(prefix + "Context/Listener", 145 "addLifecycleListener", 146 "org.apache.catalina.LifecycleListener"); 147 148 digester.addObjectCreate(prefix + "Context/Loader", 149 "org.apache.catalina.loader.WebappLoader", 150 "className"); 151 digester.addSetProperties(prefix + "Context/Loader"); 152 digester.addSetNext(prefix + "Context/Loader", 153 "setLoader", 154 "org.apache.catalina.Loader"); 155 156 digester.addObjectCreate(prefix + "Context/Manager", 157 "org.apache.catalina.session.StandardManager", 158 "className"); 159 digester.addSetProperties(prefix + "Context/Manager"); 160 digester.addSetNext(prefix + "Context/Manager", 161 "setManager", 162 "org.apache.catalina.Manager"); 163 164 digester.addObjectCreate(prefix + "Context/Manager/Store", 165 null, "className"); 167 digester.addSetProperties(prefix + "Context/Manager/Store"); 168 digester.addSetNext(prefix + "Context/Manager/Store", 169 "setStore", 170 "org.apache.catalina.Store"); 171 172 digester.addObjectCreate(prefix + "Context/Parameter", 173 "org.apache.catalina.deploy.ApplicationParameter"); 174 digester.addSetProperties(prefix + "Context/Parameter"); 175 digester.addSetNext(prefix + "Context/Parameter", 176 "addApplicationParameter", 177 "org.apache.catalina.deploy.ApplicationParameter"); 178 179 digester.addObjectCreate(prefix + "Context/Realm", 180 null, "className"); 182 digester.addSetProperties(prefix + "Context/Realm"); 183 digester.addSetNext(prefix + "Context/Realm", 184 "setRealm", 185 "org.apache.catalina.Realm"); 186 187 digester.addObjectCreate(prefix + "Context/Resources", 188 "org.apache.naming.resources.FileDirContext", 189 "className"); 190 digester.addSetProperties(prefix + "Context/Resources"); 191 digester.addSetNext(prefix + "Context/Resources", 192 "setResources", 193 "javax.naming.directory.DirContext"); 194 195 digester.addObjectCreate(prefix + "Context/ResourceLink", 196 "org.apache.catalina.deploy.ContextResourceLink"); 197 digester.addSetProperties(prefix + "Context/ResourceLink"); 198 digester.addRule(prefix + "Context/ResourceLink", 199 new SetNextNamingRule("addResourceLink", 200 "org.apache.catalina.deploy.ContextResourceLink")); 201 202 digester.addObjectCreate(prefix + "Context/Valve", 203 null, "className"); 205 digester.addSetProperties(prefix + "Context/Valve"); 206 digester.addSetNext(prefix + "Context/Valve", 207 "addValve", 208 "org.apache.catalina.Valve"); 209 210 digester.addCallMethod(prefix + "Context/WatchedResource", 211 "addWatchedResource", 0); 212 213 digester.addCallMethod(prefix + "Context/WrapperLifecycle", 214 "addWrapperLifecycle", 0); 215 216 digester.addCallMethod(prefix + "Context/WrapperListener", 217 "addWrapperListener", 0); 218 219 } 220 221 } 222 | Popular Tags |