1 26 27 package org.objectweb.jonas.web.catalina55; 28 29 import java.net.URL ; 30 31 import org.apache.catalina.LifecycleException; 32 import org.apache.catalina.Valve; 33 import org.apache.catalina.authenticator.AuthenticatorBase; 34 import org.apache.catalina.core.StandardContext; 35 import org.apache.catalina.deploy.ContextEnvironment; 36 import org.apache.catalina.deploy.ContextResource; 37 38 import org.objectweb.jonas.common.Log; 39 import org.objectweb.jonas.service.ServiceManager; 40 import org.objectweb.jonas.web.wrapper.CatalinaJWebContainerService; 41 42 import org.objectweb.util.monolog.api.BasicLevel; 43 import org.objectweb.util.monolog.api.Logger; 44 45 52 53 public final class JOnASStandardContext extends StandardContext { 54 55 58 private static CatalinaJWebContainerService catalinaService = null; 59 60 63 private static Logger logger = null; 64 65 68 private URL earURL = null; 69 70 73 private boolean inEarCase = false; 74 75 78 private boolean inServerXml = false; 79 80 83 private boolean java2DelegationModel = false; 84 85 88 private String jonasDeploymentDescriptor = null; 89 90 93 private boolean startedJStdx = false; 94 95 98 private URL warURL = null; 99 100 103 public JOnASStandardContext() { 104 this(true, true, false); 105 } 106 107 113 public JOnASStandardContext(final boolean inServerXml, final boolean java2DelegationModel, final boolean inEarCase) { 114 super(); 115 this.inServerXml = inServerXml; 116 this.java2DelegationModel = java2DelegationModel; 117 this.inEarCase = inEarCase; 118 logger = Log.getLogger(Log.JONAS_WEB_PREFIX); 119 try { 120 catalinaService = (CatalinaJWebContainerService) ServiceManager.getInstance().getWebContainerService(); 121 } catch (Exception e) { 122 if (logger.isLoggable(BasicLevel.ERROR)) { 123 logger.log(BasicLevel.ERROR, "Cannot get Web container service"); 124 } 125 } 126 } 127 128 131 public URL getEarURL() { 132 return earURL; 133 } 134 135 139 public String getJonasDeploymentDescriptor() { 140 return jonasDeploymentDescriptor; 141 } 142 143 146 public URL getWarURL() { 147 return warURL; 148 } 149 150 153 public boolean isInEarCase() { 154 return inEarCase; 155 } 156 157 161 public boolean isInServerXml() { 162 return inServerXml; 163 } 164 165 168 public boolean isJava2DelegationModel() { 169 return java2DelegationModel; 170 } 171 172 175 protected void setEarURL(URL earURL) { 176 this.earURL = earURL; 177 } 178 179 182 protected void setInEarCase(boolean inEarCase) { 183 this.inEarCase = inEarCase; 184 } 185 186 189 protected void setJava2DelegationModel(boolean java2DelegationModel) { 190 this.java2DelegationModel = java2DelegationModel; 191 } 192 193 197 public void setJonasDeploymentDescriptor(String jonasDeploymentDescriptor) { 198 this.jonasDeploymentDescriptor = jonasDeploymentDescriptor; 199 } 200 201 204 protected void setWarURL(URL warURL) { 205 this.warURL = warURL; 206 } 207 208 212 public synchronized void start() throws LifecycleException { 213 if (logger.isLoggable(BasicLevel.DEBUG)) { 214 logger.log(BasicLevel.DEBUG, ""); 215 } 216 if (catalinaService != null && catalinaService.isTomcatStarted()) { 217 if (logger.isLoggable(BasicLevel.DEBUG)) { 218 logger.log(BasicLevel.DEBUG, "Tomcat in Web container service is started, starting the context..."); 219 } 220 startedJStdx = true; 221 super.start(); 222 } 223 224 } 225 226 230 public synchronized void stop() throws LifecycleException { 231 if (logger.isLoggable(BasicLevel.DEBUG)) { 232 logger.log(BasicLevel.DEBUG, ""); 233 } 234 if (startedJStdx) { 235 startedJStdx = false; 236 super.stop(); 237 } 238 239 } 240 241 244 public void unsetAuthenticationCaching() { 245 Valve[] valves = getValves(); 246 for (int i = 0; i < valves.length; i++) { 247 Valve valve = valves[i]; 248 if (valve instanceof AuthenticatorBase) { 249 AuthenticatorBase authBase = (AuthenticatorBase) valve; 250 authBase.setCache(false); 251 } 252 } 253 } 254 255 260 public void addResource(ContextResource resource) { 261 } 262 263 268 public void addEnvironment(ContextEnvironment environment) { 269 } 270 271 272 277 public void setParentClassLoader(ClassLoader parent) { 278 if (!startedJStdx) { 280 super.setParentClassLoader(parent); 281 } 282 } 283 } 284 | Popular Tags |