1 25 26 package org.objectweb.jonas.web.catalina55; 27 28 import org.apache.tomcat.util.digester.Digester; 29 import org.apache.tomcat.util.digester.Rule; 30 import org.apache.tomcat.util.digester.RuleSetBase; 31 32 import org.apache.catalina.Container; 33 import org.apache.catalina.startup.ClusterRuleSet; 34 import org.apache.catalina.startup.ConnectorCreateRule; 35 import org.apache.catalina.startup.ContextRuleSet; 36 import org.apache.catalina.startup.EngineRuleSet; 37 import org.apache.catalina.startup.HostRuleSet; 38 import org.apache.catalina.startup.NamingRuleSet; 39 import org.apache.catalina.startup.SetAllPropertiesRule; 40 41 import org.xml.sax.Attributes ; 42 43 49 public class JCatalinaRuleSet extends RuleSetBase { 50 51 54 private ClassLoader parentClassLoader = null; 55 56 60 public JCatalinaRuleSet(final ClassLoader parentClassLoader) { 61 super(); 62 this.parentClassLoader = parentClassLoader; 63 } 64 65 66 67 71 public void addRuleInstances(Digester digester) { 72 73 digester.addObjectCreate("Server", 75 "org.apache.catalina.core.StandardServer", 76 "className"); 77 digester.addSetProperties("Server"); 78 digester.addSetNext("Server", 79 "setServer", 80 "org.apache.catalina.Server"); 81 82 digester.addObjectCreate("Server/GlobalNamingResources", 83 "org.apache.catalina.deploy.NamingResources"); 84 digester.addSetProperties("Server/GlobalNamingResources"); 85 digester.addSetNext("Server/GlobalNamingResources", 86 "setGlobalNamingResources", 87 "org.apache.catalina.deploy.NamingResources"); 88 89 90 digester.addObjectCreate("Server/Listener", 91 null, "className"); 93 digester.addSetProperties("Server/Listener"); 94 digester.addSetNext("Server/Listener", 95 "addLifecycleListener", 96 "org.apache.catalina.LifecycleListener"); 97 98 digester.addObjectCreate("Server/Service", 99 "org.apache.catalina.core.StandardService", 100 "className"); 101 digester.addSetProperties("Server/Service"); 102 digester.addSetNext("Server/Service", 103 "addService", 104 "org.apache.catalina.Service"); 105 106 digester.addObjectCreate("Server/Service/Listener", 107 null, "className"); 109 digester.addSetProperties("Server/Service/Listener"); 110 digester.addSetNext("Server/Service/Listener", 111 "addLifecycleListener", 112 "org.apache.catalina.LifecycleListener"); 113 114 digester.addRule("Server/Service/Connector", 115 new ConnectorCreateRule()); 116 digester.addRule("Server/Service/Connector", 117 new SetAllPropertiesRule()); 118 digester.addSetNext("Server/Service/Connector", 119 "addConnector", 120 "org.apache.catalina.connector.Connector"); 121 122 123 digester.addObjectCreate("Server/Service/Connector/Listener", 124 null, "className"); 126 digester.addSetProperties("Server/Service/Connector/Listener"); 127 digester.addSetNext("Server/Service/Connector/Listener", 128 "addLifecycleListener", 129 "org.apache.catalina.LifecycleListener"); 130 131 132 digester.addRuleSet(new NamingRuleSet("Server/GlobalNamingResources/")); 134 digester.addRuleSet(new EngineRuleSet("Server/Service/")); 135 digester.addRuleSet(new HostRuleSet("Server/Service/Engine/")); 136 digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Host/")); 137 digester.addRuleSet(new ClusterRuleSet("Server/Service/Engine/Host/Cluster/")); 138 digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/Host/Context/")); 139 140 digester.addRule("Server/Service/Engine", 142 new SetParentClassLoaderRule(parentClassLoader)); 143 } 144 } 145 146 150 final class SetParentClassLoaderRule extends Rule { 151 152 155 private ClassLoader parentClassLoader = null; 156 157 158 162 public SetParentClassLoaderRule(final ClassLoader parentClassLoader) { 163 super(); 164 this.parentClassLoader = parentClassLoader; 165 } 166 167 177 public void begin(String namespace, String name, Attributes attributes) throws Exception { 178 Container top = (Container) digester.peek(); 179 top.setParentClassLoader(parentClassLoader); 180 } 181 } 182 183 | Popular Tags |