tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r380209 [1/12] - in /tomcat/container/tc5.5.x/modules: groupcom/ groupcom/etc/ groupcom/src/ groupcom/src/share/ groupcom/src/share/org/ groupcom/src/share/org/apache/ groupcom/src/share/org/apache/catalina/ groupcom/src/share/org/apache/ca...
Date Thu, 23 Feb 2006 19:55:25 GMT
Author: fhanik
Date: Thu Feb 23 11:55:14 2006
New Revision: 380209

URL: http://svn.apache.org/viewcvs?rev=380209&view=rev
Log:
Skeleton for two new modules where tomcat replication logic is separated from the messaging logic

Added:
    tomcat/container/tc5.5.x/modules/groupcom/
    tomcat/container/tc5.5.x/modules/groupcom/build.xml
    tomcat/container/tc5.5.x/modules/groupcom/etc/
    tomcat/container/tc5.5.x/modules/groupcom/etc/cluster-server.xml
    tomcat/container/tc5.5.x/modules/groupcom/src/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelException.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterMessage.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterReceiver.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSession.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Constants.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/LocalStrings.properties
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Member.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipListener.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipService.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/ListenCallback.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/ObjectReader.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/ReplicationStream.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/SocketObjectReader.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/mbeans-descriptors.xml
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/mcast/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/mcast/Constants.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/mcast/LocalStrings.properties
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/mcast/McastMember.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/mcast/McastMembership.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/mcast/McastService.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/mcast/McastServiceImpl.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/mcast/mbeans-descriptors.xml
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/package.html
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/AsyncSocketSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ClusterData.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/Constants.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/DataSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/DataSenders.properties
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/FastAsyncSocketSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/IDataSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/IDataSenderFactory.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/LocalStrings.properties
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/PooledSocketSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.jbx
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/SendMessageData.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/SenderState.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/SocketSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ThreadPool.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/WorkerThread.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/mbeans-descriptors.xml
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/util/
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/util/FastQueue.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/util/IDynamicProperty.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/util/IQueue.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/util/LinkObject.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/util/SingleRemoveSynchronizedAddLock.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/util/SmartQueue.java
    tomcat/container/tc5.5.x/modules/groupcom/test/
    tomcat/container/tc5.5.x/modules/ha/
    tomcat/container/tc5.5.x/modules/ha/build.xml
    tomcat/container/tc5.5.x/modules/ha/etc/
    tomcat/container/tc5.5.x/modules/ha/src/
    tomcat/container/tc5.5.x/modules/ha/src/share/
    tomcat/container/tc5.5.x/modules/ha/src/share/org/
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterDeployer.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterManager.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterReceiver.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterSender.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterSession.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/ClusterValve.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/Constants.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/LocalStrings.properties
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/Member.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/MembershipListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/MembershipService.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/MessageListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/FileChangeListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/FileMessage.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/FileMessageFactory.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/deploy/WarWatcher.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/mbeans-descriptors.xml
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/package.html
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/ClusterSessionListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/Constants.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaRequest.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaSession.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaSessionFacade.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/LocalStrings.properties
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/ReplicatedSession.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/ReplicationStream.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SerializablePrincipal.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionMessage.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/ClusterReceiverBase.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/Constants.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/LocalStrings.properties
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/ReplicationValve.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SendMessageData.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SocketReplicationListener.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SocketReplicationThread.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/mbeans-descriptors.xml
    tomcat/container/tc5.5.x/modules/ha/test/

Added: tomcat/container/tc5.5.x/modules/groupcom/build.xml
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/build.xml?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/build.xml (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/build.xml Thu Feb 23 11:55:14 2006
@@ -0,0 +1,153 @@
+<project name="GroupCom" default="dist" basedir=".">
+
+
+  <!-- ===================== Initialize Property Values =================== -->
+
+  <property file="../../../build.properties" />
+  <property file="../../../build/build.properties" />
+  <property file="../../../build/build.properties.default" />
+
+  <!-- Build Defaults -->
+  <property name="catalina.home"  location="../.."/>
+  <property name="catalina.build" location="../../../build/build"/>
+  <property name="groupcom.build"  value="${catalina.home}/modules/groupcom/build"/>
+  <property name="groupcom.dist"   value="${catalina.home}/modules/groupcom/dist"/>
+
+    <!-- Construct Catalina classpath -->
+  <path id="groupcom.classpath">
+    <pathelement location="${catalina.build}/server/lib/catalina.jar"/>
+    <pathelement location="${catalina.build}/server/lib/tomcat-util.jar"/>
+    <pathelement location="${commons-modeler.jar}"/>
+    <pathelement location="${commons-logging.jar}"/>
+    <pathelement location="${jmx.jar}"/>
+    <pathelement location="${catalina.build}/common/lib/servlet-api.jar"/>
+  </path>
+
+    <!-- Source path -->
+  <path id="javadoc.sourcepath">
+    <pathelement location="src/share"/>
+  </path>
+
+
+  <!-- =================== BUILD: Set compile flags ======================= -->
+  <target name="flags">
+    <!-- JDK flags -->
+    <available property="jdk.1.2.present" classname="java.util.HashMap" />
+    <available property="jdk.1.3.present" 
+     classname="java.lang.reflect.Proxy" />
+    <available property="jdk.1.4.present" classname="java.nio.Buffer" />
+  </target>
+
+
+  <!-- =================== BUILD: Set compile flags ======================= -->
+  <target name="flags.display" depends="flags" unless="flags.hide">
+
+    <echo message="--- Build environment for Catalina ---" />
+
+    <echo message="If ${property_name} is displayed, then the property is not set)" />
+
+    <echo message="--- Build options ---" />
+    <echo message="full.dist=${full.dist}" />
+    <echo message="build.sysclasspath=${build.sysclasspath}" />
+    <echo message="compile.debug=${compile.debug}" />
+    <echo message="compile.deprecation=${compile.deprecation}" />
+    <echo message="compile.optimize=${compile.optimize}" />
+
+    <echo message="--- Ant Flags ---" />
+    <echo message="&lt;style&gt; task available (required)=${style.available}" />
+
+    <echo message="--- JDK ---" />
+    <echo message="jdk.1.2.present=${jdk.1.2.present}" />
+    <echo message="jdk.1.3.present=${jdk.1.3.present}" />
+    <echo message="jdk.1.4.present=${jdk.1.4.present}" />
+
+  </target>
+
+  <!-- =================== BUILD: Create Directories ====================== -->
+  <target name="build-prepare">
+    <mkdir dir="${catalina.build}"/>
+    <mkdir dir="${catalina.build}/classes"/>
+    <mkdir dir="${groupcom.dist}"/>
+  </target>
+
+
+  
+
+  <!-- ================ BUILD: Compile Catalina Components ================ -->
+  
+  <target name="build-catalina-groupcom" depends="build-prepare">
+    <!-- Compile internal server components -->
+    <javac srcdir="${basedir}/src/share" destdir="${catalina.build}/classes"
+           debug="${compile.debug}" deprecation="${compile.deprecation}"
+           optimize="${compile.optimize}"
+           excludes="**/CVS/**"  	   
+    	>
+        <classpath refid="groupcom.classpath" />
+    </javac>
+    <copy file="${basedir}/src/share/org/apache/catalina/cluster/LocalStrings.properties"
+    	  tofile="${catalina.build}/classes/org/apache/catalina/cluster/LocalStrings.properties"/>
+    <copy file="${basedir}/src/share/org/apache/catalina/cluster/tcp/LocalStrings.properties"
+    	  tofile="${catalina.build}/classes/org/apache/catalina/cluster/tcp/LocalStrings.properties"/>
+    <copy file="${basedir}/src/share/org/apache/catalina/cluster/tcp/DataSenders.properties"
+    	  tofile="${catalina.build}/classes/org/apache/catalina/cluster/tcp/DataSenders.properties"/>
+    <copy file="${basedir}/src/share/org/apache/catalina/cluster/tcp/mbeans-descriptors.xml"
+    	  tofile="${catalina.build}/classes/org/apache/catalina/cluster/tcp/mbeans-descriptors.xml"/>
+    <copy file="${basedir}/src/share/org/apache/catalina/cluster/mcast/LocalStrings.properties"
+    	  tofile="${catalina.build}/classes/org/apache/catalina/cluster/mcast/LocalStrings.properties"/>
+    <copy file="${basedir}/src/share/org/apache/catalina/cluster/mcast/mbeans-descriptors.xml"
+     	  tofile="${catalina.build}/classes/org/apache/catalina/cluster/mcast/mbeans-descriptors.xml"/>
+   </target>
+
+
+  <!-- ================ BUILD: Create Catalina Javadocs =================== -->
+  <target name="javadoc">
+    <delete dir="${catalina.build}/javadoc"/>
+    <mkdir dir="${catalina.build}/javadoc"/>
+    <javadoc packagenames="org.apache.catalina.*,org.apache.naming.*"
+      classpathref="catalina.classpath"
+      sourcepathref="javadoc.sourcepath"
+      destdir="${catalina.build}/javadoc"
+      author="true"
+      version="true"
+      windowtitle="Catalina Internal API Documentation"
+      doctitle="Catalina API"
+      bottom="Copyright &#169; 2000-2002 Apache Software Foundation.  All Rights Reserved."
+    />
+  </target>
+
+
+  <!-- ======================= BUILD: Clean Directory ===================== -->
+  <target name="build-clean">
+    <delete dir="${catalina.build}"/>
+  </target>
+
+
+  <!-- ==================== BUILD: Rebuild Everything ===================== -->
+
+
+
+
+  <!-- ================ DIST: Create Distribution ========================= -->
+  <target name="dist" depends="build-catalina-groupcom">
+    
+    <jar destfile="${groupcom.dist}/catalina-groups.jar"
+         basedir="${catalina.build}/classes">
+       <include name="org/apache/catalina/cluster/**" />
+       <exclude name="**/package.html" />
+       <exclude name="**/LocalStrings_*" />
+    </jar>
+  </target>
+
+  <target name="copy" depends="dist" >
+     <copy file="${groupcom.dist}/catalina-groups.jar" todir="${catalina.build}/server/lib" />
+  </target>
+  
+  <!-- ======================== DIST: Clean Directory ===================== -->
+
+  <target name="clean">
+      <delete dir="${catalina.build}/classes"/>
+  </target>
+  <!-- ====================== Convenient Synonyms ========================= -->
+
+
+</project>

Added: tomcat/container/tc5.5.x/modules/groupcom/etc/cluster-server.xml
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/etc/cluster-server.xml?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/etc/cluster-server.xml (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/etc/cluster-server.xml Thu Feb 23 11:55:14 2006
@@ -0,0 +1,368 @@
+<!-- Example Server Configuration File  - Search for Cluster-->
+<!-- Note that component elements are nested corresponding to their
+     parent-child relationships with each other -->
+
+<!-- A "Server" is a singleton element that represents the entire JVM,
+     which may contain one or more "Service" instances.  The Server
+     listens for a shutdown command on the indicated port.
+
+     Note:  A "Server" is not itself a "Container", so you may not
+     define subcomponents such as "Valves" or "Loggers" at this level.
+ -->
+
+<Server port="8005" shutdown="SHUTDOWN" debug="0">
+
+
+  <!-- Comment these entries out to disable JMX MBeans support -->
+  <!-- You may also configure custom components (e.g. Valves/Realms) by 
+       including your own mbean-descriptor file(s), and setting the 
+       "descriptors" attribute to point to a ';' seperated list of paths
+       (in the ClassLoader sense) of files to add to the default list.
+       e.g. descriptors="/com/myfirm/mypackage/mbean-descriptor.xml"
+  -->
+  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
+            debug="0"/>
+  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
+            debug="0"/>
+  
+  <!-- Global JNDI resources -->
+  <GlobalNamingResources>
+
+    <!-- Test entry for demonstration purposes -->
+    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
+
+    <!-- Editable user database that can also be used by
+         UserDatabaseRealm to authenticate users -->
+    <Resource name="UserDatabase" auth="Container"
+              type="org.apache.catalina.UserDatabase"
+       description="User database that can be updated and saved">
+    </Resource>
+    <ResourceParams name="UserDatabase">
+      <parameter>
+        <name>factory</name>
+        <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
+      </parameter>
+      <parameter>
+        <name>pathname</name>
+        <value>conf/tomcat-users.xml</value>
+      </parameter>
+    </ResourceParams>
+
+  </GlobalNamingResources>
+
+  <!-- A "Service" is a collection of one or more "Connectors" that share
+       a single "Container" (and therefore the web applications visible
+       within that Container).  Normally, that Container is an "Engine",
+       but this is not required.
+
+       Note:  A "Service" is not itself a "Container", so you may not
+       define subcomponents such as "Valves" or "Loggers" at this level.
+   -->
+
+  <!-- Define the Tomcat Stand-Alone Service -->
+  <Service name="Tomcat-Standalone">
+
+    <!-- A "Connector" represents an endpoint by which requests are received
+         and responses are returned.  Each Connector passes requests on to the
+         associated "Container" (normally an Engine) for processing.
+
+         By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
+         You can also enable an SSL HTTP/1.1 Connector on port 8443 by
+         following the instructions below and uncommenting the second Connector
+         entry.  SSL support requires the following steps (see the SSL Config
+         HOWTO in the Tomcat 5 documentation bundle for more detailed
+         instructions):
+         * If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
+           later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
+         * Execute:
+             %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
+             $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA  (Unix)
+           with a password value of "changeit" for both the certificate and
+           the keystore itself.
+
+         By default, DNS lookups are enabled when a web application calls
+         request.getRemoteHost().  This can have an adverse impact on
+         performance, so you can disable it by setting the
+         "enableLookups" attribute to "false".  When DNS lookups are disabled,
+         request.getRemoteHost() will return the String version of the
+         IP address of the remote client.
+    -->
+
+    <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
+    <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
+               port="8080" minProcessors="5" maxProcessors="100"
+               enableLookups="true" redirectPort="8443" acceptCount="100"
+               debug="0" connectionTimeout="20000" 
+               disableUploadTimeout="true" />
+    <!-- Note : To disable connection timeouts, set connectionTimeout value
+     to -1 -->
+
+    <!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
+    <!--
+    <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
+               port="8443" minProcessors="5" maxProcessors="75"
+               enableLookups="true" disableUploadTimeout="true"
+           acceptCount="100" debug="0" scheme="https" secure="true">
+      <Factory className="org.apache.coyote.tomcat5.CoyoteServerSocketFactory"
+               clientAuth="false" protocol="TLS" />
+    </Connector>
+    -->
+
+    <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
+    <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
+               port="8009" minProcessors="5" maxProcessors="75"
+               enableLookups="true" redirectPort="8443"
+               acceptCount="10" debug="0"
+               protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
+
+    <!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
+    <!-- See proxy documentation for more information about using this. -->
+    <!--
+    <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
+               port="8082" minProcessors="5" maxProcessors="75"
+               enableLookups="true"
+               acceptCount="100" debug="0" connectionTimeout="20000"
+               proxyPort="80" disableUploadTimeout="true" />
+    -->
+
+    <!-- An Engine represents the entry point (within Catalina) that processes
+         every request.  The Engine implementation for Tomcat stand alone
+         analyzes the HTTP headers included with the request, and passes them
+         on to the appropriate Host (virtual host). -->
+
+    <!-- You should set jvmRoute to support load-balancing via JK/JK2 ie :
+    <Engine name="Standalone" defaultHost="localhost" debug="0" jmvRoute="jvm1">         
+    --> 
+         
+    <!-- Define the top level container in our container hierarchy -->
+    <Engine name="Standalone" defaultHost="localhost" debug="0">
+
+      <!-- The request dumper valve dumps useful debugging information about
+           the request headers and cookies that were received, and the response
+           headers and cookies that were sent, for all requests received by
+           this instance of Tomcat.  If you care only about requests to a
+           particular virtual host, or a particular application, nest this
+           element inside the corresponding <Host> or <Context> entry instead.
+
+           For a similar mechanism that is portable to all Servlet 2.4
+           containers, check out the "RequestDumperFilter" Filter in the
+           example application (the source for this filter may be found in
+           "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
+
+           Request dumping is disabled by default.  Uncomment the following
+           element to enable it. -->
+      <!--
+      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
+      -->
+
+      <!-- Global logger unless overridden at lower levels -->
+      <Logger className="org.apache.catalina.logger.FileLogger"
+              prefix="catalina_log." suffix=".txt"
+              timestamp="true"/>
+
+      <!-- Because this Realm is here, an instance will be shared globally -->
+
+      <!-- This Realm uses the UserDatabase configured in the global JNDI
+           resources under the key "UserDatabase".  Any edits
+           that are performed against this UserDatabase are immediately
+           available for use by the Realm.  -->
+      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
+                 debug="0" resourceName="UserDatabase"/>
+
+      <!-- Comment out the old realm but leave here for now in case we
+           need to go back quickly -->
+      <!--
+      <Realm className="org.apache.catalina.realm.MemoryRealm" />
+      -->
+
+      <!-- Replace the above Realm with one of the following to get a Realm
+           stored in a database and accessed via JDBC -->
+
+      <!--
+      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
+             driverName="org.gjt.mm.mysql.Driver"
+          connectionURL="jdbc:mysql://localhost/authority"
+         connectionName="test" connectionPassword="test"
+              userTable="users" userNameCol="user_name" userCredCol="user_pass"
+          userRoleTable="user_roles" roleNameCol="role_name" />
+      -->
+
+      <!--
+      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
+             driverName="oracle.jdbc.driver.OracleDriver"
+          connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
+         connectionName="scott" connectionPassword="tiger"
+              userTable="users" userNameCol="user_name" userCredCol="user_pass"
+          userRoleTable="user_roles" roleNameCol="role_name" />
+      -->
+
+      <!--
+      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
+             driverName="sun.jdbc.odbc.JdbcOdbcDriver"
+          connectionURL="jdbc:odbc:CATALINA"
+              userTable="users" userNameCol="user_name" userCredCol="user_pass"
+          userRoleTable="user_roles" roleNameCol="role_name" />
+      -->
+
+      <!-- Define the default virtual host -->
+      <Host name="localhost" debug="0" appBase="webapps"
+       unpackWARs="true" autoDeploy="true">
+       
+        
+        <!-- Defines a cluster for this node,
+             By defining this element, means that every manager will be changed.
+             So when running a cluster, only make sure that you have webapps in there
+             that need to be clustered and remove the other ones.
+             A cluster has the following parameters:
+             
+             className = the fully qualified name of the cluster class
+             
+             name = a descriptive name for your cluster, can be anything
+             
+             debug = the debug level, higher means more output
+             
+             mcastAddr = the multicast address, has to be the same for all the nodes
+             
+             mcastPort = the multicast port, has to be the same for all the nodes
+             
+             mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat
+             
+             mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received
+             
+             tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes 
+
+             tcpListenAddress = the listen address (bind address) for TCP cluster request on this host, 
+                                in case of multiple ethernet cards.
+                                auto means that address becomes
+                                InetAddress.getLocalHost().getHostAddress()
+
+             tcpListenPort = the tcp listen port
+             
+             tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
+                                  has a wakup bug in java.nio. Set to 0 for no timeout
+
+             printToScreen = true means that managers will also print to std.out
+
+             expireSessionsOnShutdown = true means that 
+
+             useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
+                            false means to replicate the session after each request.
+                            false means that replication would work for the following piece of code:
+                            <%
+                            HashMap map = new HashMap();
+                            session.setAttribute("map",map);
+                            map.put("key","value");
+                            %>
+        -->             
+             
+            
+        <Cluster  className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
+                  name="FilipsCluster"
+                  debug="10"
+                  serviceclass="org.apache.catalina.cluster.mcast.McastService"
+                  mcastAddr="228.0.0.4"
+                  mcastPort="45564"
+                  mcastFrequency="500"
+                  mcastDropTime="3000"
+                  tcpThreadCount="2"
+                  tcpListenAddress="auto"
+                  tcpListenPort="4001"
+                  tcpSelectorTimeout="100"
+                  printToScreen="false"
+                  expireSessionsOnShutdown="false"
+                  useDirtyFlag="true"
+        />
+        
+        <!--
+            When configuring for clustering, you also add in a valve to catch all the requests
+            coming in, at the end of the request, the session may or may not be replicated.
+            A session is replicated if and only if all the conditions are met:
+            1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
+            2. a session exists (has been created)
+            3. the request is not trapped by the "filter" attribute
+            
+            The filter attribute is to filter out requests that could not modify the session,
+            hence we don't replicate the session after the end of this request.
+            The filter is negative, ie, anything you put in the filter, you mean to filter out,
+            ie, no replication will be done on requests that match one of the filters.
+            The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
+            
+            filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
+            ending with .gif and .js are intercepted.
+        -->
+            
+        <Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
+               filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
+
+      <!-- Add the following attributes if you want to turn XML validation
+           on. Remember to comment the Host element above. 
+           
+           Note: XML Schema validationn will works with Xerces 2.0.1 or 
+           Xerces 2.1. Xerces 2.0.2 and Xerces 2.2 have bugs that prevent 
+           their use with Tomcat-->
+      <!--
+      <Host name="localhost" debug="0" appBase="webapps"
+       unpackWARs="true" autoDeploy="true"
+       xmlValidation="true" xmlNamespaceAware="true">
+      -->
+
+        <!-- Uncomment this to cluster this host using JavaGroups. The
+             protocol attribute can be used to configure the JavaGroups
+             network stack (the defaults are used if it's not specified). -->
+        <!--
+        <Cluster className="org.apache.catalina.cluster.JGCluster"/>
+        -->
+
+        <!-- Normally, users must authenticate themselves to each web app
+             individually.  Uncomment the following entry if you would like
+             a user to be authenticated the first time they encounter a
+             resource protected by a security constraint, and then have that
+             user identity maintained across *all* web applications contained
+             in this virtual host. -->
+        <!--
+        <Valve className="org.apache.catalina.authenticator.SingleSignOn"
+                   debug="0"/>
+        -->
+        
+        <!-- Access log processes all requests for this virtual host.  By
+             default, log files are created in the "logs" directory relative to
+             $CATALINA_HOME.  If you wish, you can specify a different
+             directory with the "directory" attribute.  Specify either a relative
+             (to $CATALINA_HOME) or absolute path to the desired directory.
+        -->
+        <!--
+        <Valve className="org.apache.catalina.valves.AccessLogValve"
+                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
+                 pattern="common" resolveHosts="false"/>
+        -->
+
+        <!-- Logger shared by all Contexts related to this virtual host.  By
+             default (when using FileLogger), log files are created in the "logs"
+             directory relative to $CATALINA_HOME.  If you wish, you can specify
+             a different directory with the "directory" attribute.  Specify either a
+             relative (to $CATALINA_HOME) or absolute path to the desired
+             directory.-->
+        <Logger className="org.apache.catalina.logger.FileLogger"
+                 directory="logs"  prefix="localhost_log." suffix=".txt"
+            timestamp="true"/>
+
+        <!-- Define properties for each web application.  This is only needed
+             if you want to set non-default properties, or have web application
+             document roots in places other than the virtual host's appBase
+             directory.  -->
+
+        <!-- Tomcat Root Context -->
+        <!--
+        <Context path="/reptest" docBase="reptest" debug="0">
+            
+        </Context>
+        -->
+        
+
+      </Host>
+
+    </Engine>
+
+  </Service>
+
+</Server>

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelException.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelException.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelException.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelException.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 1999,2004-2005 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.cluster;
+
+/**
+ * Channel Exception 
+ * @author Filip Hanik
+ * @version $Revision: 304032 $, $Date: 2005-07-27 10:11:55 -0500 (Wed, 27 Jul 2005) $
+ */
+
+public class ChannelException
+    extends Exception {
+    public ChannelException() {
+        super();
+    }
+
+    public ChannelException(String message) {
+        super(message);
+    }
+
+    public ChannelException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public ChannelException(Throwable cause) {
+        super(cause);
+    }
+
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterChannel.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,76 @@
+/*
+ * Copyright 1999,2004-2005 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.cluster;
+
+/**
+ * Channel interface
+ * A channel is an object that manages a group of members.
+ * It manages a complete cluster group, both membership and replication.
+ * @author Filip Hanik
+ * @version $Revision: 304032 $, $Date: 2005-07-27 10:11:55 -0500 (Wed, 27 Jul 2005) $
+ */
+public interface ClusterChannel {
+    
+    /**
+     * Start and stop sequences can be controlled by these constants
+     */
+    public static final int DEFAULT = 15;
+    public static final int MBR_RX_SEQ = 1;
+    public static final int SND_TX_SEQ = 2;
+    public static final int SND_RX_SEQ = 4;
+    public static final int MBR_TX_SEQ = 8;
+    
+    /**
+     * Starts up the channel. This can be called multiple times for individual services to start
+     * The svc parameter can be the logical or value of any constants
+     * @param svc int value of <BR>
+     * DEFAULT - will start all services <BR>
+     * MBR_RX_SEQ - starts the membership receiver <BR>
+     * MBR_TX_SEQ - starts the membership broadcaster <BR>
+     * SND_TX_SEQ - starts the replication transmitter<BR>
+     * SND_RX_SEQ - starts the replication receiver<BR>
+     * @throws ChannelException if a startup error occurs or the service is already started.
+     */
+    public void start(int svc) throws ChannelException;
+
+    /**
+     * Shuts down the channel. This can be called multiple times for individual services to shutdown
+     * The svc parameter can be the logical or value of any constants
+     * @param svc int value of <BR>
+     * DEFAULT - will shutdown all services <BR>
+     * MBR_RX_SEQ - stops the membership receiver <BR>
+     * MBR_TX_SEQ - stops the membership broadcaster <BR>
+     * SND_TX_SEQ - stops the replication transmitter<BR>
+     * SND_RX_SEQ - stops the replication receiver<BR>
+     * @throws ChannelException if a startup error occurs or the service is already started.
+     */
+    public void stop(int svc) throws ChannelException;    
+    
+    /**
+     * Send a message to one or more members in the cluster
+     * @param destination Member[] - the destinations, null or zero length means all
+     * @param msg ClusterMessage - the message to send
+     * @param options int - sender options, see class documentation
+     * @return ClusterMessage[] - the replies from the members, if any. 
+     */
+    public ClusterMessage[] send(Member[] destination, ClusterMessage msg, int options) throws ChannelException;
+
+    
+    public void setClusterSender(ClusterSender sender);
+    public void setClusterReceiver(ClusterReceiver receiver);
+    public void setMembershipService(MembershipService service);
+    
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterMessage.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterMessage.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterMessage.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterMessage.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,100 @@
+/*
+ * Copyright 1999,2005 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.cluster;
+
+import java.io.Serializable;
+
+/**
+ * @author Filip Hanik
+ * @author Peter Rossbach
+ * 
+ */
+public interface ClusterMessage extends Serializable {
+    
+    public final static int FLAG_FORBIDDEN = 0 ;
+    public final static int FLAG_ALLOWED = 1 ;
+    public final static int FLAG_DEFAULT = 2 ;
+    
+    /**
+     * Get the address that this message originated from.  This would be set
+     * if the message was being relayed from a host other than the one
+     * that originally sent it.
+     */
+    public Member getAddress();
+
+    /**
+     * Called by the cluster before sending it to the other
+     * nodes.
+     *
+     * @param member Member
+     */
+    public void setAddress(Member member);
+
+    /**
+     * Timestamp message.
+     *
+     * @return long
+     */
+    public long getTimestamp();
+
+    /**
+     * Called by the cluster before sending out
+     * the message.
+     *
+     * @param timestamp The timestamp
+     */
+    public void setTimestamp(long timestamp);
+
+    /**
+     * Each message must have a unique ID, in case of using async replication,
+     * and a smart queue, this id is used to replace messages not yet sent.
+     *
+     * @return String
+     */
+    public String getUniqueId();
+
+    /**
+     * Each message can made the desicion that resend is allowed or not or handle by default.
+     * @return 0 Forbidden, 1 allowed, 2 default
+     * @since 5.5.10
+     */
+    public int getResend();
+    
+    /**
+     * set desicion that resend is allowed or not or handle by default.
+     *
+     * @param resend 0 Forbidden, 1 allowed, 2 default
+     * @since 5.5.10
+     */
+    public void setResend(int resend) ;
+
+    /**
+     * Each message can made the desicion that compress is allowed or not or handle by default.
+     *
+     * @return 0 Forbidden, 1 allowed, 2 default
+     * @since 5.5.10
+     */
+    public int getCompress();
+    
+    /**
+     * set desicion that compress is allowed or not or handle by default.
+     *
+     * @param compress 0 Forbidden, 1 allowed, 2 default
+     * @since 5.5.10
+     */
+    public void setCompress(int compress) ;
+
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterReceiver.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterReceiver.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterReceiver.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterReceiver.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 1999,2004-2005 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.cluster;
+
+
+/**
+ * Cluster Receiver Interface
+ * @author Filip Hanik
+ * @author Peter Rossbach
+ * @version $Revision: 379904 $, $Date: 2006-02-22 15:16:25 -0600 (Wed, 22 Feb 2006) $
+ */
+public interface ClusterReceiver {
+    /**
+     * Start message listing
+     * @throws java.io.IOException
+     */
+    public void start() throws java.io.IOException;
+
+    /**
+     * Stop message listing 
+     */
+    public void stop();
+
+    
+    public boolean isSendAck();
+    
+    /**
+     * set ack mode
+     * @param isSendAck
+     */
+    public void setSendAck(boolean isSendAck);
+    
+    public boolean isCompress() ;
+    public void setCompress(boolean compress);
+
+    /**
+     * get the listing ip interface
+     * @return The host
+     */
+    public String getHost();
+    
+    
+    /**
+     * get the listing ip port
+     * @return The port
+     */
+    public int getPort();
+    
+    public void setMessageListener(MessageListener listener);
+    public MessageListener getMessageListener();
+
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 1999,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.cluster;
+
+/**
+ * 
+ * @author Filip Hanik
+ * @version $Revision: 303950 $, $Date: 2005-06-09 15:38:30 -0500 (Thu, 09 Jun 2005) $
+ *
+ */
+public interface ClusterSender
+{
+
+    public void add(Member member);
+
+    public void remove(Member member);
+
+    public void start() throws java.io.IOException;
+
+    public void stop();
+
+    public void backgroundProcess() ;
+
+    public void sendMessage(ClusterMessage message, Member member) throws java.io.IOException;
+
+    public void sendMessage(ClusterMessage message) throws java.io.IOException;
+    
+    public void sendMessageClusterDomain(ClusterMessage message) throws java.io.IOException;
+
+    public boolean isWaitForAck();
+    public void setWaitForAck(boolean isWaitForAck);
+
+    public boolean isCompress() ;
+    public void setCompress(boolean compress);
+
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSession.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSession.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSession.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSession.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 1999,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.cluster;
+
+import org.apache.catalina.Session;
+import javax.servlet.http.HttpSession;
+
+public interface ClusterSession extends Session, HttpSession {
+   /**
+    * returns true if this session is the primary session, if that is the
+    * case, the manager can expire it upon timeout.
+    * @return True if this session is primary
+    */
+   public boolean isPrimarySession();
+
+   /**
+    * Sets whether this is the primary session or not.
+    * @param primarySession Flag value
+    */
+   public void setPrimarySession(boolean primarySession);
+
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Constants.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Constants.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Constants.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Constants.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 1999,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.cluster;
+
+/**
+ * Manifest constants for the <code>org.apache.catalina.cluster</code>
+ * package.
+ *
+ * @author Bip Thelin
+ * @version $Revision: 302726 $, $Date: 2004-02-27 08:59:07 -0600 (Fri, 27 Feb 2004) $
+ */
+
+public final class Constants {
+    public static final String Package = "org.apache.catalina.cluster";
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/LocalStrings.properties
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/LocalStrings.properties?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/LocalStrings.properties (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/LocalStrings.properties Thu Feb 23 11:55:14 2006
@@ -0,0 +1 @@
+cluster.mbean.register.already=MBean {0} already registered!

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Member.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Member.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Member.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/Member.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 1999,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.cluster;
+
+/**
+ * The Member interface, defines a member in the Cluster.
+ * A member is a Tomcat process that participates in session replication.<BR>
+ * Each member can carry a set of properties, defined by the actual implementation.<BR>
+ * For TCP replication has been targeted for the first release, the hostname and listen port
+ * of the member is defined as hardcoded stuff.<BR>
+ * The Member interface together with MembershipListener, MembershipService are interfaces used to
+ * switch out the service used to establish membership in between the cluster nodes.
+ *
+ * @author Filip Hanik
+ * @version $Revision: 303950 $, $Date: 2005-06-09 15:38:30 -0500 (Thu, 09 Jun 2005) $
+ */
+
+
+public interface Member {
+    /**
+     * Return implementation specific properties about this cluster node.
+     */
+    public java.util.HashMap getMemberProperties();
+    /**
+     * Returns the name of this node, should be unique within the cluster.
+     */
+    public String getName();
+  
+    /**
+     * Returns the name of the cluster domain from this node
+     */
+    public String getDomain();
+    
+    /**
+     * Returns the TCP listen host for the TCP implementation
+     */
+    public String getHost();
+    /**
+     * Returns the TCP listen portfor the TCP implementation
+     */
+    public int getPort();
+
+    /**
+     * Contains information on how long this member has been online.
+     * The result is the number of milli seconds this member has been
+     * broadcasting its membership to the cluster.
+     * @return nr of milliseconds since this member started.
+     */
+    public long getMemberAliveTime();
+    
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipListener.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipListener.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipListener.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999,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.cluster;
+
+/**
+ * The MembershipListener interface is used as a callback to the
+ * membership service. It has two methods that will notify the listener
+ * when a member has joined the cluster and when a member has disappeared (crashed)
+ *
+ * @author Filip Hanik
+ * @version $Revision: 302726 $, $Date: 2004-02-27 08:59:07 -0600 (Fri, 27 Feb 2004) $
+ */
+
+
+public interface MembershipListener {
+    public void memberAdded(Member member);
+    public void memberDisappeared(Member member);
+
+}
\ No newline at end of file

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipService.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipService.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipService.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MembershipService.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,110 @@
+/*
+ * Copyright 1999,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.cluster;
+
+
+/**
+ * The membership service helps the cluster determine the membership
+ * logic in the cluster.
+ * @author Filip Hanik
+ * @version $Revision: 378093 $, $Date: 2006-02-15 15:13:45 -0600 (Wed, 15 Feb 2006) $
+ */
+
+
+public interface MembershipService {
+    
+    public static final int MBR_RX = 1;
+    public static final int MBR_TX = 2;
+    
+    /**
+     * Sets the properties for the membership service. This must be called before
+     * the <code>start()</code> method is called.
+     * The properties are implementation specific.
+     * @param properties - to be used to configure the membership service.
+     */
+    public void setProperties(java.util.Properties properties);
+    /**
+     * Returns the properties for the configuration used.
+     */
+    public java.util.Properties getProperties();
+    /**
+     * Starts the membership service. If a membership listeners is added
+     * the listener will start to receive membership events.
+     * Performs a start level 1 and 2
+     * @throws java.lang.Exception if the service fails to start.
+     */
+    public void start() throws java.lang.Exception;
+
+    /**
+     * Starts the membership service. If a membership listeners is added
+     * the listener will start to receive membership events.
+     * @param level - level 1 starts listening for members, level 2 
+     * starts broad casting the server
+     * @throws java.lang.Exception if the service fails to start.
+     */
+    public void start(int level) throws java.lang.Exception;
+
+
+    /**
+     * Stops the membership service
+     */
+    public void stop();
+    
+    /**
+     * Returns that cluster has members.
+     */
+    public boolean hasMembers();
+    
+    /**
+     * Returns a list of all the members in the cluster.
+     */
+    
+    public Member[] getMembers();
+    
+    /**
+     * Returns the member object that defines this member
+     */
+    public Member getLocalMember();
+
+    /**
+     * Return all members by name
+     */
+    public String[] getMembersByName() ; 
+    
+    /**
+     * Return the member by name
+     */
+    public Member findMemberByName(String name) ;
+
+    /**
+     * Sets the local member properties for broadcasting
+     */
+    public void setLocalMemberProperties(String listenHost, int listenPort);
+    
+    /**
+     * Sets the membership listener, only one listener can be added.
+     * If you call this method twice, the last listener will be used.
+     * @param listener The listener
+     */
+    public void setMembershipListener(MembershipListener listener);
+    
+    /**
+     * removes the membership listener.
+     */
+    public void removeMembershipListener();
+
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/MessageListener.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1999,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.cluster;
+
+public interface MessageListener {
+    
+    public void messageReceived(ClusterMessage msg);
+    
+    public boolean accept(ClusterMessage msg);
+    
+    public boolean equals(Object listener);
+    
+    public int hashCode();
+
+}

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java?rev=380209&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/demos/Draw.java Thu Feb 23 11:55:14 2006
@@ -0,0 +1,484 @@
+package org.apache.catalina.cluster.demos;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Random;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import org.apache.catalina.cluster.ClusterMessage;
+import org.apache.catalina.cluster.Member;
+import org.apache.catalina.cluster.group.ChannelInterceptorBase;
+import org.apache.catalina.cluster.group.GroupChannel;
+import org.apache.catalina.cluster.mcast.McastService;
+import org.apache.catalina.cluster.tcp.ReplicationListener;
+import org.apache.catalina.cluster.tcp.ReplicationTransmitter;
+import org.apache.commons.logging.impl.LogFactoryImpl;
+/**
+ * Shared whiteboard, each new instance joins the same group. Each instance chooses a random color,
+ * mouse moves are broadcast to all group members, which then apply them to their canvas<p>
+ * @author Bela Ban, Oct 17 2001
+ */
+public class Draw extends ChannelInterceptorBase implements ActionListener {
+    static LogFactoryImpl dependencyhack = new LogFactoryImpl();
+    static org.apache.commons.logging.impl.SimpleLog depHack2 = new org.apache.commons.logging.impl.SimpleLog("test");
+    
+    private final ByteArrayOutputStream out = new ByteArrayOutputStream();
+    String groupname = "DrawGroupDemo";
+    private GroupChannel channel = null;
+    private int member_size = 1;
+    final boolean first = true;
+    final boolean cummulative = true;
+    private JFrame mainFrame = null;
+    private JPanel sub_panel = null;
+    private DrawPanel panel = null;
+    private JButton clear_button, leave_button;
+    private final Random random = new Random(System.currentTimeMillis());
+    private final Font default_font = new Font("Helvetica", Font.PLAIN, 12);
+    private final Color draw_color = selectColor();
+    private final Color background_color = Color.white;
+    boolean no_channel = false;
+    boolean jmx;
+
+    public Draw(int port, boolean debug, boolean cummulative, boolean no_channel, boolean jmx) throws Exception {
+        this.no_channel = no_channel;
+        this.jmx = jmx;
+        if (no_channel)
+            return;
+
+        ReplicationListener rl = new ReplicationListener();
+        rl.setTcpListenAddress("auto");
+        rl.setTcpListenPort(port);
+        rl.setTcpSelectorTimeout(100);
+        rl.setTcpThreadCount(4);
+        rl.getBind();
+        
+        ReplicationTransmitter ps = new ReplicationTransmitter();
+        ps.setReplicationMode("pooled");
+        ps.setAckTimeout(15000);
+        ps.setAutoConnect(true);
+        ps.setCompress(false);
+        
+        McastService service = new McastService();
+        service.setMcastAddr("228.0.0.5");
+        service.setMcastFrequency(500);
+        service.setMcastDropTime(5000);
+        service.setMcastPort(45565);
+        service.setLocalMemberProperties(rl.getHost(),port);
+        
+        channel = new GroupChannel();
+        channel.setClusterReceiver(rl);
+        channel.setClusterSender(ps);
+        channel.setMembershipService(service);
+        channel.start(channel.DEFAULT);
+        
+        channel.addInterceptor(this);
+
+        if (debug) {
+        }
+    }
+
+    public String getGroupName() {
+        return groupname;
+    }
+
+    public void setGroupName(String groupname) {
+        if (groupname != null)
+            this.groupname = groupname;
+    }
+
+    public static void main(String[] args) {
+        Draw draw = null;
+        int port = 4000;
+        boolean debug = false;
+        boolean cummulative = false;
+        boolean no_channel = false;
+        boolean jmx = false;
+        String group_name = null;
+
+        for (int i = 0; i < args.length; i++) {
+            if ("-help".equals(args[i])) {
+                help();
+                return;
+            }
+            if ("-debug".equals(args[i])) {
+                debug = true;
+                continue;
+            }
+            if ("-cummulative".equals(args[i])) {
+                cummulative = true;
+                continue;
+            }
+            if ("-port".equals(args[i])) {
+                port = Integer.parseInt(args[++i]);
+                continue;
+            }
+            if ("-no_channel".equals(args[i])) {
+                no_channel = true;
+                continue;
+            }
+            if ("-jmx".equals(args[i])) {
+                jmx = true;
+                continue;
+            }
+            if ("-groupname".equals(args[i])) {
+                group_name = args[++i];
+                continue;
+            }
+
+            help();
+            return;
+        }
+
+        try {
+            draw = new Draw(port, debug, cummulative, no_channel, jmx);
+            if (group_name != null)
+                draw.setGroupName(group_name);
+            draw.go();
+        } catch (Throwable e) {
+            e.printStackTrace();
+            System.exit(0);
+        }
+    }
+
+    static void help() {
+        System.out.println("\nDraw [-help] [-debug] [-cummulative] [-no_channel] [-props <protocol stack definition>]" +
+                           " [-groupname <name>]");
+        System.out.println("-debug: brings up a visual debugger");
+        System.out.println("-no_channel: doesn't use JGroups at all, any drawing will be relected on the " +
+                           "whiteboard directly");
+        System.out.println("-props: argument can be an old-style protocol stack specification, or it can be " +
+                           "a URL. In the latter case, the protocol specification will be read from the URL\n");
+    }
+
+    private Color selectColor() {
+        int red = (Math.abs(random.nextInt()) % 255);
+        int green = (Math.abs(random.nextInt()) % 255);
+        int blue = (Math.abs(random.nextInt()) % 255);
+        return new Color(red, green, blue);
+    }
+
+    public void go() throws Exception {
+        mainFrame = new JFrame();
+        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        panel = new DrawPanel(this);
+        panel.setBackground(background_color);
+        sub_panel = new JPanel();
+        mainFrame.getContentPane().add("Center", panel);
+        clear_button = new JButton("Clear");
+        clear_button.setFont(default_font);
+        clear_button.addActionListener(this);
+        leave_button = new JButton("Leave & Exit");
+        leave_button.setFont(default_font);
+        leave_button.addActionListener(this);
+        sub_panel.add("South", clear_button);
+        sub_panel.add("South", leave_button);
+        mainFrame.getContentPane().add("South", sub_panel);
+        mainFrame.setBackground(background_color);
+        clear_button.setForeground(Color.blue);
+        leave_button.setForeground(Color.blue);
+        setTitle();
+        mainFrame.pack();
+        mainFrame.setLocation(15, 25);
+        mainFrame.setBounds(new Rectangle(250, 250));
+        mainFrame.setVisible(true);
+        
+    }
+
+    void setTitle(String title) {
+        String tmp = "";
+        if (no_channel) {
+            mainFrame.setTitle(" Draw Demo ");
+            return;
+        }
+        if (title != null) {
+            mainFrame.setTitle(title);
+        } else {
+            if (channel.getMembershipService().getLocalMember() != null)
+                tmp += channel.getMembershipService().getLocalMember().getName();
+            tmp += " (" + channel.getMembershipService().getMembers().length + ")";
+            mainFrame.setTitle(tmp);
+        }
+    }
+
+    void setTitle() {
+        setTitle(null);
+    }
+
+    
+
+    /* --------------- Callbacks --------------- */
+
+
+
+    public void clearPanel() {
+        if (panel != null)
+            panel.clear();
+    }
+    
+    public DrawMessage getEmptyMessage() {
+        DrawMessage msg = new DrawMessage();
+        msg.setAddress(channel.getMembershipService().getLocalMember());
+        msg.setTimestamp(System.currentTimeMillis());
+        msg.setCompress(0);
+        return msg;
+    }
+
+    public void sendClearPanelMsg() {
+        int tmp[] = new int[1];
+        tmp[0] = 0;
+        DrawCommand comm = new DrawCommand(DrawCommand.CLEAR);
+        ObjectOutputStream os;
+
+        try {
+            out.reset();
+            os = new ObjectOutputStream(out);
+            os.writeObject(comm);
+            os.flush();
+            DrawMessage msg = this.getEmptyMessage();
+            msg.setDrawCommand(comm);
+            channel.send(null,msg,0);
+            //draw on the local picture
+            messageReceived(msg);
+        } catch (Exception ex) {
+            System.err.println(ex);
+        }
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        String command = e.getActionCommand();
+        if ("Clear".equals(command)) {
+            if (no_channel) {
+                clearPanel();
+                return;
+            }
+            sendClearPanelMsg();
+        } else if ("Leave & Exit".equals(command)) {
+            if (!no_channel) {
+                try {
+                    channel.stop(channel.DEFAULT);
+                } catch (Exception ex) {
+                    System.err.println(ex);
+                }
+            }
+            mainFrame.setVisible(false);
+            mainFrame.dispose();
+            System.exit(0);
+        } else
+            System.out.println("Unknown action");
+    }
+
+    /* ------------------------------ ChannelListener interface -------------------------- */
+
+    
+
+    public void memberAdded(Member addr) {
+        setTitle();
+    }
+
+    public void memberDisappeared(Member addr) {
+        setTitle();
+    }
+    
+    public void messageReceived(ClusterMessage msg) { 
+        if ( msg instanceof DrawMessage ) {
+            DrawMessage dmsg = (DrawMessage)msg;
+            DrawCommand comm = dmsg.getDrawCommand();
+            switch (comm.mode) {
+                case DrawCommand.DRAW:
+                    if (panel != null)
+                        panel.drawPoint(comm);
+                    break;
+                case DrawCommand.CLEAR:
+                    clearPanel();
+                    break;
+                default:
+                    System.err.println("***** Draw.run(): received invalid draw command " + comm.mode);
+                    break;
+            }
+        } else {
+            System.out.println("Invalid message="+msg);
+        }
+    }
+    
+    
+    public static class DrawMessage implements ClusterMessage {
+        private Member address;
+        private long timestamp;
+        private String id;
+        private int resend;
+        private int compress;
+        private DrawCommand comm;
+        public Member getAddress() { return address;}
+        public void setAddress(Member member) { address = member;}
+        public long getTimestamp() { return timestamp;}
+        public void setTimestamp(long timestamp) {this.timestamp = timestamp;}
+        public String getUniqueId() {return id;}
+        public int getResend() { return resend;}
+        public void setResend(int resend) {this.resend = resend;}
+        public int getCompress() {return compress;}
+        public void setCompress(int compress) {this.compress = compress;}
+        public DrawCommand getDrawCommand(){return comm;}
+        public void setDrawCommand(DrawCommand command) {this.comm = command;}
+
+    }
+    /* --------------------------- End of ChannelListener interface ---------------------- */
+
+
+
+    private class DrawPanel
+        extends JPanel implements MouseMotionListener {
+        final Dimension preferred_size = new Dimension(235, 170);
+        Image img = null; // for drawing pixels
+        Dimension d, imgsize;
+        Graphics gr = null;
+        Draw parent;
+        public DrawPanel(Draw parent) {
+            this.parent = parent;
+            createOffscreenImage();
+            addMouseMotionListener(this);
+            addComponentListener(new ComponentAdapter() {
+                public void componentResized(ComponentEvent e) {
+                    if (getWidth() <= 0 || getHeight() <= 0)return;
+                    createOffscreenImage();
+                }
+            });
+        }
+
+        void createOffscreenImage() {
+            d = getSize();
+            if (img == null || imgsize == null || imgsize.width != d.width || imgsize.height != d.height) {
+                img = createImage(d.width, d.height);
+                if (img != null)
+                    gr = img.getGraphics();
+                imgsize = d;
+            }
+        }
+
+        /* ---------------------- MouseMotionListener interface------------------------- */
+
+        public void mouseMoved(MouseEvent e) {}
+
+        public void mouseDragged(MouseEvent e) {
+            ObjectOutputStream os;
+            int x = e.getX(), y = e.getY();
+            DrawCommand comm = new DrawCommand(DrawCommand.DRAW, x, y,
+                                               draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue());
+
+            if (no_channel) {
+                drawPoint(comm);
+                return;
+            }
+
+            try {
+                out.reset();
+                os = new ObjectOutputStream(out);
+                os.writeObject(comm);
+                os.flush();
+                DrawMessage msg = parent.getEmptyMessage();
+                msg.setDrawCommand(comm);
+                channel.send(null,msg,0);
+                parent.messageReceived(msg);
+                Thread.yield(); // gives the repainter some breath
+            } catch (Exception ex) {
+                System.err.println(ex);
+            }
+        }
+
+        /* ------------------- End of MouseMotionListener interface --------------------- */
+
+
+        /**
+         * Adds pixel to queue and calls repaint() whenever we have MAX_ITEMS pixels in the queue
+         * or when MAX_TIME msecs have elapsed (whichever comes first). The advantage compared to just calling
+         * repaint() after adding a pixel to the queue is that repaint() can most often draw multiple points
+         * at the same time.
+         */
+        public void drawPoint(DrawCommand c) {
+            if (c == null || gr == null)return;
+            gr.setColor(new Color(c.r, c.g, c.b));
+            gr.fillOval(c.x, c.y, 10, 10);
+            repaint();
+        }
+
+        public void clear() {
+            if (gr == null)return;
+            gr.clearRect(0, 0, getSize().width, getSize().height);
+            repaint();
+        }
+
+        public Dimension getPreferredSize() {
+            return preferred_size;
+        }
+
+        public void paintComponent(Graphics g) {
+            super.paintComponent(g);
+            if (img != null) {
+                g.drawImage(img, 0, 0, null);
+            }
+        }
+
+    }
+
+    public static class DrawCommand
+        implements Serializable {
+        static final int DRAW = 1;
+        static final int CLEAR = 2;
+        final int mode;
+        int x = 0;
+        int y = 0;
+        int r = 0;
+        int g = 0;
+        int b = 0;
+
+        DrawCommand(int mode) {
+            this.mode = mode;
+        }
+
+        DrawCommand(int mode, int x, int y, int r, int g, int b) {
+            this.mode = mode;
+            this.x = x;
+            this.y = y;
+            this.r = r;
+            this.g = g;
+            this.b = b;
+        }
+
+        DrawCommand Copy() {
+            return new DrawCommand(mode, x, y, r, g, b);
+        }
+
+        public String toString() {
+            StringBuffer ret = new StringBuffer();
+            switch (mode) {
+                case DRAW:
+                    ret.append("DRAW(" + x + ", " + y + ") [" + r + '|' + g + '|' + b + ']');
+                    break;
+                case CLEAR:
+                    ret.append("CLEAR");
+                    break;
+                default:
+                    return "<undefined>";
+            }
+            return ret.toString();
+        }
+
+    }
+
+}
+



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message