-
Notifications
You must be signed in to change notification settings - Fork 143
/
StandardContext.java
7265 lines (6284 loc) · 238 KB
/
StandardContext.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2021-2022 Contributors to Eclipse Foundation.
* Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.core;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.FilterRegistration;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletContainerInitializer;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletContextAttributeListener;
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRegistration;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletRequestAttributeListener;
import jakarta.servlet.ServletRequestEvent;
import jakarta.servlet.ServletRequestListener;
import jakarta.servlet.SessionCookieConfig;
import jakarta.servlet.SessionTrackingMode;
import jakarta.servlet.descriptor.JspConfigDescriptor;
import jakarta.servlet.http.HttpServletMapping;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSessionAttributeListener;
import jakarta.servlet.http.HttpSessionIdListener;
import jakarta.servlet.http.HttpSessionListener;
import jakarta.servlet.http.HttpUpgradeHandler;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Enumeration;
import java.util.EventListener;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.ServiceConfigurationError;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import javax.management.MBeanRegistrationException;
import javax.management.MalformedObjectNameException;
import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
import javax.management.ObjectName;
import javax.naming.Binding;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import org.apache.catalina.Auditor;
import org.apache.catalina.Authenticator;
import org.apache.catalina.Container;
import org.apache.catalina.ContainerListener;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.InstanceListener;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Loader;
import org.apache.catalina.LogFacade;
import org.apache.catalina.Pipeline;
import org.apache.catalina.Server;
import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.MappingImpl;
import org.apache.catalina.deploy.ApplicationParameter;
import org.apache.catalina.deploy.ContextEjb;
import org.apache.catalina.deploy.ContextEnvironment;
import org.apache.catalina.deploy.ContextLocalEjb;
import org.apache.catalina.deploy.ContextResource;
import org.apache.catalina.deploy.ContextResourceLink;
import org.apache.catalina.deploy.ErrorPage;
import org.apache.catalina.deploy.FilterDef;
import org.apache.catalina.deploy.FilterMap;
import org.apache.catalina.deploy.FilterMaps;
import org.apache.catalina.deploy.LoginConfig;
import org.apache.catalina.deploy.MessageDestination;
import org.apache.catalina.deploy.MessageDestinationRef;
import org.apache.catalina.deploy.NamingResources;
import org.apache.catalina.deploy.ResourceParams;
import org.apache.catalina.deploy.SecurityCollection;
import org.apache.catalina.deploy.SecurityConstraint;
import org.apache.catalina.deploy.ServletMap;
import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.servlets.DefaultServlet;
import org.apache.catalina.session.ManagerBase;
import org.apache.catalina.session.PersistentManagerBase;
import org.apache.catalina.session.StandardManager;
import org.apache.catalina.startup.ContextConfig;
import org.apache.catalina.util.CharsetMapper;
import org.apache.catalina.util.CustomObjectInputStream;
import org.apache.catalina.util.ExtensionValidator;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.URLEncoder;
import org.apache.naming.ContextBindings;
import org.apache.naming.resources.BaseDirContext;
import org.apache.naming.resources.DirContextURLStreamHandler;
import org.apache.naming.resources.FileDirContext;
import org.apache.naming.resources.ProxyDirContext;
import org.apache.naming.resources.Resource;
import org.apache.naming.resources.WARDirContext;
import org.apache.naming.resources.WebDirContext;
import org.glassfish.grizzly.http.server.util.AlternateDocBase;
import org.glassfish.grizzly.http.server.util.Mapper;
import org.glassfish.grizzly.http.server.util.MappingData;
import org.glassfish.grizzly.http.util.CharChunk;
import org.glassfish.grizzly.http.util.MessageBytes;
import org.glassfish.hk2.classmodel.reflect.Types;
import org.glassfish.web.loader.ServletContainerInitializerUtil;
import org.glassfish.web.loader.WebappClassLoader;
import org.glassfish.web.valve.GlassFishValve;
import static com.sun.enterprise.util.Utility.isAllNull;
import static com.sun.enterprise.util.Utility.isEmpty;
import static com.sun.logging.LogCleanerUtil.neutralizeForLog;
import static jakarta.servlet.RequestDispatcher.ERROR_EXCEPTION;
import static java.text.MessageFormat.format;
import static java.util.Collections.synchronizedList;
import static java.util.Collections.unmodifiableMap;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.FINEST;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.SEVERE;
import static java.util.logging.Level.WARNING;
import static org.apache.catalina.ContainerEvent.AFTER_CONTEXT_DESTROYED;
import static org.apache.catalina.ContainerEvent.AFTER_CONTEXT_INITIALIZED;
import static org.apache.catalina.ContainerEvent.AFTER_CONTEXT_INITIALIZER_ON_STARTUP;
import static org.apache.catalina.ContainerEvent.AFTER_REQUEST_DESTROYED;
import static org.apache.catalina.ContainerEvent.AFTER_REQUEST_INITIALIZED;
import static org.apache.catalina.ContainerEvent.BEFORE_CONTEXT_DESTROYED;
import static org.apache.catalina.ContainerEvent.BEFORE_CONTEXT_INITIALIZED;
import static org.apache.catalina.ContainerEvent.BEFORE_CONTEXT_INITIALIZER_ON_STARTUP;
import static org.apache.catalina.ContainerEvent.BEFORE_REQUEST_DESTROYED;
import static org.apache.catalina.ContainerEvent.BEFORE_REQUEST_INITIALIZED;
import static org.apache.catalina.ContainerEvent.PRE_DESTROY;
import static org.apache.catalina.Globals.ALTERNATE_RESOURCES_ATTR;
import static org.apache.catalina.Globals.ALT_DD_ATTR;
import static org.apache.catalina.Globals.FACES_INITIALIZER;
import static org.apache.catalina.Globals.META_INF_RESOURCES;
import static org.apache.catalina.Globals.RESOURCES_ATTR;
import static org.apache.catalina.LogFacade.*;
import static org.apache.catalina.core.Constants.DEFAULT_SERVLET_NAME;
import static org.apache.catalina.core.Constants.JSP_SERVLET_NAME;
import static org.apache.catalina.startup.Constants.WebDtdPublicId_22;
import static org.apache.catalina.util.RequestUtil.urlDecode;
import static org.apache.naming.resources.ProxyDirContext.CONTEXT;
import static org.apache.naming.resources.ProxyDirContext.HOST;
import org.apache.naming.resources.UrlResource;
import static org.glassfish.web.loader.ServletContainerInitializerUtil.getInitializerList;
import static org.glassfish.web.loader.ServletContainerInitializerUtil.getInterestList;
/**
* Standard implementation of the <b>Context</b> interface. Each child container must be a Wrapper implementation to
* process the requests directed to a particular servlet.
*
* @author Craig R. McClanahan
* @author Remy Maucherat
* @version $Revision: 1.48 $ $Date: 2007/07/25 00:52:04 $
*/
public class StandardContext extends ContainerBase implements Context, ServletContext {
private static final String DEFAULT_RESPONSE_CHARACTER_ENCODING = StandardCharsets.ISO_8859_1.name();
private static final ClassLoader standardContextClassLoader = StandardContext.class.getClassLoader();
private static final Set<SessionTrackingMode> DEFAULT_SESSION_TRACKING_MODES = EnumSet.of(SessionTrackingMode.COOKIE);
/**
* Array containing the safe characters set.
*/
protected static final URLEncoder urlEncoder;
/**
* The descriptive information string for this implementation.
*/
private static final String info = "org.apache.catalina.core.StandardContext/1.0";
private static final RuntimePermission GET_CLASSLOADER_PERMISSION = new RuntimePermission("getClassLoader");
/**
* GMT timezone - all HTTP dates are on GMT
*/
static {
urlEncoder = new URLEncoder();
urlEncoder.addSafeCharacter('~');
urlEncoder.addSafeCharacter('-');
urlEncoder.addSafeCharacter('_');
urlEncoder.addSafeCharacter('.');
urlEncoder.addSafeCharacter('*');
urlEncoder.addSafeCharacter('/');
}
// ----------------------------------------------------------- Constructors
/**
* Create a new StandardContext component with the default basic Valve.
*/
public StandardContext() {
pipeline.setBasic(new StandardContextValve());
namingResources.setContainer(this);
if (Globals.IS_SECURITY_ENABLED) {
mySecurityManager = AccessController.doPrivileged(new PrivilegedCreateSecurityManager());
}
}
// ----------------------------------------------------- Instance Variables
/**
* The alternate deployment descriptor name.
*/
private String altDDName;
/**
* The antiJARLocking flag for this Context.
*/
private boolean antiJARLocking;
/**
* Associated host name.
*/
private String hostName;
/**
* The list of instantiated application event listeners
*/
private final List<EventListener> eventListeners = new ArrayList<>();
/**
* The list of ServletContextListeners
*/
protected List<ServletContextListener> contextListeners = new ArrayList<>();
/**
* The list of HttpSessionListeners
*/
private final List<HttpSessionListener> sessionListeners = new ArrayList<>();
/**
* The set of application parameters defined for this application.
*/
private final List<ApplicationParameter> applicationParameters = new ArrayList<>();
/**
* The application available flag for this Context.
*/
private boolean available;
/**
* The broadcaster that sends EE notifications.
*/
private NotificationBroadcasterSupport broadcaster;
/**
* The Locale to character set mapper for this application.
*/
private CharsetMapper charsetMapper;
/**
* The Java class name of the CharsetMapper class to be created.
*/
private String charsetMapperClass = CharsetMapper.class.getName();
/**
* The request character encoding.
*/
private String requestCharacterEncoding;
/**
* The response character encoding.
*/
private String responseCharacterEncoding;
/**
* The path to a file to save this Context information.
*/
private String configFile;
/**
* The "correctly configured" flag for this Context.
*/
private boolean configured;
/**
* The security constraints for this web application.
*/
private final List<SecurityConstraint> constraints = new ArrayList<>();
/**
* The ServletContext implementation associated with this Context.
*/
protected ApplicationContext context;
/**
* Is the context initialized.
*/
private boolean isContextInitializedCalled;
/**
* Compiler classpath to use.
*/
private String compilerClasspath;
/**
* Should we attempt to use cookies for session id communication?
*/
private boolean cookies = true;
/**
* true if the rewriting of URLs with the jsessionids of HTTP sessions belonging to this context is enabled, false
* otherwise
*/
private boolean enableURLRewriting = true;
/**
* Should we allow the <code>ServletContext.getContext()</code> method to access the context of other web applications
* in this server?
*/
private boolean crossContext;
/**
* The "follow standard delegation model" flag that will be used to configure our ClassLoader.
*/
private boolean delegate;
/**
* The display name of this web application.
*/
private String displayName;
/**
* Override the default web xml location. ContextConfig is not configurable so the setter is not used.
*/
private String defaultWebXml;
/**
* The distributable flag for this web application.
*/
private boolean distributable;
/**
* Thread local data used during request dispatch.
*/
private final ThreadLocal<DispatchData> dispatchData = new ThreadLocal<>();
/**
* The document root for this web application.
*/
private String docBase;
/**
* The exception pages for this web application, keyed by fully qualified class name of the Java exception.
*/
private final Map<String, ErrorPage> exceptionPages = new HashMap<>();
/**
* The default error page (error page that was declared without any exception-type and error-code).
*/
private ErrorPage defaultErrorPage;
/**
* The set of filter configurations (and associated filter instances) we have initialized, keyed by filter name.
*/
private final Map<String, FilterConfig> filterConfigs = new HashMap<>();
/**
* The set of filter definitions for this application, keyed by filter name.
*/
private final Map<String, FilterDef> filterDefs = new HashMap<>();
/**
* The list of filter mappings for this application, in the order they were defined in the deployment descriptor.
*/
private final List<FilterMap> filterMaps = new ArrayList<>();
/**
* The list of classnames of InstanceListeners that will be added to each newly created Wrapper by
* <code>createWrapper()</code>.
*/
private final ArrayList<String> instanceListeners = new ArrayList<>();
/**
* The set of already instantiated InstanceListeners that will be added to each newly created Wrapper by
* <code>createWrapper()</code>.
*/
private final List<InstanceListener> instanceListenerInstances = new ArrayList<>();
/**
* The login configuration descriptor for this web application.
*/
private LoginConfig loginConfig;
/**
* The mapper associated with this context.
*/
private final Mapper mapper = new Mapper();
/**
* The naming context listener for this web application.
*/
private NamingContextListener namingContextListener;
/**
* The naming resources for this web application.
*/
private NamingResources namingResources = new NamingResources();
/**
* The message destinations for this web application.
*/
private final Map<String, MessageDestination> messageDestinations = new HashMap<>();
/**
* The MIME mappings for this web application, keyed by extension.
*/
private final Map<String, String> mimeMappings = new HashMap<>();
/**
* The context initialization parameters for this web application, keyed by name.
*/
private final HashMap<String, String> parameters = new HashMap<>();
/**
* The request processing pause flag (while reloading occurs)
*/
private boolean paused;
/**
* The public identifier of the DTD for the web application deployment descriptor version we are currently parsing. This
* is used to support relaxed validation rules when processing version 2.2 web.xml files.
*/
private String publicId;
/**
* The reloadable flag for this web application.
*/
private boolean reloadable;
/**
* Unpack WAR property.
*/
private boolean unpackWAR = true;
/**
* The DefaultContext override flag for this web application.
*/
private boolean override;
/**
* The original document root for this web application.
*/
private String originalDocBase;
/**
* The privileged flag for this web application.
*/
private boolean privileged;
/**
* Should the next call to <code>addWelcomeFile()</code> cause replacement of any existing welcome files? This will be
* set before processing the web application's deployment descriptor, so that application specified choices
* <strong>replace</strong>, rather than append to, those defined in the global descriptor.
*/
private boolean replaceWelcomeFiles;
/**
* With proxy caching disabled, setting this flag to true adds Pragma and Cache-Control headers with "No-cache" as
* value. Setting this flag to false does not add any Pragma header, but sets the Cache-Control header to "private".
*/
private boolean securePagesWithPragma = true;
/**
* The security role mappings for this application, keyed by role name (as used within the application).
*/
private final Map<String, String> roleMappings = new HashMap<>();
/**
* The security roles for this application
*/
private final List<String> securityRoles = new ArrayList<>();
/**
* The servlet mappings for this web application, keyed by matching pattern.
*/
private final Map<String, String> servletMappings = new HashMap<>();
/**
* The session timeout (in minutes) for this web application.
*/
private int sessionTimeout = 30;
/**
* Has the session timeout (in minutes) for this web application been over-ridden by web-xml HERCULES:add
*/
private boolean sessionTimeoutOveridden;
/**
* The notification sequence number.
*/
private long sequenceNumber = 0;
/**
* The status code error pages for this web application, keyed by HTTP status code (as an Integer).
*/
private final Map<Integer, ErrorPage> statusPages = new HashMap<>();
/**
* Amount of ms that the container will wait for servlets to unload.
*/
private long unloadDelay = 2000;
/**
* The watched resources for this application.
*/
private final List<String> watchedResources = synchronizedList(new ArrayList<String>());
/**
* The welcome files for this application.
*/
private String[] welcomeFiles = new String[0];
/**
* The list of classnames of LifecycleListeners that will be added to each newly created Wrapper by
* <code>createWrapper()</code>.
*/
private final List<String> wrapperLifecycles = new ArrayList<>();
/**
* The list of classnames of ContainerListeners that will be added to each newly created Wrapper by
* <code>createWrapper()</code>.
*/
private final List<String> wrapperListeners = new ArrayList<>();
/**
* The pathname to the work directory for this context (relative to the server's home if not absolute).
*/
private String workDir;
/**
* JNDI use flag.
*/
private boolean useNaming = true;
/**
* Filesystem based flag.
*/
private boolean filesystemBased;
/**
* Name of the associated naming context.
*/
private String namingContextName;
/**
* Frequency of the session expiration, and related manager operations. Manager operations will be done once for the
* specified amount of backgrondProcess calls (ie, the lower the amount, the most often the checks will occur).
*/
private int managerChecksFrequency = 6;
/**
* Iteration count for background processing.
*/
private int count = 0;
/**
* Caching allowed flag.
*/
private boolean cachingAllowed = true;
/**
* Case sensitivity.
*/
protected boolean caseSensitive = true;
/**
* Allow linking.
*/
protected boolean allowLinking;
/**
* Cache max size in KB.
*/
protected int cacheMaxSize = 10240; // 10 MB
/**
* Cache TTL in ms.
*/
protected int cacheTTL = 5000;
/**
* Non proxied resources.
*/
private DirContext webappResources;
/*
* Time (in milliseconds) it took to start this context
*/
private long startupTime;
/*
* Time (in milliseconds since January 1, 1970, 00:00:00) when this context was started
*/
private long startTimeMillis;
private long tldScanTime;
// Should the filter and security mapping be done
// in a case sensitive manner
protected boolean caseSensitiveMapping = true;
/**
* The flag that specifies whether to reuse the session id (if any) from the request for newly created sessions
*/
private boolean reuseSessionID;
/**
* The flag that specifies whether this context allows sendRedirect() to redirect to a relative URL.
*/
private boolean allowRelativeRedirect;
/**
* Name of the engine. If null, the domain is used.
*/
private String engineName;
private String eeApplication = "null";
private String eeServer = "none";
/**
* List of configured Auditors for this context.
*/
private Auditor[] auditors;
/**
* used to create unique id for each app instance.
*/
private static AtomicInteger instanceIDCounter = new AtomicInteger(1);
/**
* Attribute value used to turn on/off XML validation
*/
private boolean webXmlValidation;
private String jvmRoute;
/**
* Attribute value used to turn on/off XML namespace validation
*/
private boolean webXmlNamespaceAware;
/**
* Attribute value used to turn on/off XML validation
*/
private boolean tldValidation;
/**
* Attribute value used to turn on/off TLD XML namespace validation
*/
private boolean tldNamespaceAware;
/**
* Is the context contains the JSF servlet.
*/
protected boolean isJsfApplication;
private boolean isReload;
/**
* Alternate doc base resources
*/
private ArrayList<AlternateDocBase> alternateDocBases;
private boolean useMyFaces;
private Set<SessionTrackingMode> sessionTrackingModes;
/**
* Encoded path.
*/
private String encodedPath;
/**
* Session cookie config
*/
private SessionCookieConfig sessionCookieConfig;
/**
* The name of the session tracking cookies created by this context Cache the name here as the getSessionCookieConfig()
* is synchronized.
*/
private String sessionCookieName = Globals.SESSION_COOKIE_NAME;
private boolean sessionCookieNameInitialized;
protected Map<String, ServletRegistrationImpl> servletRegistrationMap = new ConcurrentHashMap<>();
protected Map<String, FilterRegistrationImpl> filterRegistrationMap = new ConcurrentHashMap<>();
/**
* The list of ordered libs, which is used as the value of the ServletContext attribute with name
* jakarta.servlet.context.orderedLibs
*/
private List<String> orderedLibs;
// <jsp-config> related info aggregated from web.xml and web-fragment.xml
private JspConfigDescriptor jspConfigDesc;
// ServletContextListeners may be registered (via ServletContext#addListener) only within the scope of
// ServletContainerInitializer#onStartup
private boolean isProgrammaticServletContextListenerRegistrationAllowed;
/*
* Security manager responsible for enforcing permission check on ServletContext#getClassLoader
*/
private MySecurityManager mySecurityManager;
// Iterable over all ServletContainerInitializers that were discovered
private Iterable<ServletContainerInitializer> servletContainerInitializers;
// The major Servlet spec version of the web.xml
private int effectiveMajorVersion;
// The minor Servlet spec version of the web.xml
private int effectiveMinorVersion;
// Created via embedded API
private boolean isEmbedded;
protected boolean directoryDeployed;
protected boolean showArchivedRealPathEnabled = true;
protected int servletReloadCheckSecs = 1;
// Fine tune log levels for ServletContainerInitializerUtil to avoid spurious or too verbose logging
protected ServletContainerInitializerUtil.LogContext logContext
= new ServletContainerInitializerUtil.LogContext() {
public Level getNonCriticalClassloadingErrorLogLevel() {
return isStandaloneModule() ? Level.WARNING : Level.FINE;
}
};
// ----------------------------------------------------- Context Properties
@Override
public String getEncodedPath() {
return encodedPath;
}
@Override
public void setName(String name) {
super.setName(name);
encodedPath = urlEncoder.encode(name);
}
/**
* Is caching allowed ?
*/
public boolean isCachingAllowed() {
return cachingAllowed;
}
/**
* Set caching allowed flag.
*/
public void setCachingAllowed(boolean cachingAllowed) {
this.cachingAllowed = cachingAllowed;
}
/**
* Set case sensitivity.
*/
public void setCaseSensitive(boolean caseSensitive) {
this.caseSensitive = caseSensitive;
}
/**
* Is case sensitive ?
*/
public boolean isCaseSensitive() {
return caseSensitive;
}
/**
* Set case sensitivity for filter and security constraint mappings.
*/
public void setCaseSensitiveMapping(boolean caseSensitiveMap) {
caseSensitiveMapping = caseSensitiveMap;
}
/**
* Are filters and security constraints mapped in a case sensitive manner?
*/
public boolean isCaseSensitiveMapping() {
return caseSensitiveMapping;
}
/**
* Set allow linking.
*/
public void setAllowLinking(boolean allowLinking) {
this.allowLinking = allowLinking;
}
/**
* Is linking allowed.
*/
public boolean isAllowLinking() {
return allowLinking;
}
/**
* Set cache TTL.
*/
public void setCacheTTL(int cacheTTL) {
this.cacheTTL = cacheTTL;
}
/**
* Get cache TTL.
*/
public int getCacheTTL() {
return cacheTTL;
}
/**
* Return the maximum size of the cache in KB.
*/
public int getCacheMaxSize() {
return cacheMaxSize;
}
/**
* Set the maximum size of the cache in KB.
*/
public void setCacheMaxSize(int cacheMaxSize) {
this.cacheMaxSize = cacheMaxSize;
}
/**
* Return the "follow standard delegation model" flag used to configure our ClassLoader.
*/
public boolean getDelegate() {
return delegate;
}
/**
* Set the "follow standard delegation model" flag used to configure our ClassLoader.
*
* @param delegate The new flag
*/
public void setDelegate(boolean delegate) {
boolean oldDelegate = this.delegate;
this.delegate = delegate;
support.firePropertyChange("delegate", Boolean.valueOf(oldDelegate), Boolean.valueOf(this.delegate));
}
/**
* Returns true if the internal naming support is used.
*/
public boolean isUseNaming() {
synchronized (this) {
return useNaming;
}
}
/**
* Enables or disables naming.
*/
public void setUseNaming(boolean useNaming) {
this.useNaming = useNaming;
}
/**
* @return true if the resources associated with this context are filesystem based, false otherwise
*/
public boolean isFilesystemBased() {
return filesystemBased;
}
/**
* @return the list of initialized application event listeners of this application, in the order in which they have been
* specified in the deployment descriptor
*/
@Override
public List<EventListener> getApplicationEventListeners() {
return eventListeners;
}
public List<HttpSessionListener> getSessionListeners() {
return sessionListeners;
}
/**
* Return the application available flag for this Context.
*/
@Override
public boolean getAvailable() {
return available;
}
/**
* Set the application available flag for this Context.
*
* @param available The new application available flag
*/
@Override
public void setAvailable(boolean available) {
boolean oldAvailable = this.available;
this.available = available;
support.firePropertyChange("available", Boolean.valueOf(oldAvailable), Boolean.valueOf(this.available));
}
/**
* Return the antiJARLocking flag for this Context.
*/
public boolean getAntiJARLocking() {
return antiJARLocking;
}
/**
* Set the antiJARLocking feature for this Context.
*
* @param antiJARLocking The new flag value
*/
public void setAntiJARLocking(boolean antiJARLocking) {
boolean oldAntiJARLocking = this.antiJARLocking;
this.antiJARLocking = antiJARLocking;
support.firePropertyChange("antiJARLocking", oldAntiJARLocking, this.antiJARLocking);
}
/**
* Return the Locale to character set mapper for this Context.
*/
@Override
public CharsetMapper getCharsetMapper() {
// Create a mapper the first time it is requested
if (charsetMapper == null) {
try {
this.charsetMapper = (CharsetMapper)
Class.forName(charsetMapperClass)
.getDeclaredConstructor()
.newInstance();
} catch (Throwable t) {
charsetMapper = new CharsetMapper();
}
}
return charsetMapper;
}
/**
* Set the Locale to character set mapper for this Context.
*
* @param mapper The new mapper
*/
@Override
public void setCharsetMapper(CharsetMapper mapper) {
CharsetMapper oldCharsetMapper = this.charsetMapper;
this.charsetMapper = mapper;
if (mapper != null) {
this.charsetMapperClass = mapper.getClass().getName();