JOnASStandardContext.java

00001 
00027 package org.objectweb.jonas.web.catalina50;
00028 
00029 import java.net.URL;
00030 
00031 import org.apache.catalina.LifecycleException;
00032 import org.apache.catalina.Valve;
00033 import org.apache.catalina.authenticator.AuthenticatorBase;
00034 import org.apache.catalina.core.StandardContext;
00035 import org.apache.catalina.deploy.ContextEnvironment;
00036 import org.apache.catalina.deploy.ContextResource;
00037 
00038 import org.objectweb.jonas.common.Log;
00039 import org.objectweb.jonas.service.ServiceManager;
00040 import org.objectweb.jonas.web.wrapper.CatalinaJWebContainerService;
00041 
00042 import org.objectweb.util.monolog.api.BasicLevel;
00043 import org.objectweb.util.monolog.api.Logger;
00044 
00053 public final class JOnASStandardContext extends StandardContext {
00054 
00058     private static CatalinaJWebContainerService catalinaService = null;
00059 
00063     private static Logger logger = null;
00064 
00068     private URL earURL = null;
00069 
00073     private boolean inEarCase = false;
00074 
00078     private boolean inServerXml = false;
00079 
00083     private boolean java2DelegationModel = false;
00084 
00088     private String jonasDeploymentDescriptor = null;
00089 
00093     private boolean startedJStdx = false;
00094 
00098     private URL warURL = null;
00099 
00103     public JOnASStandardContext() {
00104         this(true, true, false);
00105     }
00106 
00113     public JOnASStandardContext(boolean inServerXml, boolean java2DelegationModel, boolean inEarCase) {
00114         super();
00115         this.inServerXml = inServerXml;
00116         this.java2DelegationModel = java2DelegationModel;
00117         this.inEarCase = inEarCase;
00118         logger = Log.getLogger(Log.JONAS_WEB_PREFIX);
00119         try {
00120             catalinaService = (CatalinaJWebContainerService) ServiceManager.getInstance().getWebContainerService();
00121         } catch (Exception e) {
00122             if (logger.isLoggable(BasicLevel.ERROR)) {
00123                 logger.log(BasicLevel.ERROR, "Cannot get Web container service");
00124             }
00125         }
00126     }
00127 
00131     public URL getEarURL() {
00132         return earURL;
00133     }
00134 
00139     public String getJonasDeploymentDescriptor() {
00140         return jonasDeploymentDescriptor;
00141     }
00142 
00146     public URL getWarURL() {
00147         return warURL;
00148     }
00149 
00153     public boolean isInEarCase() {
00154         return inEarCase;
00155     }
00156 
00161     public boolean isInServerXml() {
00162         return inServerXml;
00163     }
00164 
00168     public boolean isJava2DelegationModel() {
00169         return java2DelegationModel;
00170     }
00171 
00175     protected void setEarURL(URL earURL) {
00176         this.earURL = earURL;
00177     }
00178 
00182     protected void setInEarCase(boolean inEarCase) {
00183         this.inEarCase = inEarCase;
00184     }
00185 
00189     protected void setJava2DelegationModel(boolean java2DelegationModel) {
00190         this.java2DelegationModel = java2DelegationModel;
00191     }
00192 
00197     public void setJonasDeploymentDescriptor(String jonasDeploymentDescriptor) {
00198         this.jonasDeploymentDescriptor = jonasDeploymentDescriptor;
00199     }
00200 
00204     protected void setWarURL(URL warURL) {
00205         this.warURL = warURL;
00206     }
00207 
00212     public synchronized void start() throws LifecycleException {
00213         if (logger.isLoggable(BasicLevel.DEBUG)) {
00214             logger.log(BasicLevel.DEBUG, "");
00215         }
00216         if (catalinaService != null && catalinaService.isTomcatStarted()) {
00217             if (logger.isLoggable(BasicLevel.DEBUG)) {
00218                 logger.log(BasicLevel.DEBUG, "Tomcat in Web container service is started, starting the context...");
00219             }
00220             startedJStdx = true;
00221             super.start();
00222         }
00223 
00224     }
00225 
00230     public synchronized void stop() throws LifecycleException {
00231         if (logger.isLoggable(BasicLevel.DEBUG)) {
00232             logger.log(BasicLevel.DEBUG, "");
00233         }
00234         if (startedJStdx) {
00235             startedJStdx = false;
00236             super.stop();
00237         }
00238 
00239     }
00240 
00244     public void unsetAuthenticationCaching() {
00245         Valve[] valves = getValves();
00246         for (int i = 0; i < valves.length; i++) {
00247             Valve valve = valves[i];
00248             if (valve instanceof AuthenticatorBase) {
00249                 AuthenticatorBase authBase = (AuthenticatorBase) valve;
00250                 authBase.setCache(false);
00251             }
00252         }
00253     }
00254 
00260     public void addResource(ContextResource resource) {
00261     }
00262 
00268     public void addEnvironment(ContextEnvironment environment) {
00269     }
00270 }

Generated on Tue Feb 15 15:05:25 2005 for JOnAS by  doxygen 1.3.9.1