Lines 29-34
Link Here
|
29 |
import java.util.Properties; |
29 |
import java.util.Properties; |
30 |
import java.util.Stack; |
30 |
import java.util.Stack; |
31 |
import java.util.concurrent.atomic.AtomicInteger; |
31 |
import java.util.concurrent.atomic.AtomicInteger; |
|
|
32 |
import java.util.concurrent.locks.ReentrantReadWriteLock; |
32 |
import java.security.AccessController; |
33 |
import java.security.AccessController; |
33 |
import java.security.PrivilegedActionException; |
34 |
import java.security.PrivilegedActionException; |
34 |
import java.security.PrivilegedExceptionAction; |
35 |
import java.security.PrivilegedExceptionAction; |
Lines 292-299
Link Here
|
292 |
* Restricted servlets (which can only be loaded by a privileged webapp). |
293 |
* Restricted servlets (which can only be loaded by a privileged webapp). |
293 |
*/ |
294 |
*/ |
294 |
protected static Properties restrictedServlets = null; |
295 |
protected static Properties restrictedServlets = null; |
295 |
|
296 |
|
296 |
|
297 |
private final ReentrantReadWriteLock parametersLock = |
|
|
298 |
new ReentrantReadWriteLock(); |
299 |
|
300 |
private final ReentrantReadWriteLock mappingsLock = |
301 |
new ReentrantReadWriteLock(); |
302 |
|
303 |
private final ReentrantReadWriteLock referencesLock = |
304 |
new ReentrantReadWriteLock(); |
305 |
|
297 |
// ------------------------------------------------------------- Properties |
306 |
// ------------------------------------------------------------- Properties |
298 |
|
307 |
|
299 |
|
308 |
|
Lines 713-720
Link Here
|
713 |
*/ |
722 |
*/ |
714 |
public void addInitParameter(String name, String value) { |
723 |
public void addInitParameter(String name, String value) { |
715 |
|
724 |
|
716 |
synchronized (parameters) { |
725 |
try { |
|
|
726 |
parametersLock.writeLock().lock(); |
717 |
parameters.put(name, value); |
727 |
parameters.put(name, value); |
|
|
728 |
} finally { |
729 |
parametersLock.writeLock().unlock(); |
718 |
} |
730 |
} |
719 |
fireContainerEvent("addInitParameter", name); |
731 |
fireContainerEvent("addInitParameter", name); |
720 |
|
732 |
|
Lines 740-747
Link Here
|
740 |
*/ |
752 |
*/ |
741 |
public void addMapping(String mapping) { |
753 |
public void addMapping(String mapping) { |
742 |
|
754 |
|
743 |
synchronized (mappings) { |
755 |
try { |
|
|
756 |
mappingsLock.writeLock().lock(); |
744 |
mappings.add(mapping); |
757 |
mappings.add(mapping); |
|
|
758 |
} finally { |
759 |
mappingsLock.writeLock().unlock(); |
745 |
} |
760 |
} |
746 |
fireContainerEvent("addMapping", mapping); |
761 |
fireContainerEvent("addMapping", mapping); |
747 |
|
762 |
|
Lines 757-764
Link Here
|
757 |
*/ |
772 |
*/ |
758 |
public void addSecurityReference(String name, String link) { |
773 |
public void addSecurityReference(String name, String link) { |
759 |
|
774 |
|
760 |
synchronized (references) { |
775 |
try { |
|
|
776 |
referencesLock.writeLock().lock(); |
761 |
references.put(name, link); |
777 |
references.put(name, link); |
|
|
778 |
} finally { |
779 |
referencesLock.writeLock().unlock(); |
762 |
} |
780 |
} |
763 |
fireContainerEvent("addSecurityReference", name); |
781 |
fireContainerEvent("addSecurityReference", name); |
764 |
|
782 |
|
Lines 902-909
Link Here
|
902 |
*/ |
920 |
*/ |
903 |
public String findInitParameter(String name) { |
921 |
public String findInitParameter(String name) { |
904 |
|
922 |
|
905 |
synchronized (parameters) { |
923 |
try { |
|
|
924 |
parametersLock.readLock().lock(); |
906 |
return ((String) parameters.get(name)); |
925 |
return ((String) parameters.get(name)); |
|
|
926 |
} finally { |
927 |
parametersLock.readLock().unlock(); |
907 |
} |
928 |
} |
908 |
|
929 |
|
909 |
} |
930 |
} |
Lines 915-923
Link Here
|
915 |
*/ |
936 |
*/ |
916 |
public String[] findInitParameters() { |
937 |
public String[] findInitParameters() { |
917 |
|
938 |
|
918 |
synchronized (parameters) { |
939 |
try { |
|
|
940 |
parametersLock.readLock().lock(); |
919 |
String results[] = new String[parameters.size()]; |
941 |
String results[] = new String[parameters.size()]; |
920 |
return ((String[]) parameters.keySet().toArray(results)); |
942 |
return ((String[]) parameters.keySet().toArray(results)); |
|
|
943 |
} finally { |
944 |
parametersLock.readLock().unlock(); |
921 |
} |
945 |
} |
922 |
|
946 |
|
923 |
} |
947 |
} |
Lines 928-935
Link Here
|
928 |
*/ |
952 |
*/ |
929 |
public String[] findMappings() { |
953 |
public String[] findMappings() { |
930 |
|
954 |
|
931 |
synchronized (mappings) { |
955 |
try { |
|
|
956 |
mappingsLock.readLock().lock(); |
932 |
return (String[]) mappings.toArray(new String[mappings.size()]); |
957 |
return (String[]) mappings.toArray(new String[mappings.size()]); |
|
|
958 |
} finally { |
959 |
mappingsLock.readLock().unlock(); |
933 |
} |
960 |
} |
934 |
|
961 |
|
935 |
} |
962 |
} |
Lines 943-950
Link Here
|
943 |
*/ |
970 |
*/ |
944 |
public String findSecurityReference(String name) { |
971 |
public String findSecurityReference(String name) { |
945 |
|
972 |
|
946 |
synchronized (references) { |
973 |
try { |
|
|
974 |
referencesLock.readLock().lock(); |
947 |
return ((String) references.get(name)); |
975 |
return ((String) references.get(name)); |
|
|
976 |
} finally { |
977 |
referencesLock.readLock().unlock(); |
948 |
} |
978 |
} |
949 |
|
979 |
|
950 |
} |
980 |
} |
Lines 956-964
Link Here
|
956 |
*/ |
986 |
*/ |
957 |
public String[] findSecurityReferences() { |
987 |
public String[] findSecurityReferences() { |
958 |
|
988 |
|
959 |
synchronized (references) { |
989 |
try { |
|
|
990 |
referencesLock.readLock().lock(); |
960 |
String results[] = new String[references.size()]; |
991 |
String results[] = new String[references.size()]; |
961 |
return ((String[]) references.keySet().toArray(results)); |
992 |
return ((String[]) references.keySet().toArray(results)); |
|
|
993 |
} finally { |
994 |
referencesLock.readLock().unlock(); |
962 |
} |
995 |
} |
963 |
|
996 |
|
964 |
} |
997 |
} |
Lines 1248-1255
Link Here
|
1248 |
*/ |
1281 |
*/ |
1249 |
public void removeInitParameter(String name) { |
1282 |
public void removeInitParameter(String name) { |
1250 |
|
1283 |
|
1251 |
synchronized (parameters) { |
1284 |
try { |
|
|
1285 |
parametersLock.writeLock().lock(); |
1252 |
parameters.remove(name); |
1286 |
parameters.remove(name); |
|
|
1287 |
} finally { |
1288 |
parametersLock.writeLock().unlock(); |
1253 |
} |
1289 |
} |
1254 |
fireContainerEvent("removeInitParameter", name); |
1290 |
fireContainerEvent("removeInitParameter", name); |
1255 |
|
1291 |
|
Lines 1275-1282
Link Here
|
1275 |
*/ |
1311 |
*/ |
1276 |
public void removeMapping(String mapping) { |
1312 |
public void removeMapping(String mapping) { |
1277 |
|
1313 |
|
1278 |
synchronized (mappings) { |
1314 |
try { |
|
|
1315 |
mappingsLock.writeLock().lock(); |
1279 |
mappings.remove(mapping); |
1316 |
mappings.remove(mapping); |
|
|
1317 |
} finally { |
1318 |
mappingsLock.writeLock().unlock(); |
1280 |
} |
1319 |
} |
1281 |
fireContainerEvent("removeMapping", mapping); |
1320 |
fireContainerEvent("removeMapping", mapping); |
1282 |
|
1321 |
|
Lines 1290-1297
Link Here
|
1290 |
*/ |
1329 |
*/ |
1291 |
public void removeSecurityReference(String name) { |
1330 |
public void removeSecurityReference(String name) { |
1292 |
|
1331 |
|
1293 |
synchronized (references) { |
1332 |
try { |
|
|
1333 |
referencesLock.writeLock().lock(); |
1294 |
references.remove(name); |
1334 |
references.remove(name); |
|
|
1335 |
} finally { |
1336 |
referencesLock.writeLock().unlock(); |
1295 |
} |
1337 |
} |
1296 |
fireContainerEvent("removeSecurityReference", name); |
1338 |
fireContainerEvent("removeSecurityReference", name); |
1297 |
|
1339 |
|
Lines 1488-1495
Link Here
|
1488 |
*/ |
1530 |
*/ |
1489 |
public Enumeration getInitParameterNames() { |
1531 |
public Enumeration getInitParameterNames() { |
1490 |
|
1532 |
|
1491 |
synchronized (parameters) { |
1533 |
try { |
|
|
1534 |
parametersLock.readLock().lock(); |
1492 |
return (new Enumerator(parameters.keySet())); |
1535 |
return (new Enumerator(parameters.keySet())); |
|
|
1536 |
} finally { |
1537 |
parametersLock.readLock().unlock(); |
1493 |
} |
1538 |
} |
1494 |
|
1539 |
|
1495 |
} |
1540 |
} |