fhanik 2004/09/29 09:43:45 Modified: modules/cluster/src/share/org/apache/catalina/cluster ClusterManager.java modules/cluster/src/share/org/apache/catalina/cluster/session DeltaManager.java DeltaRequest.java DeltaSession.java SimpleTcpReplicationManager.java modules/cluster/src/share/org/apache/catalina/cluster/tcp SimpleTcpCluster.java Log: Added flag to enabled/disable attribute/context events during session delta replication Revision Changes Path 1.7 +4 -0 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/ClusterManager.java Index: ClusterManager.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/ClusterManager.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ClusterManager.java 22 Jul 2004 15:41:15 -0000 1.6 +++ ClusterManager.java 29 Sep 2004 16:43:44 -0000 1.7 @@ -71,5 +71,9 @@ public void setUseDirtyFlag(boolean useDirtyFlag); public void setCluster(CatalinaCluster cluster); + + public boolean getNotifyListenersOnReplication(); + + public void setNotifyListenersOnReplication(boolean notifyListenersOnReplication); } 1.31 +12 -2 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java Index: DeltaManager.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- DeltaManager.java 5 Sep 2004 22:03:42 -0000 1.30 +++ DeltaManager.java 29 Sep 2004 16:43:44 -0000 1.31 @@ -128,6 +128,8 @@ private boolean useDirtyFlag; private boolean expireSessionsOnShutdown; private boolean printToScreen; + + private boolean notifyListenersOnReplication = false; // ------------------------------------------------------------- Constructor public DeltaManager() { super(); @@ -895,7 +897,7 @@ DeltaSession session = (DeltaSession)findSession(msg.getSessionID()); if (session != null) { DeltaRequest dreq = loadDeltaRequest(session, delta); - dreq.execute(session); + dreq.execute(session,notifyListenersOnReplication); session.setPrimarySession(false); } @@ -984,6 +986,14 @@ } public void setName(String name) { this.name = name; + } + + public boolean getNotifyListenersOnReplication() { + return notifyListenersOnReplication; + } + + public void setNotifyListenersOnReplication(boolean notifyListenersOnReplication) { + this.notifyListenersOnReplication = notifyListenersOnReplication; } 1.9 +9 -5 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java Index: DeltaRequest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DeltaRequest.java 1 Jul 2004 09:44:26 -0000 1.8 +++ DeltaRequest.java 29 Sep 2004 16:43:44 -0000 1.9 @@ -55,7 +55,7 @@ public DeltaRequest() { } - + public DeltaRequest(String sessionId, boolean recordAllActions) { this.recordAllActions=recordAllActions; setSessionId(sessionId); @@ -108,8 +108,12 @@ //add the action actions.addLast(info); } - + public void execute(DeltaSession session) { + execute(session,true); + } + + public void execute(DeltaSession session, boolean notifyListeners) { if ( !this.sessionId.equals( session.getId() ) ) throw new java.lang.IllegalArgumentException("Session id mismatch, not executing the delta request"); session.access(); @@ -118,9 +122,9 @@ switch ( info.getType() ) { case TYPE_ATTRIBUTE: { if ( info.getAction() == ACTION_SET ) { - session.setAttribute(info.getName(), info.getValue(),false); + session.setAttribute(info.getName(), info.getValue(),notifyListeners,false); } else - session.removeAttribute(info.getName(),true,false); + session.removeAttribute(info.getName(),notifyListeners,false); break; }//case case TYPE_ISNEW: { @@ -215,7 +219,7 @@ info.writeExternal(out); } } - + public static class AttributeInfo implements java.io.Externalizable { private String name = null; private Object value = null; 1.27 +9 -5 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java Index: DeltaSession.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- DeltaSession.java 1 Jul 2004 09:44:26 -0000 1.26 +++ DeltaSession.java 29 Sep 2004 16:43:44 -0000 1.27 @@ -1239,9 +1239,9 @@ * invalidated session */ public void setAttribute(String name, Object value) { - setAttribute(name,value,true); + setAttribute(name,value,true, true); } - public void setAttribute(String name, Object value, boolean addDeltaRequest) { + public void setAttribute(String name, Object value, boolean notify, boolean addDeltaRequest) { // Name cannot be null if (name == null) @@ -1274,7 +1274,7 @@ HttpSessionBindingEvent event = null; // Call the valueBound() method if necessary - if ( value instanceof HttpSessionBindingListener ) { + if ( value instanceof HttpSessionBindingListener && notify) { event = new HttpSessionBindingEvent(getSession(), name, value); try { ( (HttpSessionBindingListener) value).valueBound(event); @@ -1287,7 +1287,7 @@ Object unbound = attributes.put(name, value); // Call the valueUnbound() method if necessary - if ((unbound != null) && + if ((unbound != null) && notify && (unbound instanceof HttpSessionBindingListener)) { try { ( (HttpSessionBindingListener) unbound).valueUnbound @@ -1297,6 +1297,10 @@ } } + + //dont notify any listeners + if (!notify) return; + // Notify interested application event listeners 1.32 +7 -0 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java Index: SimpleTcpReplicationManager.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- SimpleTcpReplicationManager.java 22 Jul 2004 15:41:15 -0000 1.31 +++ SimpleTcpReplicationManager.java 29 Sep 2004 16:43:44 -0000 1.32 @@ -100,6 +100,7 @@ * Assumes false. */ protected boolean stateTransferred = false; + private boolean notifyListenersOnReplication; /** * Constructor, just calls super() @@ -598,5 +599,11 @@ public void setName(String name) { this.name = name; + } + public boolean getNotifyListenersOnReplication() { + return notifyListenersOnReplication; + } + public void setNotifyListenersOnReplication(boolean notifyListenersOnReplication) { + this.notifyListenersOnReplication = notifyListenersOnReplication; } } 1.50 +18 -2 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java Index: SimpleTcpCluster.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- SimpleTcpCluster.java 17 Sep 2004 18:32:14 -0000 1.49 +++ SimpleTcpCluster.java 29 Sep 2004 16:43:44 -0000 1.50 @@ -166,6 +166,11 @@ * Listeners of messages */ protected Vector clusterListeners = new Vector(); + + /** + * Currently only implemented for the delta manager + */ + private boolean notifyListenersOnReplication = true; // ------------------------------------------------------------- Properties @@ -284,8 +289,10 @@ manager.setDistributable(true); manager.setExpireSessionsOnShutdown(expireSessionsOnShutdown); manager.setUseDirtyFlag(useDirtyFlag); + manager.setNotifyListenersOnReplication(notifyListenersOnReplication); managers.put(name,manager); + return manager; } @@ -371,7 +378,8 @@ clusterDeployer.setCluster(this); Object deployer = IntrospectionUtils.getProperty(getContainer(), "deployer"); // FIXME: clusterDeployer.setDeployer( (org.apache.catalina.Deployer) deployer); - clusterDeployer.start(); + // clusterDeployer.setDeployer( deployer); + clusterDeployer.start(); } } catch (Throwable x) { log.fatal("Unable to retrieve the container deployer. Cluster deployment disabled.",x); @@ -682,6 +690,14 @@ } public void setClusterDeployer(org.apache.catalina.cluster.ClusterDeployer clusterDeployer) { this.clusterDeployer = clusterDeployer; + } + + public boolean getNotifyListenersOnReplication() { + return notifyListenersOnReplication; + } + + public void setNotifyListenersOnReplication(boolean notifyListenersOnReplication) { + this.notifyListenersOnReplication = notifyListenersOnReplication; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]