remm 01/03/21 16:51:20
Modified: catalina/src/share/org/apache/catalina/core
ApplicationContext.java
Log:
- Add possibility to make some servlet context attributes read only. Of course,
the object can still be mutated.
- This functionality is NOT exposed to servlets (at least to servlets which are
outside the Catalina core).
Revision Changes Path
1.18 +29 -4
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
Index: ApplicationContext.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ApplicationContext.java 2001/03/17 00:28:01 1.17
+++ ApplicationContext.java 2001/03/22 00:51:17 1.18
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
1.17 2001/03/17 00:28:01 craigmcc Exp $
- * $Revision: 1.17 $
- * $Date: 2001/03/17 00:28:01 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
1.18 2001/03/22 00:51:17 remm Exp $
+ * $Revision: 1.18 $
+ * $Date: 2001/03/22 00:51:17 $
*
* ====================================================================
*
@@ -111,7 +111,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.17 $ $Date: 2001/03/17 00:28:01 $
+ * @version $Revision: 1.18 $ $Date: 2001/03/22 00:51:17 $
*/
public final class ApplicationContext
@@ -202,6 +202,12 @@
/**
+ * List of read only attributes for this context.
+ */
+ private HashMap readOnlyAttributes = new HashMap();
+
+
+ /**
* The Context instance with which we are associated.
*/
private StandardContext context = null;
@@ -248,6 +254,19 @@
}
+ /**
+ * Set an attribute as read only.
+ */
+ public void setAttributeReadOnly(String name) {
+
+ synchronized (attributes) {
+ if (attributes.containsKey(name))
+ readOnlyAttributes.put(name, name);
+ }
+
+ }
+
+
// ------------------------------------------------- ServletContext Methods
@@ -710,6 +729,9 @@
// Remove the specified attribute
synchronized (attributes) {
+ // Check for read only attribute
+ if (readOnlyAttributes.containsKey(name))
+ return;
found = attributes.containsKey(name);
if (found) {
value = attributes.get(name);
@@ -761,6 +783,9 @@
// Add or replace the specified attribute
synchronized (attributes) {
+ // Check for read only attribute
+ if (readOnlyAttributes.containsKey(name))
+ return;
if (attributes.get(name) != null)
replaced = true;
attributes.put(name, value);