~ubuntu-branches/ubuntu/vivid/tomcat6/vivid-proposed

« back to all changes in this revision

Viewing changes to java/org/apache/catalina/core/StandardContext.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-02-17 00:02:00 UTC
  • mfrom: (1.2.10)
  • Revision ID: package-import@ubuntu.com-20140217000200-qs6ki7bhqnfhkas7
Tags: 6.0.39-1
* Team upload.
* New upstream release.
  - Refreshed the patches
* Standards-Version updated to 3.9.5 (no changes)
* Switch to debhelper level 9
* Use XZ compression for the upstream tarball
* Use canonical URL for the Vcs-Git field

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
6
 * (the "License"); you may not use this file except in compliance with
7
7
 * the License.  You may obtain a copy of the License at
8
 
 * 
 
8
 *
9
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 
 * 
 
10
 *
11
11
 * Unless required by applicable law or agreed to in writing, software
12
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
101
101
import org.apache.naming.resources.FileDirContext;
102
102
import org.apache.naming.resources.ProxyDirContext;
103
103
import org.apache.naming.resources.WARDirContext;
 
104
import org.apache.tomcat.util.descriptor.XmlIdentifiers;
104
105
import org.apache.tomcat.util.modeler.Registry;
105
106
 
106
107
/**
110
111
 *
111
112
 * @author Craig R. McClanahan
112
113
 * @author Remy Maucherat
113
 
 * @version $Id: StandardContext.java 1080224 2011-03-10 13:52:41Z markt $
 
114
 * @version $Id: StandardContext.java 1561795 2014-01-27 19:03:54Z markt $
114
115
 */
115
116
 
116
117
public class StandardContext
191
192
     */
192
193
    private boolean antiJARLocking = false;
193
194
 
194
 
    
 
195
 
195
196
    /**
196
197
     * The antiResourceLocking flag for this Context.
197
198
     */
198
199
    private boolean antiResourceLocking = false;
199
200
 
200
 
    
 
201
 
201
202
    /**
202
203
     * The set of application listener class names configured for this
203
204
     * application, in the order they were encountered in the web.xml file.
204
205
     */
205
206
    private String applicationListeners[] = new String[0];
206
 
    
 
207
 
207
208
    private final Object applicationListenersLock = new Object();
208
209
 
209
210
 
210
211
    /**
211
212
     * The set of instantiated application event listener objects</code>.
212
213
     */
213
 
    private transient Object applicationEventListenersObjects[] = 
 
214
    private transient Object applicationEventListenersObjects[] =
214
215
        new Object[0];
215
216
 
216
217
 
217
218
    /**
218
219
     * The set of instantiated application lifecycle listener objects</code>.
219
220
     */
220
 
    private transient Object applicationLifecycleListenersObjects[] = 
 
221
    private transient Object applicationLifecycleListenersObjects[] =
221
222
        new Object[0];
222
223
 
223
224
 
228
229
        new ApplicationParameter[0];
229
230
 
230
231
    private final Object applicationParametersLock = new Object();
231
 
    
 
232
 
232
233
 
233
234
    /**
234
235
     * The application available flag for this Context.
235
236
     */
236
237
    private boolean available = false;
237
 
    
 
238
 
238
239
    /**
239
 
     * The broadcaster that sends j2ee notifications. 
 
240
     * The broadcaster that sends j2ee notifications.
240
241
     */
241
242
    private NotificationBroadcasterSupport broadcaster = null;
242
 
    
 
243
 
243
244
    /**
244
245
     * The Locale to character set mapper for this application.
245
246
     */
269
270
     * The security constraints for this web application.
270
271
     */
271
272
    private SecurityConstraint constraints[] = new SecurityConstraint[0];
272
 
    
 
273
 
273
274
    private final Object constraintsLock = new Object();
274
275
 
275
276
 
297
298
     */
298
299
    private boolean crossContext = false;
299
300
 
300
 
    
 
301
 
301
302
    /**
302
303
     * Encoded path.
303
304
     */
304
305
    private String encodedPath = null;
305
 
    
 
306
 
306
307
 
307
308
    /**
308
309
     * The "follow standard delegation model" flag that will be used to
317
318
    private String displayName = null;
318
319
 
319
320
 
320
 
    /** 
 
321
    /**
321
322
     * Override the default context xml location.
322
323
     */
323
324
    private String defaultContextXml;
324
325
 
325
326
 
326
 
    /** 
 
327
    /**
327
328
     * Override the default web xml location.
328
329
     */
329
330
    private String defaultWebXml;
342
343
 
343
344
 
344
345
    /**
345
 
     * Has URL rewriting been disabled. 
 
346
     * Has URL rewriting been disabled.
346
347
     */
347
348
    private boolean disableURLRewriting = false;
348
349
 
373
374
     * they were defined in the deployment descriptor.
374
375
     */
375
376
    private FilterMap filterMaps[] = new FilterMap[0];
376
 
    
 
377
 
377
378
    private final Object filterMapsLock = new Object();
378
379
 
379
380
 
401
402
    /**
402
403
     * The mapper associated with this context.
403
404
     */
404
 
    private org.apache.tomcat.util.http.mapper.Mapper mapper = 
 
405
    private org.apache.tomcat.util.http.mapper.Mapper mapper =
405
406
        new org.apache.tomcat.util.http.mapper.Mapper();
406
407
 
407
408
 
478
479
     * The original document root for this web application.
479
480
     */
480
481
    private String originalDocBase = null;
481
 
    
482
 
    
 
482
 
 
483
 
483
484
    /**
484
485
     * The privileged flag for this web application.
485
486
     */
516
517
     * matching pattern.
517
518
     */
518
519
    private HashMap servletMappings = new HashMap();
519
 
    
 
520
 
520
521
    private final Object servletMappingsLock = new Object();
521
522
 
522
523
 
529
530
     * The notification sequence number.
530
531
     */
531
532
    private long sequenceNumber = 0;
532
 
    
 
533
 
533
534
    /**
534
535
     * The status code error pages for this web application, keyed by
535
536
     * HTTP status code (as an Integer).
646
647
    protected int cacheMaxSize = 10240; // 10 MB
647
648
 
648
649
 
 
650
 
 
651
    /**
 
652
     * Attribute used to turn on/off the use of external entities.
 
653
     */
 
654
    private boolean xmlBlockExternal = Globals.IS_SECURITY_ENABLED;
 
655
 
 
656
 
649
657
    /**
650
658
     * Cache object max size in KB.
651
659
     */
669
677
    private long startTime;
670
678
    private long tldScanTime;
671
679
 
672
 
    /** 
 
680
    /**
673
681
     * Name of the engine. If null, the domain is used.
674
 
     */ 
 
682
     */
675
683
    private String engineName = null;
676
684
    private String j2EEApplication="none";
677
685
    private String j2EEServer="none";
680
688
    /**
681
689
     * Attribute value used to turn on/off XML validation
682
690
     */
683
 
     private boolean webXmlValidation = false;
 
691
     private boolean webXmlValidation = Globals.STRICT_SERVLET_COMPLIANCE;
684
692
 
685
693
 
686
694
    /**
687
695
     * Attribute value used to turn on/off XML namespace validation
688
696
     */
689
 
     private boolean webXmlNamespaceAware = false;
 
697
     private boolean webXmlNamespaceAware = Globals.STRICT_SERVLET_COMPLIANCE;
690
698
 
691
699
    /**
692
700
     * Attribute value used to turn on/off TLD processing
696
704
    /**
697
705
     * Attribute value used to turn on/off XML validation
698
706
     */
699
 
     private boolean tldValidation = false;
700
 
 
701
 
 
702
 
    /**
703
 
     * Attribute value used to turn on/off TLD XML namespace validation
704
 
     */
705
 
     private boolean tldNamespaceAware = false;
 
707
     private boolean tldValidation = Globals.STRICT_SERVLET_COMPLIANCE;
706
708
 
707
709
 
708
710
    /**
710
712
     */
711
713
    private boolean saveConfig = true;
712
714
 
713
 
    
 
715
 
714
716
    /**
715
717
     * The flag that indicates that session cookies should use HttpOnly
716
718
     */
717
719
    private boolean useHttpOnly = false;
718
720
 
719
 
    
 
721
 
720
722
    /**
721
723
     * The domain to use for session cookies. <code>null</code> indicates that
722
724
     * the domain is controlled by the application.
723
725
     */
724
726
    private String sessionCookieDomain;
725
727
 
726
 
    
 
728
 
727
729
    /**
728
730
     * The path to use for session cookies. <code>null</code> indicates that
729
731
     * the path is controlled by the application.
730
732
     */
731
733
    private String sessionCookiePath;
732
734
 
733
 
    
 
735
 
734
736
    /**
735
737
     * The name to use for session cookies. <code>null</code> indicates that
736
738
     * the name is controlled by the application.
737
739
     */
738
740
    private String sessionCookieName;
739
741
 
740
 
    
 
742
 
741
743
    /**
742
744
     * Should Tomcat attempt to terminate threads that have been started by the
743
745
     * web application? Stopping threads is performed via the deprecated (for
759
761
    /**
760
762
     * If an HttpClient keep-alive timer thread has been started by this web
761
763
     * application and is still running, should Tomcat change the context class
762
 
     * loader from the current {@link WebappClassLoader} to
763
 
     * {@link WebappClassLoader#parent} to prevent a memory leak? Note that the
764
 
     * keep-alive timer thread will stop on its own once the keep-alives all
765
 
     * expire however, on a busy system that might not happen for some time.
 
764
     * loader from the current
 
765
     * {@link org.apache.catalina.loader.WebappClassLoader} to
 
766
     * {@link org.apache.catalina.loader.WebappClassLoader#parent} to prevent a
 
767
     * memory leak? Note that the keep-alive timer thread will stop on its own
 
768
     * once the keep-alives all expire however, on a busy system that might not
 
769
     * happen for some time.
766
770
     */
767
771
    private boolean clearReferencesHttpClientKeepAliveThread = true;
768
 
    
 
772
 
769
773
    /**
770
774
     * Should Tomcat attempt to clear any ThreadLocal objects that are instances
771
775
     * of classes loaded by this class loader. Failure to remove any such
774
778
     * objects is not performed in a thread-safe manner.
775
779
     */
776
780
    private boolean clearReferencesThreadLocals = false;
777
 
    
 
781
 
778
782
    // ----------------------------------------------------- Context Properties
779
783
 
780
784
 
787
791
       this.annotationProcessor = annotationProcessor;
788
792
    }
789
793
 
790
 
    
 
794
 
791
795
    public String getEncodedPath() {
792
796
        return encodedPath;
793
797
    }
1189
1193
                                   this.cookies);
1190
1194
 
1191
1195
    }
1192
 
    
 
1196
 
1193
1197
    /**
1194
1198
     * Gets the value of the use HttpOnly cookies for session cookies flag.
1195
 
     * 
 
1199
     *
1196
1200
     * @return <code>true</code> if the HttpOnly flag should be set on session
1197
1201
     *         cookies
1198
1202
     */
1203
1207
 
1204
1208
    /**
1205
1209
     * Sets the use HttpOnly cookies for session cookies flag.
1206
 
     * 
 
1210
     *
1207
1211
     * @param useHttpOnly   Set to <code>true</code> to use HttpOnly cookies
1208
1212
     *                          for session cookies
1209
1213
     */
1214
1218
                oldUseHttpOnly,
1215
1219
                this.useHttpOnly);
1216
1220
    }
1217
 
    
1218
 
    
 
1221
 
 
1222
 
1219
1223
    /**
1220
1224
     * Gets the domain to use for session cookies.
1221
 
     * 
 
1225
     *
1222
1226
     * @return  The value of the default session cookie domain or null if not
1223
1227
     *          specified
1224
1228
     */
1225
1229
    public String getSessionCookieDomain() {
1226
1230
        return sessionCookieDomain;
1227
1231
    }
1228
 
    
1229
 
    
 
1232
 
 
1233
 
1230
1234
    /**
1231
1235
     * Sets the domain to use for session cookies.
1232
 
     * 
 
1236
     *
1233
1237
     * @param sessionCookieDomain   The domain to use
1234
1238
     */
1235
1239
    public void setSessionCookieDomain(String sessionCookieDomain) {
1242
1246
 
1243
1247
    /**
1244
1248
     * Gets the path to use for session cookies.
1245
 
     * 
 
1249
     *
1246
1250
     * @return  The value of the default session cookie path or null if not
1247
1251
     *          specified
1248
1252
     */
1249
1253
    public String getSessionCookiePath() {
1250
1254
        return sessionCookiePath;
1251
1255
    }
1252
 
    
1253
 
    
 
1256
 
 
1257
 
1254
1258
    /**
1255
1259
     * Sets the path to use for session cookies.
1256
 
     * 
 
1260
     *
1257
1261
     * @param sessionCookiePath   The path to use
1258
1262
     */
1259
1263
    public void setSessionCookiePath(String sessionCookiePath) {
1263
1267
                oldSessionCookiePath, sessionCookiePath);
1264
1268
    }
1265
1269
 
1266
 
    
 
1270
 
1267
1271
    /**
1268
1272
     * Gets the name to use for session cookies.
1269
 
     * 
 
1273
     *
1270
1274
     * @return  The value of the default session cookie name or null if not
1271
1275
     *          specified
1272
1276
     */
1273
1277
    public String getSessionCookieName() {
1274
1278
        return sessionCookieName;
1275
1279
    }
1276
 
    
1277
 
    
 
1280
 
 
1281
 
1278
1282
    /**
1279
1283
     * Sets the name to use for session cookies. Overrides any setting that
1280
1284
     * may be specified by the application.
1281
 
     * 
 
1285
     *
1282
1286
     * @param sessionCookieName   The name to use
1283
1287
     */
1284
1288
    public void setSessionCookieName(String sessionCookieName) {
1288
1292
                oldSessionCookieName, sessionCookieName);
1289
1293
    }
1290
1294
 
1291
 
    
 
1295
 
1292
1296
    /**
1293
1297
     * Return the "allow crossing servlet contexts" flag.
1294
1298
     */
1318
1322
        return defaultContextXml;
1319
1323
    }
1320
1324
 
1321
 
    /** 
 
1325
    /**
1322
1326
     * Set the location of the default context xml that will be used.
1323
1327
     * If not absolute, it'll be made relative to the engine's base dir
1324
1328
     * ( which defaults to catalina.base system property ).
1325
1329
     *
1326
 
     * @param defaultContextXml The default web xml 
 
1330
     * @param defaultContextXml The default web xml
1327
1331
     */
1328
1332
    public void setDefaultContextXml(String defaultContextXml) {
1329
1333
        this.defaultContextXml = defaultContextXml;
1333
1337
        return defaultWebXml;
1334
1338
    }
1335
1339
 
1336
 
    /** 
 
1340
    /**
1337
1341
     * Set the location of the default web xml that will be used.
1338
1342
     * If not absolute, it'll be made relative to the engine's base dir
1339
1343
     * ( which defaults to catalina.base system property ).
1340
1344
     *
1341
 
     * @param defaultWebXml The default web xml 
 
1345
     * @param defaultWebXml The default web xml
1342
1346
     */
1343
1347
    public void setDefaultWebXml(String defaultWebXml) {
1344
1348
        this.defaultWebXml = defaultWebXml;
1478
1482
        this.docBase = docBase;
1479
1483
 
1480
1484
    }
1481
 
    
 
1485
 
1482
1486
    /**
1483
1487
     * Is URL rewriting disabled?
1484
1488
     * URL rewriting is an optional component of the servlet 2.5 specification.
1485
1489
     * However if set to true this will be non-compliant with the specification
1486
1490
     * as the specification requires that there <b>must</b> be a way to retain
1487
1491
     * sessions if the client doesn't allow session cookies.
1488
 
     * 
 
1492
     *
1489
1493
     * @return true If URL rewriting is disabled.
1490
 
     * 
 
1494
     *
1491
1495
     * @see <a href="http://jcp.org/aboutJava/communityprocess/mrel/jsr154/index2.html">Servlet
1492
1496
     *      2.5 Specification. Sections SRV.7.1.3 and SRV.7.1.4</a>
1493
1497
     * @see javax.servlet.http.HttpServletResponse#encodeURL(String) encodeURL
1497
1501
    public boolean isDisableURLRewriting() {
1498
1502
        return (this.disableURLRewriting);
1499
1503
    }
1500
 
    
 
1504
 
1501
1505
    /**
1502
1506
     * Sets the disabling of URL Rewriting.
1503
1507
     * @param disable True to disable URL Rewriting. Default <b>false</b>.
1507
1511
        this.disableURLRewriting = disable;
1508
1512
        support.firePropertyChange("disableURLRewriting",
1509
1513
                oldDisableURLRewriting, disableURLRewriting);
1510
 
        
 
1514
 
1511
1515
    }
1512
1516
 
1513
1517
    // experimental
1575
1579
    public boolean getIgnoreAnnotations() {
1576
1580
        return this.ignoreAnnotations;
1577
1581
    }
1578
 
    
1579
 
    
 
1582
 
 
1583
 
1580
1584
    /**
1581
 
     * Set the boolean on the annotations parsing for this web 
 
1585
     * Set the boolean on the annotations parsing for this web
1582
1586
     * application.
1583
 
     * 
 
1587
     *
1584
1588
     * @param ignoreAnnotations The boolean on the annotations parsing
1585
1589
     */
1586
1590
    public void setIgnoreAnnotations(boolean ignoreAnnotations) {
1589
1593
        support.firePropertyChange("ignoreAnnotations", oldIgnoreAnnotations,
1590
1594
                this.ignoreAnnotations);
1591
1595
    }
1592
 
    
1593
 
    
 
1596
 
 
1597
 
1594
1598
    /**
1595
1599
     * Return the login configuration descriptor for this web application.
1596
1600
     */
1695
1699
 
1696
1700
    }
1697
1701
 
1698
 
    
 
1702
 
1699
1703
    /**
1700
1704
     * Set the context path for this Context.
1701
1705
     * <p>
1782
1786
 
1783
1787
        this.originalDocBase = docBase;
1784
1788
    }
1785
 
    
 
1789
 
1786
1790
 
1787
1791
    /**
1788
1792
     * Return the parent class loader (if any) for this web application.
1800
1804
        return (ClassLoader.getSystemClassLoader());
1801
1805
    }
1802
1806
 
1803
 
    
 
1807
 
1804
1808
    /**
1805
1809
     * Return the privileged flag for this web application.
1806
1810
     */
1974
1978
    /**
1975
1979
     * Set the value of the unloadDelay flag, which represents the amount
1976
1980
     * of ms that the container will wait when unloading servlets.
1977
 
     * Setting this to a small value may cause more requests to fail 
 
1981
     * Setting this to a small value may cause more requests to fail
1978
1982
     * to complete when stopping a web application.
1979
1983
     *
1980
1984
     * @param unloadDelay The new value
2034
2038
        this.wrapperClassName = wrapperClassName;
2035
2039
 
2036
2040
        try {
2037
 
            wrapperClass = Class.forName(wrapperClassName);         
 
2041
            wrapperClass = Class.forName(wrapperClassName);
2038
2042
            if (!StandardWrapper.class.isAssignableFrom(wrapperClass)) {
2039
2043
                throw new IllegalArgumentException(
2040
2044
                    sm.getString("standardContext.invalidWrapperClass",
2117
2121
 
2118
2122
    /** Get the absolute path to the work dir.
2119
2123
     *  To avoid duplication.
2120
 
     * 
 
2124
     *
2121
2125
     * @return The work path
2122
 
     */ 
 
2126
     */
2123
2127
    public String getWorkPath() {
2124
2128
        if (getWorkDir() == null) {
2125
2129
            return null;
2138
2142
        }
2139
2143
        return workDir.getAbsolutePath();
2140
2144
    }
2141
 
    
 
2145
 
2142
2146
    /**
2143
2147
     * Return the work directory for this Context.
2144
2148
     */
2263
2267
 
2264
2268
 
2265
2269
    /**
2266
 
     * Set the clearReferencesStopThreads feature for this Context.
 
2270
     * Set the clearReferencesThreadLocals feature for this Context.
2267
2271
     *
2268
 
     * @param clearReferencesStopThreads The new flag value
 
2272
     * @param clearReferencesThreadLocals The new flag value
2269
2273
     */
2270
2274
    public void setClearReferencesThreadLocals(
2271
2275
            boolean clearReferencesThreadLocals) {
2371
2375
        if ((jspFile != null) && !jspFile.startsWith("/")) {
2372
2376
            if (isServlet22()) {
2373
2377
                if(log.isDebugEnabled())
2374
 
                    log.debug(sm.getString("standardContext.wrapper.warning", 
 
2378
                    log.debug(sm.getString("standardContext.wrapper.warning",
2375
2379
                                       jspFile));
2376
2380
                wrapper.setJspFile("/" + jspFile);
2377
2381
            } else {
2509
2513
//      if ((servletNames.length == 0) && (urlPatterns.length == 0))
2510
2514
//      Servlet API 2.5 (FIX 43338)
2511
2515
//      SRV 6.2.5 says supporting for '*' as the servlet-name in filter-mapping.
2512
 
        if (!filterMap.getMatchAllServletNames() && 
2513
 
            !filterMap.getMatchAllUrlPatterns() && 
 
2516
        if (!filterMap.getMatchAllServletNames() &&
 
2517
            !filterMap.getMatchAllUrlPatterns() &&
2514
2518
            (servletNames.length == 0) && (urlPatterns.length == 0))
2515
2519
            throw new IllegalArgumentException
2516
2520
                (sm.getString("standardContext.filterMap.either"));
3083
3087
    public Context findMappingObject() {
3084
3088
        return (Context) getMappingObject();
3085
3089
    }
3086
 
    
3087
 
    
 
3090
 
 
3091
 
3088
3092
    /**
3089
3093
     * Return the message destination with the specified name, if any;
3090
3094
     * otherwise, return <code>null</code>.
3371
3375
 
3372
3376
 
3373
3377
    /**
3374
 
     * Return the set of watched resources for this Context. If none are 
 
3378
     * Return the set of watched resources for this Context. If none are
3375
3379
     * defined, a zero length array will be returned.
3376
3380
     */
3377
3381
    public String[] findWatchedResources() {
3379
3383
            return watchedResources;
3380
3384
        }
3381
3385
    }
3382
 
    
3383
 
    
 
3386
 
 
3387
 
3384
3388
    /**
3385
3389
     * Return the set of welcome files defined for this Context.  If none are
3386
3390
     * defined, a zero-length array is returned.
3873
3877
    /**
3874
3878
     * Remove the specified watched resource name from the list associated
3875
3879
     * with this Context.
3876
 
     * 
 
3880
     *
3877
3881
     * @param name Name of the watched resource to be removed
3878
3882
     */
3879
3883
    public void removeWatchedResource(String name) {
3880
 
        
 
3884
 
3881
3885
        synchronized (watchedResourcesLock) {
3882
3886
 
3883
3887
            // Make sure this watched resource is currently present
3905
3909
        fireContainerEvent("removeWatchedResource", name);
3906
3910
 
3907
3911
    }
3908
 
    
3909
 
    
 
3912
 
 
3913
 
3910
3914
    /**
3911
3915
     * Remove the specified welcome file name from the list recognized
3912
3916
     * by this Context.
4032
4036
     * StandardContext
4033
4037
     */
4034
4038
    public long getProcessingTime() {
4035
 
        
 
4039
 
4036
4040
        long result = 0;
4037
4041
 
4038
4042
        Container[] children = findChildren();
4283
4287
                }
4284
4288
            }
4285
4289
        }
4286
 
        
 
4290
 
4287
4291
        setApplicationEventListeners(null);
4288
4292
        setApplicationLifecycleListeners(null);
4289
4293
 
4327
4331
            }
4328
4332
            // Register the cache in JMX
4329
4333
            if (isCachingAllowed()) {
4330
 
                ObjectName resourcesName = 
4331
 
                    new ObjectName(this.getDomain() + ":type=Cache,host=" 
4332
 
                                   + getHostname() + ",path=" 
 
4334
                ObjectName resourcesName =
 
4335
                    new ObjectName(this.getDomain() + ":type=Cache,host="
 
4336
                                   + getHostname() + ",path="
4333
4337
                                   + (("".equals(getPath()))?"/":getPath()));
4334
4338
                Registry.getRegistry(null, null).registerComponent
4335
4339
                    (proxyDirContext.getCache(), resourcesName, null);
4362
4366
                }
4363
4367
                // Unregister the cache in JMX
4364
4368
                if (isCachingAllowed()) {
4365
 
                    ObjectName resourcesName = 
 
4369
                    ObjectName resourcesName =
4366
4370
                        new ObjectName(this.getDomain()
4367
 
                                       + ":type=Cache,host=" 
4368
 
                                       + getHostname() + ",path=" 
 
4371
                                       + ":type=Cache,host="
 
4372
                                       + getHostname() + ",path="
4369
4373
                                       + (("".equals(getPath()))?"/"
4370
4374
                                          :getPath()));
4371
4375
                    Registry.getRegistry(null, null)
4444
4448
                log.info(sm.getString("containerBase.alreadyStarted", logName()));
4445
4449
            return;
4446
4450
        }
4447
 
        if( !initialized ) { 
 
4451
        if( !initialized ) {
4448
4452
            try {
4449
4453
                init();
4450
4454
            } catch( Exception ex ) {
4457
4461
        // Set JMX object name for proper pipeline registration
4458
4462
        preRegisterJMX();
4459
4463
 
4460
 
        if ((oname != null) && 
 
4464
        if ((oname != null) &&
4461
4465
            (Registry.getRegistry(null, null).getMBeanServer().isRegistered(oname))) {
4462
4466
            // As things depend on the JMX registration, the context
4463
4467
            // must be reregistered again once properly initialized
4492
4496
            }
4493
4497
        }
4494
4498
 
4495
 
        // Look for a realm - that may have been configured earlier. 
 
4499
        // Look for a realm - that may have been configured earlier.
4496
4500
        // If the realm is added after context - it'll set itself.
4497
 
        // TODO: what is the use case for this ? 
 
4501
        // TODO: what is the use case for this ?
4498
4502
        if( realm == null && mserver != null ) {
4499
4503
            ObjectName realmName=null;
4500
4504
            try {
4501
 
                realmName=new ObjectName( getEngineName() + ":type=Realm,host=" + 
 
4505
                realmName=new ObjectName( getEngineName() + ":type=Realm,host=" +
4502
4506
                        getHostname() + ",path=" + getPath());
4503
4507
                if( mserver.isRegistered(realmName ) ) {
4504
 
                    mserver.invoke(realmName, "init", 
 
4508
                    mserver.invoke(realmName, "init",
4505
4509
                            new Object[] {},
4506
4510
                            new String[] {}
4507
 
                    );            
 
4511
                    );
4508
4512
                }
4509
4513
            } catch( Throwable t ) {
4510
4514
                if(log.isDebugEnabled())
4511
4515
                    log.debug("No realm for this host " + realmName);
4512
4516
            }
4513
4517
        }
4514
 
        
 
4518
 
4515
4519
        if (getLoader() == null) {
4516
4520
            WebappLoader webappLoader = new WebappLoader(getParentClassLoader());
4517
4521
            webappLoader.setDelegate(getDelegate());
4553
4557
                addLifecycleListener(namingContextListener);
4554
4558
            }
4555
4559
        }
4556
 
        
 
4560
 
4557
4561
        // Standard container startup
4558
4562
        if (log.isDebugEnabled())
4559
4563
            log.debug("Processing standard container startup");
4560
4564
 
4561
 
        
 
4565
 
4562
4566
        // Binding thread
4563
4567
        ClassLoader oldCCL = bindThread();
4564
4568
 
4567
4571
        try {
4568
4572
 
4569
4573
            if (ok) {
4570
 
                
 
4574
 
4571
4575
                started = true;
4572
4576
 
4573
4577
                // Start our subordinate components, if any
4581
4585
                unbindThread(oldCCL);
4582
4586
                oldCCL = bindThread();
4583
4587
 
4584
 
                // Initialize logger again. Other components might have used it too early, 
 
4588
                // Initialize logger again. Other components might have used it too early,
4585
4589
                // so it should be reset.
4586
4590
                logger = null;
4587
4591
                getLogger();
4588
4592
                if ((logger != null) && (logger instanceof Lifecycle))
4589
4593
                    ((Lifecycle) logger).start();
4590
 
                
 
4594
 
4591
4595
                if ((cluster != null) && (cluster instanceof Lifecycle))
4592
4596
                    ((Lifecycle) cluster).start();
4593
4597
                if ((realm != null) && (realm instanceof Lifecycle))
4607
4611
                if (pipeline instanceof Lifecycle) {
4608
4612
                    ((Lifecycle) pipeline).start();
4609
4613
                }
4610
 
                
 
4614
 
4611
4615
                // Notify our interested LifecycleListeners
4612
4616
                lifecycle.fireLifecycleEvent(START_EVENT, null);
4613
 
                
 
4617
 
4614
4618
                // Acquire clustered manager
4615
4619
                Manager contextManager = null;
4616
4620
                if (manager == null) {
4624
4628
                    } else {
4625
4629
                        contextManager = new StandardManager();
4626
4630
                    }
4627
 
                } 
4628
 
                
 
4631
                }
 
4632
 
4629
4633
                // Configure default manager if none was specified
4630
4634
                if (contextManager != null) {
4631
4635
                    setManager(contextManager);
4637
4641
                    getCluster().registerManager(manager);
4638
4642
                }
4639
4643
 
4640
 
                
 
4644
 
4641
4645
                mainOk = true;
4642
4646
 
4643
4647
            }
4675
4679
        if (ok && !getIgnoreAnnotations()) {
4676
4680
            if (annotationProcessor == null) {
4677
4681
                if (isUseNaming() && namingContextListener != null) {
4678
 
                    annotationProcessor = 
 
4682
                    annotationProcessor =
4679
4683
                        new DefaultAnnotationProcessor(namingContextListener.getEnvContext());
4680
4684
                } else {
4681
4685
                    annotationProcessor = new DefaultAnnotationProcessor(null);
4686
4690
        }
4687
4691
 
4688
4692
        try {
4689
 
            
 
4693
 
4690
4694
            // Create context attributes that will be required
4691
4695
            if (ok) {
4692
4696
                postWelcomeFiles();
4693
4697
            }
4694
 
            
 
4698
 
4695
4699
            // Set up the context init params
4696
4700
            mergeParameters();
4697
4701
 
4699
4703
                // Notify our interested LifecycleListeners
4700
4704
                lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
4701
4705
            }
4702
 
            
 
4706
 
4703
4707
            // Configure and call application event listeners
4704
4708
            if (ok) {
4705
4709
                if (!listenerStart()) {
4707
4711
                    ok = false;
4708
4712
                }
4709
4713
            }
4710
 
            
 
4714
 
4711
4715
            try {
4712
4716
                // Start manager
4713
4717
                if ((manager != null) && (manager instanceof Lifecycle)) {
4714
4718
                    ((Lifecycle) getManager()).start();
4715
4719
                }
4716
 
    
 
4720
 
4717
4721
                // Start ContainerBackgroundProcessor thread
4718
4722
                super.threadStart();
4719
4723
            } catch(Exception e) {
4728
4732
                    ok = false;
4729
4733
                }
4730
4734
            }
4731
 
            
 
4735
 
4732
4736
            // Load and initialize all "load on startup" servlets
4733
4737
            if (ok) {
4734
4738
                loadOnStartup(findChildren());
4735
4739
            }
4736
 
            
 
4740
 
4737
4741
        } finally {
4738
4742
            // Unbinding thread
4739
4743
            unbindThread(oldCCL);
4758
4762
        registerJMX();
4759
4763
 
4760
4764
        startTime=System.currentTimeMillis();
4761
 
        
4762
 
        // Send j2ee.state.running notification 
 
4765
 
 
4766
        // Send j2ee.state.running notification
4763
4767
        if (ok && (this.getObjectName() != null)) {
4764
 
            Notification notification = 
4765
 
                new Notification("j2ee.state.running", this.getObjectName(), 
 
4768
            Notification notification =
 
4769
                new Notification("j2ee.state.running", this.getObjectName(),
4766
4770
                                sequenceNumber++);
4767
4771
            broadcaster.sendNotification(notification);
4768
4772
        }
4769
4773
 
4770
 
        // Close all JARs right away to avoid always opening a peak number 
 
4774
        // Close all JARs right away to avoid always opening a peak number
4771
4775
        // of files on startup
4772
4776
        if (getLoader() instanceof WebappLoader) {
4773
4777
            ((WebappLoader) getLoader()).closeJARs(true);
4781
4785
        //cacheContext();
4782
4786
    }
4783
4787
 
4784
 
    
 
4788
 
4785
4789
    private void cacheContext() {
4786
4790
        try {
4787
4791
            File workDir=new File( getWorkPath() );
4788
 
            
 
4792
 
4789
4793
            File ctxSer=new File( workDir, "_tomcat_context.ser");
4790
4794
            FileOutputStream fos=new FileOutputStream( ctxSer );
4791
4795
            ObjectOutputStream oos=new ObjectOutputStream( fos );
4798
4802
        }
4799
4803
    }
4800
4804
 
4801
 
    
 
4805
 
4802
4806
    /**
4803
4807
     * Merge the context initialization parameters specified in the application
4804
4808
     * deployment descriptor with the application parameters described in the
4807
4811
     */
4808
4812
    private void mergeParameters() {
4809
4813
        Map<String,String> mergedParams = new HashMap<String,String>();
4810
 
        
 
4814
 
4811
4815
        String names[] = findParameters();
4812
4816
        for (int i = 0; i < names.length; i++) {
4813
4817
            mergedParams.put(names[i], findParameter(names[i]));
4824
4828
                mergedParams.put(params[i].getName(), params[i].getValue());
4825
4829
            }
4826
4830
        }
4827
 
        
 
4831
 
4828
4832
        for (Map.Entry<String,String> entry : mergedParams.entrySet()) {
4829
4833
            context.setInitParameter(entry.getKey(), entry.getValue());
4830
4834
        }
4831
4835
 
4832
4836
    }
4833
4837
 
4834
 
    
 
4838
 
4835
4839
    /**
4836
4840
     * Stop this Context component.
4837
4841
     *
4848
4852
 
4849
4853
        // Notify our interested LifecycleListeners
4850
4854
        lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
4851
 
        
4852
 
        // Send j2ee.state.stopping notification 
 
4855
 
 
4856
        // Send j2ee.state.stopping notification
4853
4857
        if (this.getObjectName() != null) {
4854
 
            Notification notification = 
4855
 
                new Notification("j2ee.state.stopping", this.getObjectName(), 
 
4858
            Notification notification =
 
4859
                new Notification("j2ee.state.stopping", this.getObjectName(),
4856
4860
                                sequenceNumber++);
4857
4861
            broadcaster.sendNotification(notification);
4858
4862
        }
4859
 
        
 
4863
 
4860
4864
        // Mark this application as unavailable while we shut down
4861
4865
        setAvailable(false);
4862
4866
 
4927
4931
 
4928
4932
        }
4929
4933
 
4930
 
        // Send j2ee.state.stopped notification 
 
4934
        // Send j2ee.state.stopped notification
4931
4935
        if (this.getObjectName() != null) {
4932
 
            Notification notification = 
4933
 
                new Notification("j2ee.state.stopped", this.getObjectName(), 
 
4936
            Notification notification =
 
4937
                new Notification("j2ee.state.stopped", this.getObjectName(),
4934
4938
                                sequenceNumber++);
4935
4939
            broadcaster.sendNotification(notification);
4936
4940
        }
4937
 
        
 
4941
 
4938
4942
        // Reset application context
4939
4943
        context = null;
4940
4944
 
4941
 
        // This object will no longer be visible or used. 
 
4945
        // This object will no longer be visible or used.
4942
4946
        try {
4943
4947
            resetContext();
4944
4948
        } catch( Exception ex ) {
4945
4949
            log.error( "Error reseting context " + this + " " + ex, ex );
4946
4950
        }
4947
 
        
 
4951
 
4948
4952
        // Notify our interested LifecycleListeners
4949
4953
        lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
4950
4954
 
4954
4958
    }
4955
4959
 
4956
4960
    /** Destroy needs to clean up the context completely.
4957
 
     * 
4958
 
     * The problem is that undoing all the config in start() and restoring 
 
4961
     *
 
4962
     * The problem is that undoing all the config in start() and restoring
4959
4963
     * a 'fresh' state is impossible. After stop()/destroy()/init()/start()
4960
4964
     * we should have the same state as if a fresh start was done - i.e
4961
 
     * read modified web.xml, etc. This can only be done by completely 
 
4965
     * read modified web.xml, etc. This can only be done by completely
4962
4966
     * removing the context object and remapping a new one, or by cleaning
4963
4967
     * up everything.
4964
 
     * 
 
4968
     *
4965
4969
     * XXX Should this be done in stop() ?
4966
 
     * 
4967
 
     */ 
 
4970
     *
 
4971
     */
4968
4972
    public void destroy() throws Exception {
4969
 
        if( oname != null ) { 
4970
 
            // Send j2ee.object.deleted notification 
4971
 
            Notification notification = 
4972
 
                new Notification("j2ee.object.deleted", this.getObjectName(), 
 
4973
        if( oname != null ) {
 
4974
            // Send j2ee.object.deleted notification
 
4975
            Notification notification =
 
4976
                new Notification("j2ee.object.deleted", this.getObjectName(),
4973
4977
                                sequenceNumber++);
4974
4978
            broadcaster.sendNotification(notification);
4975
 
        } 
 
4979
        }
4976
4980
        super.destroy();
4977
4981
 
4978
4982
        // Notify our interested LifecycleListeners
4983
4987
        }
4984
4988
 
4985
4989
    }
4986
 
    
 
4990
 
4987
4991
    private void resetContext() throws Exception, MBeanRegistrationException {
4988
4992
        // Restore the original state ( pre reading web.xml in start )
4989
4993
        // If you extend this - override this method and make sure to clean up
4999
5003
        applicationEventListenersObjects = new Object[0];
5000
5004
        applicationLifecycleListenersObjects = new Object[0];
5001
5005
        taglibs = new HashMap<String, String>();
5002
 
        
 
5006
 
5003
5007
        annotationProcessor = null;
5004
5008
 
5005
5009
        if(log.isDebugEnabled())
5055
5059
     * Are we processing a version 2.2 deployment descriptor?
5056
5060
     */
5057
5061
    protected boolean isServlet22() {
5058
 
 
5059
 
        if (this.publicId == null)
5060
 
            return (false);
5061
 
        if (this.publicId.equals
5062
 
            (org.apache.catalina.startup.Constants.WebDtdPublicId_22))
5063
 
            return (true);
5064
 
        else
5065
 
            return (false);
5066
 
 
 
5062
        return XmlIdentifiers.WEB_22_PUBLIC.equals(publicId);
5067
5063
    }
5068
5064
 
5069
5065
 
5187
5183
     * Get config base.
5188
5184
     */
5189
5185
    public File getConfigBase() {
5190
 
        File configBase = 
 
5186
        File configBase =
5191
5187
            new File(System.getProperty("catalina.base"), "conf");
5192
5188
        if (!configBase.exists()) {
5193
5189
            return null;
5295
5291
    return namingContextName;
5296
5292
    }
5297
5293
 
5298
 
    
 
5294
 
5299
5295
    /**
5300
5296
     * Naming context listener accessor.
5301
5297
     */
5302
5298
    public NamingContextListener getNamingContextListener() {
5303
5299
        return namingContextListener;
5304
5300
    }
5305
 
    
 
5301
 
5306
5302
 
5307
5303
    /**
5308
5304
     * Naming context listener setter.
5310
5306
    public void setNamingContextListener(NamingContextListener namingContextListener) {
5311
5307
        this.namingContextListener = namingContextListener;
5312
5308
    }
5313
 
    
 
5309
 
5314
5310
 
5315
5311
    /**
5316
5312
     * Return the request processing paused flag for this Context.
5486
5482
    /**
5487
5483
     * JSR77 deploymentDescriptor attribute
5488
5484
     *
5489
 
     * @return string deployment descriptor 
 
5485
     * @return string deployment descriptor
5490
5486
     */
5491
5487
    public String getDeploymentDescriptor() {
5492
 
    
 
5488
 
5493
5489
        InputStream stream = null;
5494
5490
        ServletContext servletContext = getServletContext();
5495
5491
        if (servletContext != null) {
5512
5508
            return "";
5513
5509
        }
5514
5510
 
5515
 
        return sb.toString(); 
5516
 
    
 
5511
        return sb.toString();
 
5512
 
5517
5513
    }
5518
 
    
5519
 
    
 
5514
 
 
5515
 
5520
5516
    /**
5521
5517
     * JSR77 servlets attribute
5522
5518
     *
5523
5519
     * @return list of all servlets ( we know about )
5524
5520
     */
5525
5521
    public String[] getServlets() {
5526
 
        
 
5522
 
5527
5523
        String[] result = null;
5528
5524
 
5529
5525
        Container[] children = findChildren();
5536
5532
 
5537
5533
        return result;
5538
5534
    }
5539
 
    
 
5535
 
5540
5536
 
5541
5537
    public ObjectName createObjectName(String hostDomain, ObjectName parentName)
5542
5538
            throws MalformedObjectNameException
5543
5539
    {
5544
5540
        String onameStr;
5545
5541
        StandardHost hst=(StandardHost)getParent();
5546
 
        
 
5542
 
5547
5543
        String pathName=getName();
5548
5544
        String hostName=getParent().getName();
5549
5545
        String name= "//" + ((hostName==null)? "DEFAULT" : hostName) +
5556
5552
        onameStr="j2eeType=WebModule,name=" + name + suffix;
5557
5553
        if( log.isDebugEnabled())
5558
5554
            log.debug("Registering " + onameStr + " for " + oname);
5559
 
        
 
5555
 
5560
5556
        // default case - no domain explictely set.
5561
5557
        if( getDomain() == null ) domain=hst.getDomain();
5562
5558
 
5563
5559
        ObjectName oname=new ObjectName(getDomain() + ":" + onameStr);
5564
 
        return oname;        
5565
 
    }    
5566
 
    
 
5560
        return oname;
 
5561
    }
 
5562
 
5567
5563
    private void preRegisterJMX() {
5568
5564
        try {
5569
5565
            StandardHost host = (StandardHost) getParent();
5570
 
            if ((oname == null) 
 
5566
            if ((oname == null)
5571
5567
                || (oname.getKeyProperty("j2eeType") == null)) {
5572
5568
                oname = createObjectName(host.getDomain(), host.getJmxName());
5573
5569
                controller = oname;
5589
5585
                controller = oname;
5590
5586
                Registry.getRegistry(null, null)
5591
5587
                    .registerComponent(this, oname, null);
5592
 
                
5593
 
                // Send j2ee.object.created notification 
 
5588
 
 
5589
                // Send j2ee.object.created notification
5594
5590
                if (this.getObjectName() != null) {
5595
5591
                    Notification notification = new Notification(
5596
 
                                                        "j2ee.object.created", 
5597
 
                                                        this.getObjectName(), 
 
5592
                                                        "j2ee.object.created",
 
5593
                                                        this.getObjectName(),
5598
5594
                                                        sequenceNumber++);
5599
5595
                    broadcaster.sendNotification(notification);
5600
5596
                }
5646
5642
 
5647
5643
        if( this.getParent() == null ) {
5648
5644
            ObjectName parentName=getParentName();
5649
 
            
 
5645
 
5650
5646
            if( ! mserver.isRegistered(parentName)) {
5651
5647
                if(log.isDebugEnabled())
5652
5648
                    log.debug("No host, creating one " + parentName);
5660
5656
                // or same thing easier:
5661
5657
                host.init();
5662
5658
            }
5663
 
            
 
5659
 
5664
5660
            // Add the main configuration listener
5665
5661
            LifecycleListener config = null;
5666
5662
            try {
5702
5698
        }
5703
5699
 
5704
5700
        super.init();
5705
 
        
 
5701
 
5706
5702
        // Notify our interested LifecycleListeners
5707
5703
        lifecycle.fireLifecycleEvent(INIT_EVENT, null);
5708
5704
 
5709
 
        // Send j2ee.state.starting notification 
 
5705
        // Send j2ee.state.starting notification
5710
5706
        if (this.getObjectName() != null) {
5711
 
            Notification notification = new Notification("j2ee.state.starting", 
5712
 
                                                        this.getObjectName(), 
 
5707
            Notification notification = new Notification("j2ee.state.starting",
 
5708
                                                        this.getObjectName(),
5713
5709
                                                        sequenceNumber++);
5714
5710
            broadcaster.sendNotification(notification);
5715
5711
        }
5716
 
        
 
5712
 
5717
5713
    }
5718
5714
 
5719
5715
    public ObjectName getParentName() throws MalformedObjectNameException {
5749
5745
                "type=Host,host=" + hostName);
5750
5746
        return parentName;
5751
5747
    }
5752
 
    
 
5748
 
5753
5749
    public void create() throws Exception{
5754
5750
        init();
5755
5751
    }
5756
5752
 
5757
 
    /* Remove a JMX notficationListener 
 
5753
    /* Remove a JMX notficationListener
5758
5754
     * @see javax.management.NotificationEmitter#removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
5759
5755
     */
5760
 
    public void removeNotificationListener(NotificationListener listener, 
 
5756
    public void removeNotificationListener(NotificationListener listener,
5761
5757
            NotificationFilter filter, Object object) throws ListenerNotFoundException {
5762
5758
        broadcaster.removeNotificationListener(listener,filter,object);
5763
 
        
 
5759
 
5764
5760
    }
5765
 
    
 
5761
 
5766
5762
    private MBeanNotificationInfo[] notificationInfo;
5767
 
    
 
5763
 
5768
5764
    /* Get JMX Broadcaster Info
5769
5765
     * @TODO use StringManager for international support!
5770
5766
     * @TODO This two events we not send j2ee.state.failed and j2ee.attribute.changed!
5778
5774
                                "j2ee.object.created"},
5779
5775
                                        Notification.class.getName(),
5780
5776
                                        "web application is created"
5781
 
                                ), 
 
5777
                                ),
5782
5778
                                        new MBeanNotificationInfo(new String[] {
5783
5779
                                        "j2ee.state.starting"},
5784
5780
                                        Notification.class.getName(),
5805
5801
                                        "web application is deleted"
5806
5802
                                        )
5807
5803
                };
5808
 
                
 
5804
 
5809
5805
        }
5810
 
        
 
5806
 
5811
5807
        return notificationInfo;
5812
5808
    }
5813
 
    
5814
 
    
 
5809
 
 
5810
 
5815
5811
    /* Add a JMX-NotificationListener
5816
5812
     * @see javax.management.NotificationBroadcaster#addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
5817
5813
     */
5818
 
    public void addNotificationListener(NotificationListener listener, 
 
5814
    public void addNotificationListener(NotificationListener listener,
5819
5815
            NotificationFilter filter, Object object) throws IllegalArgumentException {
5820
5816
        broadcaster.addNotificationListener(listener,filter,object);
5821
 
        
 
5817
 
5822
5818
    }
5823
 
    
5824
 
    
 
5819
 
 
5820
 
5825
5821
    /**
5826
 
     * Remove a JMX-NotificationListener 
 
5822
     * Remove a JMX-NotificationListener
5827
5823
     * @see javax.management.NotificationBroadcaster#removeNotificationListener(javax.management.NotificationListener)
5828
5824
     */
5829
 
    public void removeNotificationListener(NotificationListener listener) 
 
5825
    public void removeNotificationListener(NotificationListener listener)
5830
5826
    throws ListenerNotFoundException {
5831
5827
        broadcaster.removeNotificationListener(listener);
5832
 
        
 
5828
 
5833
5829
    }
5834
 
    
5835
 
    
 
5830
 
 
5831
 
5836
5832
    // ------------------------------------------------------------- Attributes
5837
5833
 
5838
5834
 
5848
5844
 
5849
5845
    /**
5850
5846
     * Return the naming resources associated with this web application.
5851
 
     * FIXME: Fooling introspection ... 
 
5847
     * FIXME: Fooling introspection ...
5852
5848
     */
5853
5849
    public javax.naming.directory.DirContext findStaticResources() {
5854
5850
 
5866
5862
 
5867
5863
    }
5868
5864
 
5869
 
     /**
5870
 
     * Set the validation feature of the XML parser used when
5871
 
     * parsing xml instances.
5872
 
     * @param webXmlValidation true to enable xml instance validation
5873
 
     */
 
5865
 
 
5866
    public boolean getXmlNamespaceAware(){
 
5867
        return webXmlNamespaceAware;
 
5868
    }
 
5869
 
 
5870
 
 
5871
    public void setXmlNamespaceAware(boolean webXmlNamespaceAware){
 
5872
        this.webXmlNamespaceAware= webXmlNamespaceAware;
 
5873
    }
 
5874
 
 
5875
 
5874
5876
    public void setXmlValidation(boolean webXmlValidation){
5875
 
        
5876
5877
        this.webXmlValidation = webXmlValidation;
5877
 
 
5878
5878
    }
5879
5879
 
5880
 
    /**
5881
 
     * Get the server.xml <context> attribute's xmlValidation.
5882
 
     * @return true if validation is enabled.
5883
 
     *
5884
 
     */
 
5880
 
5885
5881
    public boolean getXmlValidation(){
5886
5882
        return webXmlValidation;
5887
5883
    }
5888
5884
 
5889
5885
 
5890
 
    /**
5891
 
     * Get the server.xml <context> attribute's xmlNamespaceAware.
5892
 
     * @return true if namespace awarenes is enabled.
5893
 
     */
5894
 
    public boolean getXmlNamespaceAware(){
5895
 
        return webXmlNamespaceAware;
5896
 
    }
5897
 
 
5898
 
 
5899
 
    /**
5900
 
     * Set the namespace aware feature of the XML parser used when
5901
 
     * parsing xml instances.
5902
 
     * @param webXmlNamespaceAware true to enable namespace awareness
5903
 
     */
5904
 
    public void setXmlNamespaceAware(boolean webXmlNamespaceAware){
5905
 
        this.webXmlNamespaceAware= webXmlNamespaceAware;
5906
 
    }    
5907
 
 
5908
 
 
5909
 
    /**
5910
 
     * Set the validation feature of the XML parser used when
5911
 
     * parsing tlds files. 
5912
 
     * @param tldValidation true to enable xml instance validation
5913
 
     */
 
5886
    public boolean getTldNamespaceAware(){
 
5887
        return true;
 
5888
    }
 
5889
 
 
5890
 
 
5891
    public void setTldNamespaceAware(boolean tldNamespaceAware){
 
5892
        // NO-OP;
 
5893
    }
 
5894
 
 
5895
 
 
5896
    public void setXmlBlockExternal(boolean xmlBlockExternal) {
 
5897
        this.xmlBlockExternal = xmlBlockExternal;
 
5898
    }
 
5899
 
 
5900
 
 
5901
    public boolean getXmlBlockExternal() {
 
5902
        return xmlBlockExternal;
 
5903
    }
 
5904
 
 
5905
 
5914
5906
    public void setTldValidation(boolean tldValidation){
5915
 
        
5916
5907
        this.tldValidation = tldValidation;
5917
 
 
5918
5908
    }
5919
5909
 
5920
 
    /**
5921
 
     * Get the server.xml <context> attribute's webXmlValidation.
5922
 
     * @return true if validation is enabled.
5923
 
     *
5924
 
     */
 
5910
 
5925
5911
    public boolean getTldValidation(){
5926
5912
        return tldValidation;
5927
5913
    }
5928
5914
 
 
5915
 
5929
5916
    /**
5930
5917
     * Sets the process TLDs attribute.
5931
5918
     *
5942
5929
        return processTlds;
5943
5930
    }
5944
5931
 
5945
 
    /**
5946
 
     * Get the server.xml &lt;host&gt; attribute's xmlNamespaceAware.
5947
 
     * @return true if namespace awarenes is enabled.
5948
 
     */
5949
 
    public boolean getTldNamespaceAware(){
5950
 
        return tldNamespaceAware;
5951
 
    }
5952
 
 
5953
 
 
5954
 
    /**
5955
 
     * Set the namespace aware feature of the XML parser used when
5956
 
     * parsing xml instances.
5957
 
     * @param tldNamespaceAware true to enable namespace awareness
5958
 
     */
5959
 
    public void setTldNamespaceAware(boolean tldNamespaceAware){
5960
 
        this.tldNamespaceAware= tldNamespaceAware;
5961
 
    }    
5962
 
 
5963
 
 
5964
 
    /** 
5965
 
     * Support for "stateManageable" JSR77 
 
5932
 
 
5933
    /**
 
5934
     * Support for "stateManageable" JSR77
5966
5935
     */
5967
5936
    public boolean isStateManageable() {
5968
5937
        return true;
5969
5938
    }
5970
 
    
 
5939
 
5971
5940
    public void startRecursive() throws LifecycleException {
5972
5941
        // nothing to start recursive, the servlets will be started by load-on-startup
5973
5942
        start();
5974
5943
    }
5975
 
    
 
5944
 
5976
5945
    public int getState() {
5977
5946
        if( started ) {
5978
5947
            return 1; // RUNNING
5979
5948
        }
5980
5949
        if( initialized ) {
5981
 
            return 0; // starting ? 
 
5950
            return 0; // starting ?
5982
5951
        }
5983
 
        if( ! available ) { 
 
5952
        if( ! available ) {
5984
5953
            return 4; //FAILED
5985
5954
        }
5986
5955
        // 2 - STOPPING
5987
5956
        return 3; // STOPPED
5988
5957
    }
5989
 
    
 
5958
 
5990
5959
    public String getStateName() {
5991
5960
        return lifecycle.getState();
5992
5961
    }
5993
5962
 
5994
5963
    /**
5995
5964
     * The J2EE Server ObjectName this module is deployed on.
5996
 
     */     
 
5965
     */
5997
5966
    private String server = null;
5998
 
    
 
5967
 
5999
5968
    /**
6000
5969
     * The Java virtual machines on which this module is running.
6001
 
     */       
 
5970
     */
6002
5971
    private String[] javaVMs = null;
6003
 
    
 
5972
 
6004
5973
    public String getServer() {
6005
5974
        return server;
6006
5975
    }
6007
 
        
 
5976
 
6008
5977
    public String setServer(String server) {
6009
5978
        return this.server=server;
6010
5979
    }
6011
 
        
 
5980
 
6012
5981
    public String[] getJavaVMs() {
6013
5982
        return javaVMs;
6014
5983
    }
6015
 
        
 
5984
 
6016
5985
    public String[] setJavaVMs(String[] javaVMs) {
6017
5986
        return this.javaVMs = javaVMs;
6018
5987
    }
6019
 
    
 
5988
 
6020
5989
    /**
6021
5990
     * Gets the time this context was started.
6022
5991
     *
6023
5992
     * @return Time (in milliseconds since January 1, 1970, 00:00:00) when this
6024
 
     * context was started 
 
5993
     * context was started
6025
5994
     */
6026
5995
    public long getStartTime() {
6027
5996
        return startTime;
6028
5997
    }
6029
 
    
 
5998
 
6030
5999
    public boolean isEventProvider() {
6031
6000
        return false;
6032
6001
    }
6033
 
    
 
6002
 
6034
6003
    public boolean isStatisticsProvider() {
6035
6004
        return false;
6036
6005
    }
6037
 
    
 
6006
 
6038
6007
}