Author: fhanik Date: Mon Mar 26 21:44:06 2007 New Revision: 522745 URL: http://svn.apache.org/viewvc?view=rev&rev=522745 Log: fixes for http://issues.apache.org/bugzilla/show_bug.cgi?id=41166 although there is still work to be done, need to separate Tomcat attributes vs. application attributes
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java?view=diff&rev=522745&r1=522744&r2=522745 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java Mon Mar 26 21:44:06 2007 @@ -804,12 +804,17 @@ // -------------------------------------------------------- Package Methods - - + protected StandardContext getContext() { + return this.context; + } + + protected Map getReadonlyAttributes() { + return this.readOnlyAttributes; + } /** * Clear all application-created attributes. */ - void clearAttributes() { + protected void clearAttributes() { // Create list of attributes to be removed ArrayList list = new ArrayList(); Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java?view=diff&rev=522745&r1=522744&r2=522745 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java Mon Mar 26 21:44:06 2007 @@ -26,6 +26,11 @@ import org.apache.catalina.Globals; import javax.servlet.ServletContext; import java.util.AbstractMap; +import org.apache.catalina.tribes.tipis.AbstractReplicatedMap; +import java.util.ArrayList; +import java.util.Iterator; +import javax.servlet.ServletContextAttributeListener; +import javax.servlet.ServletContextAttributeEvent; /** * @author Filip Hanik @@ -98,6 +103,12 @@ } public ServletContext getServletContext() { + if (context == null) { + context = new ReplApplContext(getBasePath(), this); + if (getAltDDName() != null) + context.setAttribute(Globals.ALT_DD_ATTR,getAltDDName()); + } + return ((ReplApplContext)context).getFacade(); } @@ -118,8 +129,19 @@ public void setAttributeMap(AbstractMap map) { this.attributes = map; } - + + public void removeAttribute(String name) { + //do nothing + super.removeAttribute(name); + } + + public void setAttribute(String name, Object value) { + //do nothing + super.setAttribute(name,value); + } + } + } Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java?view=diff&rev=522745&r1=522744&r2=522745 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Mon Mar 26 21:44:06 2007 @@ -747,10 +747,13 @@ * @return Object */ public Object remove(Object key) { + return remove(key,true); + } + public Object remove(Object key, boolean notify) { MapEntry entry = (MapEntry)super.remove(key); try { - if (getMapMembers().length > 0 ) { + if (getMapMembers().length > 0 && notify) { MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_REMOVE, false, (Serializable) key, null, null, null); getChannel().send(getMapMembers(), msg, getChannelSendOptions()); } @@ -885,11 +888,20 @@ put(entry.getKey(),entry.getValue()); } } - + public void clear() { - //only delete active keys - Iterator keys = keySet().iterator(); - while ( keys.hasNext() ) remove(keys.next()); + clear(true); + } + + public void clear(boolean notify) { + if ( notify ) { + //only delete active keys + Iterator keys = keySet().iterator(); + while (keys.hasNext()) + remove(keys.next()); + } else { + super.clear(); + } } public boolean containsValue(Object value) { @@ -933,8 +945,9 @@ Iterator i = super.entrySet().iterator(); while ( i.hasNext() ) { Map.Entry e = (Map.Entry)i.next(); - MapEntry entry = (MapEntry)e.getValue(); - if ( entry.isPrimary() ) set.add(entry); + Object key = e.getKey(); + MapEntry entry = (MapEntry)super.get(key); + if ( entry.isPrimary() ) set.add(entry.getValue()); } return Collections.unmodifiableSet(set); } @@ -946,10 +959,12 @@ Iterator i = super.entrySet().iterator(); while ( i.hasNext() ) { Map.Entry e = (Map.Entry)i.next(); - MapEntry entry = (MapEntry)e.getValue(); - if ( entry.isPrimary() ) set.add(entry.getKey()); + Object key = e.getKey(); + MapEntry entry = (MapEntry)super.get(key); + if ( entry.isPrimary() ) set.add(key); } return Collections.unmodifiableSet(set); + } @@ -1056,7 +1071,7 @@ public Object setValue(Object value) { Object old = this.value; - this.value = (Serializable) value; + this.value = value; return old; } @@ -1066,7 +1081,7 @@ public Object setKey(Object key) { Object old = this.key; - this.key = (Serializable)key; + this.key = key; return old; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]