You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2007/02/24 17:04:25 UTC

svn commit: r511289 [1/2] - in /webservices/axis2/trunk/java: etc/ modules/clustering/ modules/clustering/conf/ modules/clustering/src/ modules/clustering/src/org/ modules/clustering/src/org/apache/ modules/clustering/src/org/apache/axis2/ modules/clus...

Author: chamikara
Date: Sat Feb 24 08:04:23 2007
New Revision: 511289

URL: http://svn.apache.org/viewvc?view=rev&rev=511289
Log:
Core for the clustering module - From the branch (https://svn.apache.org/repos/asf/webservices/axis2/branches/java/clustering).

This includes
------------- 
The ClusterManager interface
Changes to the kernel to notify the ClusterManager when certain events happen.
The clustering module which currently contain the Tribes based implementation of the ClsuterManager.

Added:
    webservices/axis2/trunk/java/modules/clustering/
    webservices/axis2/trunk/java/modules/clustering/conf/
    webservices/axis2/trunk/java/modules/clustering/maven.xml
    webservices/axis2/trunk/java/modules/clustering/pom.xml
    webservices/axis2/trunk/java/modules/clustering/project.properties
    webservices/axis2/trunk/java/modules/clustering/project.xml
    webservices/axis2/trunk/java/modules/clustering/src/
    webservices/axis2/trunk/java/modules/clustering/src/org/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/handlers/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/handlers/ReplicationHandler.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/CommandType.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextManager.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextType.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesChannelInfo.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesMemberInfo.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesCommandMessage.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesInfoWebService.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesMapEntryMessage.java
    webservices/axis2/trunk/java/modules/clustering/test/
    webservices/axis2/trunk/java/modules/clustering/test/org/
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ClusterManagerTestCase.java
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ManageContextTestCase.java
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/UpdateStateTestCase.java
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/ManageContextTest.java
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/UpdateStateTest.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java
Modified:
    webservices/axis2/trunk/java/etc/project.properties
    webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ServiceContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ServiceGroupContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/SessionContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java

Modified: webservices/axis2/trunk/java/etc/project.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/etc/project.properties?view=diff&rev=511289&r1=511288&r2=511289
==============================================================================
--- webservices/axis2/trunk/java/etc/project.properties (original)
+++ webservices/axis2/trunk/java/etc/project.properties Sat Feb 24 08:04:23 2007
@@ -71,7 +71,8 @@
 modules/jaxbri/project.xml,\
 modules/jaxws/project.xml,\
 modules/jaxws-api/project.xml,\
-modules/json/project.xml
+modules/json/project.xml\
+modules/clustering/project.xml
 
 # -------------------------------------------------------------------
 #                JUnit
@@ -134,6 +135,8 @@
 xmlunit.version=1.0
 log4j.version=1.2.13
 jettison.version=1.0-alpha-2-SNAPSHOT
+tomcat.tribes.version=6.0.8
+tomcat.juli.version=6.0.8
 
 # ------------------------------------------------------------------------
 # M A V E N  J A R  O V E R R I D E

Added: webservices/axis2/trunk/java/modules/clustering/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/maven.xml?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/maven.xml (added)
+++ webservices/axis2/trunk/java/modules/clustering/maven.xml Sat Feb 24 08:04:23 2007
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project default="jar"
+    xmlns:j="jelly:core"
+    xmlns:u="jelly:util"
+    xmlns:maven="jelly:maven"
+    xmlns:deploy="deploy"
+    xmlns:ant="jelly:ant">
+    
+    <preGoal name="itest:compile">
+        <u:file var="file" name="${maven.itest.src}"/>
+        <j:if test="${!file.exists()}">
+            <j:expr value="${context.setVariable('maven.itest.skip', 'true')}"/>
+        </j:if>
+    </preGoal>
+    
+</project>

Added: webservices/axis2/trunk/java/modules/clustering/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/pom.xml?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/pom.xml (added)
+++ webservices/axis2/trunk/java/modules/clustering/pom.xml Sat Feb 24 08:04:23 2007
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ !
+ ! Copyright 2006 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.
+ !-->
+<project
+    xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.axis2</groupId>
+    <artifactId>axis2-parent</artifactId>
+    <version>SNAPSHOT</version>
+    <relativePath>../parent/pom.xml</relativePath>    
+  </parent>
+
+  <artifactId>axis2-clustering</artifactId>
+  <name>Apache Axis 2.0 - Clustering</name>
+  <description>Axis2 Clustering module</description>
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/clustering</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/clustering</developerConnection>
+    <url>http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering</url>
+  </scm>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.axis2</groupId>
+      <artifactId>axis2-kernel</artifactId>
+		<version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat.tribes</groupId>
+      <artifactId>tribes</artifactId>
+		<version>${tomcat.tribes.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat.juli</groupId>
+      <artifactId>juli</artifactId>
+		<version>${tomcat.juli.version}</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <sourceDirectory>src</sourceDirectory>
+    <testSourceDirectory>test</testSourceDirectory>
+    <resources>
+      <resource>
+        <directory>conf</directory>
+        <excludes>
+          <exclude>**/*.properties</exclude>
+        </excludes>
+        <filtering>false</filtering>
+      </resource>
+      <resource>
+        <directory>src</directory>
+        <excludes>
+          <exclude>**/*.java</exclude>
+        </excludes>
+      </resource>
+    </resources>
+  </build>
+</project>

Added: webservices/axis2/trunk/java/modules/clustering/project.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/project.properties?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/project.properties (added)
+++ webservices/axis2/trunk/java/modules/clustering/project.properties Sat Feb 24 08:04:23 2007
@@ -0,0 +1,38 @@
+# -------------------------------------------------------------------
+# Copyright 2001-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.
+# -------------------------------------------------------------------
+
+maven.multiproject.type=jar
+
+# -------------------------------------------------------------------
+#                JUnit
+# -------------------------------------------------------------------
+maven.junit.jvmargs=-Xmx256m -Djava.awt.headless=true -Dbuild.repository=./target/test-classes
+maven.junit.fork=true
+
+# -------------------------------------------------------------------
+#                Test
+# -------------------------------------------------------------------
+#maven.test.failure.ignore=true
+
+# -------------------------------------------------------------------
+#                Compile
+# -------------------------------------------------------------------
+maven.compile.optimize=false
+maven.compile.fork=true
+maven.compile.target=1.5
+maven.compile.source=1.5
+
+jaxws.version=${pom.currentVersion}

Added: webservices/axis2/trunk/java/modules/clustering/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/project.xml?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/project.xml (added)
+++ webservices/axis2/trunk/java/modules/clustering/project.xml Sat Feb 24 08:04:23 2007
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * Copyright 2001-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.
+ */
+ -->
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>../../etc/project.xml</extend>
+
+    <name>Apache Axis 2.0 - Cluster</name>
+    <id>axis2-cluster</id>
+    <groupId>org.apache.axis2</groupId>
+    <description>Clustering Support for Axis 2.0</description>
+
+    <dependencies>
+
+       <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-api</artifactId>
+            <version>${axiom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-impl</artifactId>
+            <version>${axiom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-kernel</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+         <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-adb</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>        
+        <!-- external JARs -->
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons.logging.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+	  <!-- added for the QName -->	
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+            <version>${stax.api.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>${stax.impl.groupid}</groupId>
+            <artifactId>${stax.impl.artifactid}</artifactId>
+            <version>${stax.impl.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>${commons.httpclient.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>wsdl4j</groupId>
+            <artifactId>wsdl4j</artifactId>
+            <version>${wsdl4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-java2wsdl</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.schema</groupId>
+            <artifactId>XmlSchema</artifactId>
+            <version>${XmlSchema.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>annogen</groupId>
+            <artifactId>annogen</artifactId>
+            <version>${annogen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+        <groupId>org.apache.tomcat.juli</groupId>
+            <artifactId>juli</artifactId>
+             <version>${tomcat.juli.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>       
+        <dependency>
+            <groupId>org.apache.tomcat.tribes</groupId>
+            <artifactId>tribes</artifactId>
+             <version>${tomcat.tribes.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>   
+    </dependencies>
+    <build/>
+    <reports/>
+</project>

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/handlers/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/handlers/ReplicationHandler.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/handlers/ReplicationHandler.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/handlers/ReplicationHandler.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,67 @@
+/*
+ * Copyright 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.axis2.cluster.handlers;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.handlers.AbstractHandler;
+
+public class ReplicationHandler extends AbstractHandler {
+
+	public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+		replicateState(msgContext);
+
+		return InvocationResponse.CONTINUE;
+	}
+
+	public void flowComplete(MessageContext msgContext) {
+		super.flowComplete(msgContext);
+
+		replicateState(msgContext);
+	}
+
+	private void replicateState(MessageContext message) {
+
+		ConfigurationContext configurationContext = message.getConfigurationContext();
+		AxisConfiguration axisConfiguration = configurationContext.getAxisConfiguration();
+		ClusterManager clusterManager = axisConfiguration.getClusterManager();
+
+		if (clusterManager != null) {
+			ServiceContext serviceContext = message.getServiceContext();
+			ServiceGroupContext serviceGroupContext = message.getServiceGroupContext();
+
+			clusterManager.updateState(configurationContext);
+
+			if (serviceGroupContext != null) {
+				clusterManager.updateState(serviceGroupContext);
+			}
+
+			if (serviceContext != null) {
+				clusterManager.updateState(serviceContext);
+			}
+
+		}
+
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/CommandType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/CommandType.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/CommandType.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/CommandType.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,33 @@
+/*
+ * Copyright 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.axis2.cluster.tribes;
+
+public interface CommandType {
+	
+	public static String CREATE_SERVICE_CONTEXT = "CREATE_SERVICE_CONTEXT";
+	
+	public static String CREATE_SERVICE_GROUP_CONTEXT = "CREATE_SERVICE_GROUP_CONTEXT";
+
+	public static String REMOVE_SERVICE_CONTEXT = "REMOVE_SERVICE_CONTEXT";
+	
+	public static String REMOVE_SERVICE_GROUP_CONTEXT = "REMOVE_SERVICE_GROUP_CONTEXT";
+	
+	public static String UPDATE_STATE = "UPDATE_STATE";
+	
+	public static String UPDATE_STATE_MAP_ENTRY = "UPDATE_STATE_MAP_ENTRY";
+	
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextManager.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextManager.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextManager.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,259 @@
+/*
+ * Copyright 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.axis2.cluster.tribes;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.catalina.tribes.Channel;
+
+public class ContextManager {
+
+	private Channel channel;
+
+	private long timeout = 1000;
+
+	private ClassLoader classLoader;
+
+	private Map<String, HashMap> serviceCtxProps = new HashMap<String, HashMap>();
+
+	private Map<String, HashMap> serviceGrpCtxProps = new HashMap<String, HashMap>();
+
+	public ContextManager(Channel channel, long timeout, ClassLoader classLoader) {
+		this.channel = channel;
+		this.timeout = timeout;
+		this.classLoader = classLoader;
+	}
+
+	public void addServiceContext(String parentId, String serviceCtxName) {
+		String key = parentId + "_" + serviceCtxName;
+		/*
+		 * serviceCtxProps.put(key,new ReplicatedMap(this, channel, timeout,
+		 * key, new ClassLoader[]{classLoader} ));
+		 */
+
+		serviceCtxProps.put(key, new HashMap());
+	}
+
+	public void addServiceGroupContext(String groupId) {
+		String key = groupId;
+		/*
+		 * serviceGrpCtxProps.put(key,new ReplicatedMap(this, channel, timeout,
+		 * key, new ClassLoader[]{classLoader} ));
+		 */
+		serviceGrpCtxProps.put(key, new HashMap());
+	}
+
+	public void removeServiceContext(String parentId, String serviceCtxName) {
+		String key = parentId + "_" + serviceCtxName;
+		HashMap map = (HashMap) serviceCtxProps.get(key);
+		// map.breakdown();
+		serviceCtxProps.remove(key);
+	}
+
+	public void removeServiceGroupContext(String groupId) {
+		String key = groupId;
+		HashMap map = (HashMap) serviceGrpCtxProps.get(key);
+		// map.breakdown();
+		serviceGrpCtxProps.remove(key);
+	}
+
+	public void addPropToServiceContext(String parentId, String serviceCtxName,
+			String propName, Object value) {
+		String key = parentId + "_" + serviceCtxName;
+		HashMap map = (HashMap) serviceCtxProps.get(key);
+		map.put(propName, value);
+	}
+
+	public void addPropToServiceGroupContext(String groupId, String propName,
+			Object value) {
+		String key = groupId;
+		HashMap map = (HashMap) serviceGrpCtxProps.get(key);
+		map.put(propName, value);
+	}
+
+	public void removePropFromServiceContext(String parentId,
+			String serviceCtxName, String propName) {
+		String key = parentId + "_" + serviceCtxName;
+		HashMap map = (HashMap) serviceCtxProps.get(key);
+		map.remove(propName);
+	}
+
+	public void removePropFromServiceGroupContext(String groupId,
+			String propName) {
+		String key = groupId;
+		HashMap map = (HashMap) serviceGrpCtxProps.get(key);
+		map.remove(propName);
+	}
+
+	public void updatePropOnServiceContext(String parentId,
+			String serviceCtxName, String propName, Object value) {
+		String key = parentId + "_" + serviceCtxName;
+		HashMap map = (HashMap) serviceCtxProps.get(key);
+		map.put(propName, value);
+	}
+
+	public void updatePropOnServiceGroupContext(String groupId,
+			String propName, Object value) {
+		String key = groupId;
+		HashMap map = (HashMap) serviceGrpCtxProps.get(key);
+		map.put(propName, value);
+	}
+
+	public Map getServiceGroupProps(String groupId) {
+		return serviceGrpCtxProps.get(groupId);
+	}
+
+	public Map getServiceProps(String parentId, String serviceCtxName) {
+		String key = parentId + "_" + serviceCtxName;
+		return serviceCtxProps.get(key);
+	}
+
+	public List updateStateOnServiceContext(String parentId,
+			String serviceCtxName, Map<String, ?> newProps) {
+		String key = parentId + "_" + serviceCtxName;
+		HashMap oldProps = (HashMap) serviceCtxProps.get(key);
+		if (oldProps == null) {
+			oldProps = new HashMap();
+			serviceCtxProps.put(key, oldProps);
+		}
+
+		List<TribesMapEntryMessage> commandList = new ArrayList<TribesMapEntryMessage>();
+
+		try {
+			// using set operations to figure out the diffs
+
+			// figuring out entries to remove
+			Set<String> diffForRemove = new HashSet<String>();
+			diffForRemove.addAll(oldProps.keySet());
+			diffForRemove.removeAll(newProps.keySet());
+
+			// figuring out new entires
+			Set<String> diffForAddOrUpdate = new HashSet<String>();
+			diffForAddOrUpdate.addAll(newProps.keySet());
+			diffForAddOrUpdate.removeAll(oldProps.keySet());
+
+			// figuring out entries to update
+			for (String paramKey : newProps.keySet()) {
+				Object oldValue = oldProps.get(paramKey);
+				Object newValue = newProps.get(paramKey);
+
+				if (oldValue != null && !oldValue.equals(newValue)) {
+					diffForAddOrUpdate.add(paramKey);
+				}
+			}
+
+			for (String paramKey : diffForAddOrUpdate) {
+				Object value = newProps.get(paramKey);
+				if (value instanceof Serializable) {
+					oldProps.put(paramKey, value);
+					commandList.add(new TribesMapEntryMessage(
+							CommandType.UPDATE_STATE_MAP_ENTRY, parentId,
+							serviceCtxName, serviceCtxName, paramKey,
+							(Serializable) value,
+							TribesMapEntryMessage.SERVICE_CONTEXT,
+							TribesMapEntryMessage.ADD_OR_UPDATE_ENTRY));
+					// oldProps.replicate(paramKey, true);
+				}
+			}
+
+			for (String paramKey : diffForRemove) {
+				oldProps.remove(paramKey);
+				commandList.add(new TribesMapEntryMessage(
+						CommandType.UPDATE_STATE_MAP_ENTRY, parentId,
+						serviceCtxName, serviceCtxName, paramKey, "",
+						TribesMapEntryMessage.SERVICE_CONTEXT,
+						TribesMapEntryMessage.REMOVE_ENTRY));
+
+				// oldProps.replicate(paramKey, true);
+			}
+		} catch (RuntimeException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return commandList;
+	}
+
+	@SuppressWarnings("unchecked")
+	public List updateStateOnServiceGroupContext(String ctxId,
+			Map<String, ?> newProps) {
+		HashMap oldProps = (HashMap) serviceGrpCtxProps.get(ctxId);
+		if (oldProps == null) {
+			oldProps = new HashMap();
+			serviceCtxProps.put(ctxId, oldProps);
+		}
+
+		List<TribesMapEntryMessage> commandList = new ArrayList<TribesMapEntryMessage>();
+
+		try {
+			// using set operations to figure out the diffs
+
+			// figuring out entries to remove
+			Set<String> diffForRemove = new HashSet<String>();
+			diffForRemove.addAll(oldProps.keySet());
+			diffForRemove.removeAll(newProps.keySet());
+
+			// figuring out entries to update
+			Set<String> diffForAddOrUpdate = new HashSet<String>();
+			diffForAddOrUpdate.addAll(newProps.keySet());
+			diffForAddOrUpdate.removeAll(oldProps.keySet());
+
+			// figuring out entries to update
+			for (String paramKey : newProps.keySet()) {
+				Object oldValue = oldProps.get(paramKey);
+				Object newValue = newProps.get(paramKey);
+
+				if (oldValue != null && !oldValue.equals(newValue)) {
+					diffForAddOrUpdate.add(paramKey);
+				}
+			}
+
+			for (String paramKey : diffForAddOrUpdate) {
+				Object value = newProps.get(paramKey);
+				if (value instanceof Serializable) {
+					oldProps.put(paramKey, value);
+					commandList.add(new TribesMapEntryMessage(
+							CommandType.UPDATE_STATE_MAP_ENTRY, "", ctxId,
+							ctxId, paramKey, (Serializable) value,
+							TribesMapEntryMessage.SERVICE_GROUP_CONTEXT,
+							TribesMapEntryMessage.ADD_OR_UPDATE_ENTRY));
+					// oldProps.replicate(paramKey, true); //
+					// map.replicate(true) will replicate all
+				}
+			}
+
+			for (String paramKey : diffForRemove) {
+				commandList.add(new TribesMapEntryMessage(
+						CommandType.UPDATE_STATE_MAP_ENTRY, "", ctxId, ctxId,
+						paramKey, "",
+						TribesMapEntryMessage.SERVICE_GROUP_CONTEXT,
+						TribesMapEntryMessage.REMOVE_ENTRY));
+				// oldProps.remove(paramKey);
+			}
+		} catch (RuntimeException e) {
+			e.printStackTrace();
+		}
+
+		return commandList;
+	}
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextType.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextType.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextType.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,25 @@
+/*
+ * Copyright 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.axis2.cluster.tribes;
+
+public class ContextType {
+
+	public static int CONFIGURATION_CONTEXT = 1;
+	public static int SERVICE_GROUP_CONTEXT = 2;
+	public static int SERVICE_CONTEXT = 3;
+	
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesChannelInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesChannelInfo.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesChannelInfo.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesChannelInfo.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,92 @@
+/*
+ * Copyright 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.axis2.cluster.tribes;
+
+import java.io.Serializable;
+
+import org.apache.catalina.tribes.ChannelListener;
+import org.apache.catalina.tribes.Member;
+
+public class TransientTribesChannelInfo implements ChannelListener {
+
+	private long messageCount = 0;
+
+	private long grpCtxCreationCount = 0;
+
+	private long srvCtxCreationCount = 0;
+
+	private long grpCtxRemoveCount = 0;
+
+	private long srvCtxRemoveCount = 0;
+
+	private long updateStateCount = 0;
+
+	public boolean accept(Serializable msg, Member sender) {
+		return msg instanceof String;
+	}
+
+	public void messageReceived(Serializable msg, Member sender) {
+		messageCount++;
+
+		System.out.println("Tribes message " + msg);
+
+		if (msg instanceof TribesCommandMessage) {
+			TribesCommandMessage comMsg = (TribesCommandMessage) msg;
+
+			if (comMsg.getCommandName().equals(
+					CommandType.CREATE_SERVICE_GROUP_CONTEXT)) {
+				grpCtxCreationCount++;
+			} else if (comMsg.getCommandName().equals(
+					CommandType.CREATE_SERVICE_CONTEXT)) {
+				srvCtxCreationCount++;
+			} else if (comMsg.getCommandName().equals(
+					CommandType.REMOVE_SERVICE_GROUP_CONTEXT)) {
+				grpCtxRemoveCount++;
+			} else if (comMsg.getCommandName().equals(
+					CommandType.REMOVE_SERVICE_CONTEXT)) {
+				srvCtxRemoveCount++;
+			} else if (comMsg.getCommandName().equals(CommandType.UPDATE_STATE)) {
+				updateStateCount++;
+			}
+		}
+	}
+
+	public long getGrpCtxCreationCount() {
+		return grpCtxCreationCount;
+	}
+
+	public long getGrpCtxRemoveCount() {
+		return grpCtxRemoveCount;
+	}
+
+	public long getMessageCount() {
+		return messageCount;
+	}
+
+	public long getSrvCtxCreationCount() {
+		return srvCtxCreationCount;
+	}
+
+	public long getSrvCtxRemoveCount() {
+		return srvCtxRemoveCount;
+	}
+
+	public long getUpdateStateCount() {
+		return updateStateCount;
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesMemberInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesMemberInfo.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesMemberInfo.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesMemberInfo.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,48 @@
+/*
+ * Copyright 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.axis2.cluster.tribes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.MembershipListener;
+
+public class TransientTribesMemberInfo implements MembershipListener {
+
+	private List<Member> liveNodes = new ArrayList<Member>();
+
+	private List<Member> deadNodes = new ArrayList<Member>();
+
+	public void memberAdded(Member member) {
+		liveNodes.add(member);
+		deadNodes.remove(member);
+	}
+
+	public void memberDisappeared(Member member) {
+		liveNodes.remove(member);
+		deadNodes.add(member);
+	}
+
+	public List<Member> getLiveNodes() {
+		return liveNodes;
+	}
+
+	public List<Member> getDeadNodes() {
+		return deadNodes;
+	}
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,403 @@
+/*
+ * Copyright 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.axis2.cluster.tribes;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.context.AbstractContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.ChannelListener;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.group.GroupChannel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class TribesClusterManager implements ClusterManager, ChannelListener {
+
+	private static final Log log = LogFactory.getLog(TribesClusterManager.class);
+
+	private ConfigurationContext configContext;
+
+	private Channel channel;
+
+	private ContextManager ctxManager;
+
+	private long timeout = 1000L; // this should be configured in the axis2.xml
+
+	private Map<String, List> orphanedServiceCtxs = new HashMap<String, List>();
+
+	private Map<String, String> duplicateServiceGrps = new HashMap<String, String>();
+
+	private Map<String, String> duplicateServiceCtxs = new HashMap<String, String>();
+
+	public void init(ConfigurationContext context) {
+		log.debug("initializing tibes");
+
+		this.configContext = context;
+
+		TransientTribesChannelInfo channelInfo = new TransientTribesChannelInfo();
+		TransientTribesMemberInfo memberInfo = new TransientTribesMemberInfo();
+
+		configContext.setProperty("MEMBER_INFO", memberInfo);
+		configContext.setProperty("CHANNEL_INFO", channelInfo);
+
+		channel = new GroupChannel();
+		try {
+			channel.addChannelListener(this);
+			channel.addChannelListener(channelInfo);
+			channel.addMembershipListener(memberInfo);
+			channel.start(Channel.DEFAULT);
+			ctxManager = new ContextManager(channel, timeout, context.getAxisConfiguration()
+					.getSystemClassLoader());
+		} catch (ChannelException e) {
+			log.error("Error starting Tribes channel", e);
+		}
+
+		registerTribesInfoService(configContext);
+	}
+
+	private void registerTribesInfoService(ConfigurationContext configContext2) {
+		try {
+			AxisService service = AxisService.createService(
+					"org.apache.axis2.cluster.tribes.TribesInfoWebService", configContext
+							.getAxisConfiguration(), RPCMessageReceiver.class);
+
+			configContext.getAxisConfiguration().addService(service);
+		} catch (AxisFault e) {
+			log.error("Unable to create Tribes info web service", e);
+		}
+	}
+
+	public void addContext(AbstractContext context) {
+		TribesCommandMessage comMsg = null;
+
+		String contextId = getContextID(context);
+		String parentContextId = getContextID(context.getParent());
+
+		// The ServiceContex does not define a contextId
+		// therefore the service name is used
+		if (context instanceof ServiceContext) {
+
+			if (duplicateServiceCtxs.get(parentContextId + contextId) != null) {
+				return; // this is a duplicate replication request
+			}
+
+			if (ctxManager.getServiceGroupProps(parentContextId) != null) {
+				ctxManager.addServiceContext(parentContextId, contextId);
+				comMsg = new TribesCommandMessage(CommandType.CREATE_SERVICE_CONTEXT,
+						parentContextId, contextId, contextId, ContextType.SERVICE_CONTEXT);
+				send(comMsg);
+			} else {
+				// put in the queue until the service group context is created
+				// with an id
+				comMsg = new TribesCommandMessage(CommandType.CREATE_SERVICE_CONTEXT,
+						parentContextId, contextId, contextId, ContextType.SERVICE_CONTEXT);
+
+				AxisServiceGroup serviceGroupDesc = ((ServiceContext) context)
+						.getServiceGroupContext().getDescription();
+				List<TribesCommandMessage> list = (List) orphanedServiceCtxs.get(serviceGroupDesc
+						.getServiceGroupName());
+				if (list == null) {
+					list = new ArrayList<TribesCommandMessage>();
+					orphanedServiceCtxs.put(serviceGroupDesc.getServiceGroupName(), list);
+				}
+				list.add(comMsg);
+			}
+		} else if (context instanceof ServiceGroupContext) {
+
+			if (duplicateServiceGrps.get(contextId) != null) {
+				return; // this is a duplicate replication request
+			}
+
+			ServiceGroupContext srvGrpCtx = (ServiceGroupContext) context;
+
+			// The new serialization code sets the service group name as it's id initially
+			if (srvGrpCtx.getId().equals(srvGrpCtx.getDescription().getServiceGroupName())) {
+				return;
+			}
+
+			ctxManager.addServiceGroupContext(contextId);
+
+			comMsg = new TribesCommandMessage(CommandType.CREATE_SERVICE_GROUP_CONTEXT, "",
+					contextId, srvGrpCtx.getDescription().getServiceGroupName(),
+					ContextType.SERVICE_GROUP_CONTEXT);
+
+			send(comMsg);
+
+			// now iterate through the list of service contexts and replicate them
+			List<TribesCommandMessage> list = orphanedServiceCtxs.get(srvGrpCtx.getDescription()
+					.getServiceGroupName());
+
+			if (list != null) {
+				for (TribesCommandMessage command : list) {
+					ctxManager.addServiceContext(contextId, command.getContextId());
+					command.setParentId(contextId);
+
+					send(command);
+
+				}
+
+				orphanedServiceCtxs.remove(srvGrpCtx.getDescription().getServiceGroupName());
+			}
+		}
+	}
+
+	/*
+	 * public void addProperty(AbstractContext ctx,String contextId, String
+	 * parentId, String propertyName, Object propertyValue) { if (ctx instanceof
+	 * ServiceContext){ ctxManager.addPropToServiceContext(parentId, contextId,
+	 * propertyName, propertyValue); }else{
+	 * ctxManager.addPropToServiceGroupContext(contextId, propertyName,
+	 * propertyValue); } }
+	 */
+
+	public void removeContext(AbstractContext context) {
+		TribesCommandMessage comMsg = null;
+
+		String contextId = getContextID(context);
+		String parentContextId = getContextID(context.getParent());
+
+		if (context instanceof ServiceContext) {
+			ctxManager.removeServiceContext(parentContextId, contextId);
+			comMsg = new TribesCommandMessage(CommandType.CREATE_SERVICE_GROUP_CONTEXT,
+					parentContextId, contextId, contextId, ContextType.SERVICE_CONTEXT);
+		} else if (context instanceof ServiceGroupContext) {
+			ctxManager.removeServiceGroupContext(contextId);
+			comMsg = new TribesCommandMessage(CommandType.REMOVE_SERVICE_GROUP_CONTEXT, "",
+					contextId, ((ServiceGroupContext) context).getDescription()
+							.getServiceGroupName(), ContextType.SERVICE_CONTEXT);
+		}
+
+		send(comMsg);
+	}
+
+	/*
+	 * public void removeProperty(AbstractContext ctx, String contextId, String
+	 * parentId, String propertyName) { if (ctx instanceof ServiceContext){
+	 * ctxManager.removePropFromServiceContext(parentId, contextId,
+	 * propertyName); }else{
+	 * ctxManager.removePropFromServiceGroupContext(contextId, propertyName); } }
+	 */
+
+	public void updateState(AbstractContext context) {
+
+		String contextId = getContextID(context);
+		String parentContextId = getContextID(context.getParent());
+
+		Map props = context.getProperties();
+
+		List<TribesMapEntryMessage> mapEntryMsgs = null;
+
+		int contextType = 0;
+		if (context instanceof ServiceContext) {
+			contextType = ContextType.SERVICE_CONTEXT;
+			mapEntryMsgs = ctxManager
+					.updateStateOnServiceContext(parentContextId, contextId, props);
+		} else if (context instanceof ServiceGroupContext) {
+			contextType = ContextType.SERVICE_GROUP_CONTEXT;
+			mapEntryMsgs = ctxManager.updateStateOnServiceGroupContext(contextId, props);
+		}
+
+		if (mapEntryMsgs != null) {
+			for (TribesMapEntryMessage msg : mapEntryMsgs) {
+				send(msg);
+			}
+		}
+
+		TribesCommandMessage comMsg = new TribesCommandMessage(CommandType.UPDATE_STATE,
+				parentContextId, contextId, contextId, contextType);
+
+		send(comMsg);
+	}
+
+	public boolean accept(Serializable msg, Member sender) {
+		// return msg instanceof TribesCommandMessage;
+		return true;
+	}
+
+	public void messageReceived(Serializable msg, Member sender) {
+
+		try {
+
+			if (!(msg instanceof TribesCommandMessage)) {
+				return;
+			}
+
+			TribesCommandMessage comMsg = (TribesCommandMessage) msg;
+
+			// TODO make sure to remove from the duplicate lists when remove is
+			// requested for both service group and service contexts
+			// TODO fix this to support scopes other than SOAP Session.
+
+			if (comMsg.getCommandName().equals(CommandType.CREATE_SERVICE_GROUP_CONTEXT)) {
+
+				// add to the duplicate list to prevent cyclic replication
+				duplicateServiceGrps.put(comMsg.getContextId(), comMsg.getContextId());
+				ctxManager.addServiceGroupContext(comMsg.getContextId());
+				AxisServiceGroup axisServiceGroup = configContext.getAxisConfiguration()
+						.getServiceGroup(comMsg.getAxisDescriptionName());
+				ServiceGroupContext ctx = new ServiceGroupContext(configContext, axisServiceGroup);
+				ctx.setId(comMsg.getContextId());
+				configContext.registerServiceGroupContextintoSoapSessionTable(ctx);
+
+			} else if (comMsg.getCommandName().equals(CommandType.CREATE_SERVICE_CONTEXT)) {
+
+				// add to the duplicate list to prevent cyclic replication
+				duplicateServiceCtxs.put(comMsg.getParentId() + comMsg.getContextId(), comMsg
+						.getContextId());
+				ctxManager.addServiceContext(comMsg.getParentId(), comMsg.getContextId());
+				AxisService axisService = configContext.getAxisConfiguration().getService(
+						comMsg.getContextId());
+				ServiceGroupContext srvGrpCtx = configContext.getServiceGroupContext(comMsg
+						.getParentId());
+				// This will create service context if one is not available
+				srvGrpCtx.getServiceContext(axisService);
+
+			} else if (comMsg.getCommandName().equals(CommandType.UPDATE_STATE)) {
+
+				if (comMsg.getContextType() == ContextType.SERVICE_GROUP_CONTEXT) {
+
+					ServiceGroupContext srvGrpCtx = configContext.getServiceGroupContext(comMsg
+							.getContextId());
+					Map props = ctxManager.getServiceGroupProps(comMsg.getContextId());
+
+					if (props != null) {
+						srvGrpCtx.setProperties(props);
+					}
+
+				} else if (comMsg.getContextType() == ContextType.SERVICE_CONTEXT) {
+
+					ServiceGroupContext srvGrpCtx = configContext.getServiceGroupContext(comMsg
+							.getParentId());
+					Iterator iter = srvGrpCtx.getServiceContexts();
+					String serviceCtxName = comMsg.getAxisDescriptionName();
+					ServiceContext serviceContext = null;
+					while (iter.hasNext()) {
+						ServiceContext serviceContext2 = (ServiceContext) iter.next();
+						if (serviceContext2.getName() != null
+								&& serviceContext2.getName().equals(serviceCtxName))
+							serviceContext = serviceContext2;
+					}
+
+					if (serviceContext != null) {
+
+						Map srvProps = ctxManager.getServiceProps(comMsg.getParentId(), comMsg
+								.getContextId());
+
+						if (srvProps != null) {
+							serviceContext.setProperties(srvProps);
+						}
+
+					} else {
+						String message = "Cannot find the ServiceContext with the ID:"
+								+ serviceCtxName;
+						throw new AxisFault(message);
+					}
+
+				}
+
+			} else if (comMsg.getCommandName().equals(CommandType.UPDATE_STATE_MAP_ENTRY)) {
+
+				TribesMapEntryMessage mapEntryMsg = (TribesMapEntryMessage) comMsg;
+				if (mapEntryMsg.getCtxType() == TribesMapEntryMessage.SERVICE_GROUP_CONTEXT) {
+					Map props = ctxManager.getServiceGroupProps(comMsg.getContextId());
+					if (mapEntryMsg.getOperation() == TribesMapEntryMessage.ADD_OR_UPDATE_ENTRY) {
+						props.put(mapEntryMsg.getKey(), mapEntryMsg.getValue());
+					} else {
+						props.remove(mapEntryMsg.getKey());
+					}
+				} else if (mapEntryMsg.getCtxType() == TribesMapEntryMessage.SERVICE_CONTEXT) {
+					Map props = ctxManager.getServiceProps(comMsg.getParentId(), comMsg
+							.getContextId());
+					if (mapEntryMsg.getOperation() == TribesMapEntryMessage.ADD_OR_UPDATE_ENTRY) {
+						props.put(mapEntryMsg.getKey(), mapEntryMsg.getValue());
+					} else {
+						props.remove(mapEntryMsg.getKey());
+					}
+				}
+			}
+
+		} catch (AxisFault e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	private void send(TribesCommandMessage msg) {
+		Member[] group = channel.getMembers();
+		log.debug("Group size " + group.length);
+		// send the message
+
+		for (Member member : group) {
+			printMember(member);
+		}
+
+		try {
+			channel.send(group, msg, 0);
+		} catch (ChannelException e) {
+			log.error("Error sending command message : " + msg, e);
+		}
+	}
+
+	private void printMember(Member member) {
+		member.getUniqueId();
+		log.debug("\n===============================");
+		log.debug("Member Name " + member.getName());
+		log.debug("Member Host" + member.getHost());
+		log.debug("Member Payload" + member.getPayload());
+		log.debug("===============================\n");
+	}
+
+	public boolean isContextClusterable(AbstractContext context) {
+
+		if ((context instanceof ConfigurationContext) || (context instanceof ServiceContext)
+				|| (context instanceof ServiceGroupContext)) {
+			return true;
+		}
+
+		return false;
+	}
+
+	private String getContextID(AbstractContext context) {
+
+		String id = null;
+
+		if (context instanceof ServiceContext) {
+			AxisService axisService = ((ServiceContext) context).getAxisService();
+			return axisService.getName();
+		} else if (context instanceof ServiceGroupContext) {
+			return ((ServiceGroupContext) context).getId();
+		}
+
+		return id;
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesCommandMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesCommandMessage.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesCommandMessage.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesCommandMessage.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,97 @@
+/*
+ * Copyright 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.axis2.cluster.tribes;
+
+import java.io.Serializable;
+
+
+public class TribesCommandMessage implements CommandType, Serializable {
+
+	private String commandName;
+
+	private String parentId;
+
+	private String contextId;
+
+	private String axisDescriptionName;
+
+	private int contextType;
+
+	public TribesCommandMessage() {
+	}
+
+	public TribesCommandMessage(String commandName, String parentId, String contextId,
+			String axisDescriptionName, int contextType) {
+		this.commandName = commandName;
+		this.parentId = parentId;
+		this.contextId = contextId;
+		this.axisDescriptionName = axisDescriptionName;
+		this.contextType = contextType;
+	}
+
+	public String getCommandName() {
+		return commandName;
+	}
+
+	public void setCommandName(String commandName) {
+		this.commandName = commandName;
+	}
+
+	public String getContextId() {
+		return contextId;
+	}
+
+	public void setContextId(String contextId) {
+		this.contextId = contextId;
+	}
+
+	public String getParentId() {
+		return parentId;
+	}
+
+	public void setParentId(String parentId) {
+		this.parentId = parentId;
+	}
+
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("TribesCommandMessage [");
+		builder.append(commandName + ",");
+		builder.append(parentId + ",");
+		builder.append(contextId + ",");
+		builder.append(axisDescriptionName + "]");
+
+		return builder.toString();
+	}
+
+	public String getAxisDescriptionName() {
+		return axisDescriptionName;
+	}
+
+	public void setAxisDescriptionName(String axisDescriptionName) {
+		this.axisDescriptionName = axisDescriptionName;
+	}
+
+	public int getContextType() {
+		return contextType;
+	}
+
+	public void setContextType(int contextType) {
+		this.contextType = contextType;
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesInfoWebService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesInfoWebService.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesInfoWebService.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesInfoWebService.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,126 @@
+/*
+ * Copyright 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.axis2.cluster.tribes;
+
+import java.util.List;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.catalina.tribes.Member;
+
+public class TribesInfoWebService {
+
+	private ServiceContext srvCtx;
+
+	public void init(ServiceContext context) {
+		this.srvCtx = context;
+	}
+
+	public OMElement getMembershipInfo() {
+		ConfigurationContext configCtx = srvCtx.getConfigurationContext();
+		TransientTribesMemberInfo memberInfo = (TransientTribesMemberInfo) configCtx
+				.getProperty("MEMBER_INFO");
+
+		List<Member> liveMembers = memberInfo.getLiveNodes();
+		List<Member> deadMembers = memberInfo.getDeadNodes();
+
+		SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+		OMNamespace omNs = factory.createOMNamespace("http://org.apache.axis2.cluster.tribes/xsd",
+				"tribes");
+
+		OMElement memberInfoOM = factory.createOMElement("memberInfo", omNs);
+
+		OMElement liveMemberOM = factory.createOMElement("liveMemberInfo", omNs);
+		for (Member member : liveMembers) {
+			OMElement memberOM = factory.createOMElement("member", omNs);
+			memberOM.addAttribute(factory.createOMAttribute("name", omNs, member.getName()));
+			memberOM.addAttribute(factory.createOMAttribute("host", omNs, String.valueOf(member
+					.getHost())));
+			memberOM.addAttribute(factory.createOMAttribute("port", omNs, String.valueOf(member
+					.getPort())));
+			memberOM.addAttribute(factory.createOMAttribute("aliveTime", omNs, String
+					.valueOf(member.getMemberAliveTime())));
+			liveMemberOM.addChild(memberOM);
+		}
+
+		OMElement deadMemberOM = factory.createOMElement("deadMemberInfo", omNs);
+		for (Member member : deadMembers) {
+			OMElement memberOM = factory.createOMElement("member", omNs);
+			memberOM.addAttribute(factory.createOMAttribute("name", omNs, member.getName()));
+			memberOM.addAttribute(factory.createOMAttribute("host", omNs, String.valueOf(member
+					.getHost())));
+			memberOM.addAttribute(factory.createOMAttribute("port", omNs, String.valueOf(member
+					.getPort())));
+			memberOM.addAttribute(factory.createOMAttribute("aliveTime", omNs, String
+					.valueOf(member.getMemberAliveTime())));
+			deadMemberOM.addChild(memberOM);
+		}
+
+		memberInfoOM.addChild(liveMemberOM);
+		memberInfoOM.addChild(deadMemberOM);
+
+		return memberInfoOM;
+	}
+
+	public OMElement getChannelInfo() {
+		ConfigurationContext configCtx = srvCtx.getConfigurationContext();
+		TransientTribesChannelInfo channelInfo = (TransientTribesChannelInfo) configCtx
+				.getProperty("CHANNEL_INFO");
+
+		SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+		OMNamespace omNs = factory.createOMNamespace("http://org.apache.axis2.cluster.tribes/xsd",
+				"tribes");
+		OMElement channelInfoOM = factory.createOMElement("channelInfo", omNs);
+
+		OMElement messageCountOM = factory.createOMElement("messageCount", omNs);
+		messageCountOM.addChild(factory.createOMText(messageCountOM, String.valueOf(channelInfo
+				.getMessageCount())));
+
+		OMElement grpCtxCreationCountOM = factory.createOMElement("grpCtxCreationCount", omNs);
+		grpCtxCreationCountOM.addChild(factory.createOMText(grpCtxCreationCountOM, String
+				.valueOf(channelInfo.getGrpCtxCreationCount())));
+
+		OMElement grpCtxRemoveCountOM = factory.createOMElement("grpCtxRemoveCount", omNs);
+		grpCtxRemoveCountOM.addChild(factory.createOMText(grpCtxRemoveCountOM, String
+				.valueOf(channelInfo.getGrpCtxRemoveCount())));
+
+		OMElement srvCtxCreationCountOM = factory.createOMElement("srvCtxCreationCount", omNs);
+		srvCtxCreationCountOM.addChild(factory.createOMText(srvCtxCreationCountOM, String
+				.valueOf(channelInfo.getSrvCtxCreationCount())));
+
+		OMElement srvCtxRemoveCountOM = factory.createOMElement("srvCtxRemoveCount", omNs);
+		srvCtxRemoveCountOM.addChild(factory.createOMText(srvCtxRemoveCountOM, String
+				.valueOf(channelInfo.getSrvCtxRemoveCount())));
+
+		OMElement updateStateCountOM = factory.createOMElement("updateStateCount", omNs);
+		updateStateCountOM.addChild(factory.createOMText(updateStateCountOM, String
+				.valueOf(channelInfo.getUpdateStateCount())));
+
+		channelInfoOM.addChild(messageCountOM);
+		channelInfoOM.addChild(grpCtxCreationCountOM);
+		channelInfoOM.addChild(grpCtxRemoveCountOM);
+		channelInfoOM.addChild(srvCtxCreationCountOM);
+		channelInfoOM.addChild(srvCtxRemoveCountOM);
+		channelInfoOM.addChild(updateStateCountOM);
+
+		return channelInfoOM;
+	}
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesMapEntryMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesMapEntryMessage.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesMapEntryMessage.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesMapEntryMessage.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,95 @@
+/*
+ * Copyright 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.axis2.cluster.tribes;
+
+import java.io.Serializable;
+
+public class TribesMapEntryMessage extends TribesCommandMessage {
+
+	public static short ADD_OR_UPDATE_ENTRY = 0;
+
+	public static short REMOVE_ENTRY = 1;
+
+	public static short SERVICE_GROUP_CONTEXT = 0;
+
+	public static short SERVICE_CONTEXT = 1;
+
+	String key;
+
+	Serializable value;
+
+	short operation;
+
+	short ctxType;
+
+	public short getOperation() {
+		return operation;
+	}
+
+	public short getCtxType() {
+		return ctxType;
+	}
+
+	public void setCtxType(short ctxType) {
+		this.ctxType = ctxType;
+	}
+
+	public void setOperation(short operation) {
+		this.operation = operation;
+	}
+
+	public TribesMapEntryMessage(String commandName, String parentId,
+			String contextId, String axisDescriptionName, String key,
+			Serializable value, short ctxType, short operation) {
+		super(commandName, parentId, contextId, axisDescriptionName, ctxType);
+		this.key = key;
+		this.value = value;
+		this.operation = operation;
+		this.ctxType = ctxType;
+	}
+
+	public String getKey() {
+		return key;
+	}
+
+	public void setKey(String key) {
+		this.key = key;
+	}
+
+	public Serializable getValue() {
+		return value;
+	}
+
+	public void setValue(Serializable value) {
+		this.value = value;
+	}
+
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("TribesCommandMessage [");
+		builder.append(this.getCommandName() + ",");
+		builder.append(this.getParentId() + ",");
+		builder.append(this.getContextId() + ",");
+		builder.append(this.getOperation() == ADD_OR_UPDATE_ENTRY ? "ADD_OR_UPDATE_ENTRY"
+						: "REMOVE_ENTRY" + ",");
+		builder.append(this.getCtxType() == SERVICE_GROUP_CONTEXT ? "SERVICE_GROUP_CONTEXT"
+						: "SERVICE_CONTEXT" + "]");
+
+		return builder.toString();
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ClusterManagerTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ClusterManagerTestCase.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ClusterManagerTestCase.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ClusterManagerTestCase.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,88 @@
+/*
+ * Copyright 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.axis2.clustering;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.engine.AxisConfiguration;
+
+public abstract class ClusterManagerTestCase extends TestCase {
+
+	protected ClusterManager clusterManager1 = null;
+
+	protected ClusterManager clusterManager2 = null;
+
+	protected AxisConfiguration axisConfiguration1 = null;
+
+	protected AxisConfiguration axisConfiguration2 = null;
+
+	protected ConfigurationContext configurationContext1 = null;
+
+	protected ConfigurationContext configurationContext2 = null;
+
+	protected AxisServiceGroup serviceGroup1 = null;
+
+	protected AxisServiceGroup serviceGroup2 = null;
+
+	protected AxisService service1 = null;
+
+	protected AxisService service2 = null;
+
+	protected String serviceName = "testService";
+
+	protected abstract ClusterManager getClusterManager();
+
+	protected void setUp() throws Exception {
+
+		clusterManager1 = getClusterManager();
+		clusterManager2 = getClusterManager();
+
+		//ConfigContext of the Node1
+		configurationContext1 = ConfigurationContextFactory.createDefaultConfigurationContext();
+
+		//ConfigContext of the Node2
+		configurationContext2 = ConfigurationContextFactory.createDefaultConfigurationContext();
+
+		//giving both Nodes the same deployment configuration
+
+		axisConfiguration1 = configurationContext1.getAxisConfiguration();
+		serviceGroup1 = new AxisServiceGroup(axisConfiguration1);
+		service1 = new AxisService(serviceName);
+		serviceGroup1.addService(service1);
+		axisConfiguration1.addServiceGroup(serviceGroup1);
+
+		axisConfiguration2 = configurationContext2.getAxisConfiguration();
+		serviceGroup2 = new AxisServiceGroup(axisConfiguration2);
+		service2 = new AxisService(serviceName);
+		serviceGroup2.addService(service2);
+		axisConfiguration2.addServiceGroup(serviceGroup2);
+
+		//Initiating ClusterManagers
+		clusterManager1.init(configurationContext1);
+		clusterManager2.init(configurationContext2);
+	}
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ManageContextTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ManageContextTestCase.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ManageContextTestCase.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ManageContextTestCase.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,63 @@
+/*
+ * Copyright 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.axis2.clustering;
+import java.util.Iterator;
+
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axis2.context.ContextFactory;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+
+
+public abstract class ManageContextTestCase extends ClusterManagerTestCase {
+
+	public void testAddContext () throws Exception {
+		
+		//Adding contexts to the Node1
+		ServiceGroupContext serviceGroupContext1 = ContextFactory.createServiceGroupContext(configurationContext1, serviceGroup1);
+		String sgcID = UUIDGenerator.getUUID();
+		serviceGroupContext1.setId(sgcID);
+		
+		ServiceContext serviceContext1 = ContextFactory.createServiceContext(serviceGroupContext1, service1);
+		
+		//adding the Contexts to the first configContext 
+		clusterManager1.addContext(serviceGroupContext1);
+		clusterManager1.addContext(serviceContext1);
+		
+		//give a time interval
+		Thread.sleep(5000);
+		
+		//The second configContext should have the newly added contexts.
+		ServiceGroupContext serviceGroupContext2 = configurationContext2.getServiceGroupContext(sgcID);
+		assertNotNull(serviceGroupContext2);
+		
+		Iterator iter = serviceGroupContext2.getServiceContexts();
+		assertNotNull(iter);
+		assertTrue(iter.hasNext());
+		
+		ServiceContext serviceContext2 = (ServiceContext) iter.next();
+		assertNotNull(serviceContext2);
+		assertEquals(serviceContext2.getName(), serviceName);
+		
+	}
+	
+	public void testRemoveContext () {
+		
+	}
+	
+	
+}

Added: webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/UpdateStateTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/UpdateStateTestCase.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/UpdateStateTestCase.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/UpdateStateTestCase.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,154 @@
+/*
+ * Copyright 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.axis2.clustering;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axis2.context.ContextFactory;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+
+public abstract class UpdateStateTestCase extends ClusterManagerTestCase {
+
+	ServiceContext serviceContext1 = null;
+
+	ServiceGroupContext serviceGroupContext1 = null;
+
+	String sgcID = null;
+
+	String key1 = "key1";
+
+	String key2 = "key2";
+
+	String key3 = "key3";
+
+	String val1 = "val1";
+
+	String val2 = "val2";
+
+	String val3 = "val3";
+
+	public void setUp() throws Exception {
+		super.setUp();
+
+		sgcID = UUIDGenerator.getUUID();
+
+		//Adding contexts to the Node1
+		serviceGroupContext1 = ContextFactory.createServiceGroupContext(configurationContext1,
+				serviceGroup1);
+		serviceGroupContext1.setId(sgcID);
+
+		serviceContext1 = ContextFactory.createServiceContext(serviceGroupContext1, service1);
+		serviceGroupContext1.addServiceContext(serviceContext1);
+
+		configurationContext1.setProperty(key1, val1);
+		serviceGroupContext1.setProperty(key2, val2);
+		serviceContext1.setProperty(key3, val3);
+
+		clusterManager1.addContext(serviceGroupContext1);
+		clusterManager1.addContext(serviceContext1);
+
+		clusterManager1.updateState(configurationContext1);
+		clusterManager1.updateState(serviceGroupContext1);
+		clusterManager1.updateState(serviceContext1);
+
+		Thread.sleep(1000);
+	}
+
+	public void testAddProperty() throws Exception {
+
+		//TODO uncomment this when configCtx proeprty updates are supported
+		//		Object val = configurationContext2.getProperty(key1);
+		//		assertNotNull(val);
+		//		assertEquals(val, val1);
+
+		ServiceGroupContext serviceGroupContext2 = configurationContext2
+				.getServiceGroupContext(sgcID);
+		assertNotNull(serviceGroupContext2);
+		Object val = serviceGroupContext2.getProperty(key2);
+		assertNotNull(val);
+		assertEquals(val, val2);
+
+		Thread.sleep(1000);
+
+		Iterator iter = serviceGroupContext2.getServiceContexts();
+		assertNotNull(iter);
+		assertTrue(iter.hasNext());
+		ServiceContext serviceContext2 = (ServiceContext) iter.next();
+		assertNotNull(serviceContext2);
+		val = serviceContext2.getProperty(key3);
+		assertNotNull(val);
+		assertEquals(val, val3);
+
+	}
+
+	public void testRemoveProperty() throws Exception {
+
+		serviceGroupContext1.getProperties().remove(key2);
+		serviceContext1.getProperties().remove(key3);
+
+		clusterManager1.updateState(serviceContext1);
+		clusterManager1.updateState(serviceGroupContext1);
+
+		Thread.sleep(1000);
+
+		ServiceGroupContext serviceGroupContext2 = configurationContext2
+				.getServiceGroupContext(sgcID);
+		assertNotNull(serviceGroupContext2);
+		Object val = serviceGroupContext2.getProperty(key2);
+		assertNull(val);
+
+		Iterator iter = serviceGroupContext2.getServiceContexts();
+		assertNotNull(iter);
+		assertTrue(iter.hasNext());
+		ServiceContext serviceContext2 = (ServiceContext) iter.next();
+		assertNotNull(serviceContext2);
+		val = serviceContext2.getProperty(key3);
+		assertNull(val);
+
+	}
+
+	public void testUpdateProperty() throws Exception {
+
+		serviceGroupContext1.setProperty(key2, val3);
+		serviceContext1.setProperty(key3, val2);
+
+		clusterManager1.updateState(serviceContext1);
+		clusterManager1.updateState(serviceGroupContext1);
+
+		Thread.sleep(1000);
+
+		ServiceGroupContext serviceGroupContext2 = configurationContext2
+				.getServiceGroupContext(sgcID);
+		assertNotNull(serviceGroupContext2);
+		Object val = serviceGroupContext2.getProperty(key2);
+		assertNotNull(val);
+		assertEquals(val, val3);
+
+		Iterator iter = serviceGroupContext2.getServiceContexts();
+		assertNotNull(iter);
+		assertTrue(iter.hasNext());
+		ServiceContext serviceContext2 = (ServiceContext) iter.next();
+		assertNotNull(serviceContext2);
+		val = serviceContext2.getProperty(key3);
+		assertNotNull(val);
+		assertEquals(val, val2);
+
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/ManageContextTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/ManageContextTest.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/ManageContextTest.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/ManageContextTest.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,29 @@
+/*
+ * Copyright 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.axis2.clustering.tribes;
+
+import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.cluster.tribes.TribesClusterManager;
+import org.apache.axis2.clustering.ManageContextTestCase;
+
+public class ManageContextTest extends ManageContextTestCase {
+
+	protected ClusterManager getClusterManager() {
+		return new TribesClusterManager();
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/UpdateStateTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/UpdateStateTest.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/UpdateStateTest.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/UpdateStateTest.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,29 @@
+/*
+ * Copyright 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.axis2.clustering.tribes;
+
+import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.cluster.tribes.TribesClusterManager;
+import org.apache.axis2.clustering.UpdateStateTestCase;
+
+public class UpdateStateTest extends UpdateStateTestCase {
+
+	protected ClusterManager getClusterManager() {
+		return new TribesClusterManager();
+	}
+
+}

Modified: webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml?view=diff&rev=511289&r1=511288&r2=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml Sat Feb 24 08:04:23 2007
@@ -225,7 +225,17 @@
     <!--<moduleConfig name="addressing">-->
     <!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
     <!--</moduleConfig>-->
-
+
+    <!-- ================================================= -->
+    <!-- Clustering  -->
+    <!-- ================================================= -->
+    <!-- Configure and uncomment following for preparing Axis2 to a clustered environment -->
+    <!-- 
+    <cluster class="org.apache.axis2.cluster.tribes.TribesClusterManager">
+    	<parameter name="param1" locked="false">value1</parameter>
+    </cluster>
+     -->
+     
     <!-- ================================================= -->
     <!-- Phases  -->
     <!-- ================================================= -->

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java?view=auto&rev=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java Sat Feb 24 08:04:23 2007
@@ -0,0 +1,40 @@
+/*
+ * Copyright 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.axis2.cluster;
+
+import org.apache.axis2.context.AbstractContext;
+import org.apache.axis2.context.ConfigurationContext;
+
+public interface ClusterManager {
+
+	public void init(ConfigurationContext context);
+
+	public void addContext(AbstractContext context);
+	
+	public void removeContext(AbstractContext context);
+	
+	public void updateState(AbstractContext context);
+	
+	/**
+	 * This can be used to limit the contexts that get replicated through the 'flush' method.
+	 * 
+	 * @param context
+	 * @return
+	 */
+	public boolean isContextClusterable (AbstractContext context);
+	
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java?view=diff&rev=511289&r1=511288&r2=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java Sat Feb 24 08:04:23 2007
@@ -21,6 +21,11 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.i18n.Messages;
+
 /**
  * This is the top most level of the Context hierarchy and is a bag of properties.
  */
@@ -35,7 +40,7 @@
 
     protected transient AbstractContext parent;
     protected transient Map properties;
-
+    
     protected AbstractContext(AbstractContext parent) {
         this.parent = parent;
     }
@@ -166,4 +171,25 @@
     public void setLastTouchedTime(long t) {
         lastTouchedTime = t;
     }
+    
+    public void flush () throws AxisFault {
+    	
+    	ConfigurationContext configContext = getRootContext();
+    	if (configContext==null) {
+    		throw new AxisFault (Messages.getMessage("cannotFlushRootNull"));
+    	}
+    	
+    	AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
+    	ClusterManager clusterManager = axisConfiguration.getClusterManager();
+    	
+    	//Calling the ClusterManager probably to replicate the updated state of the context.
+    	if (clusterManager!=null && clusterManager.isContextClusterable (this)) {
+    		clusterManager.updateState(this);
+    	}
+    	
+    	//Other logic needed for flushing the contexts
+    }
+    
+    public abstract ConfigurationContext getRootContext ();
+    
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java?view=diff&rev=511289&r1=511288&r2=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java Sat Feb 24 08:04:23 2007
@@ -20,6 +20,7 @@
 import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.cluster.ClusterManager;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
 import org.apache.axis2.description.Parameter;
@@ -65,6 +66,9 @@
         super(null);
         this.axisConfiguration = axisConfiguration;
         initConfigContextTimeout(axisConfiguration);
+        
+        if (axisConfiguration.getClusterManager()!=null)
+        	initCluster();
     }
 
     private void initConfigContextTimeout(AxisConfiguration axisConfiguration) {
@@ -77,6 +81,11 @@
         }
     }
 
+    private void initCluster() {
+		ClusterManager clusterManager = axisConfiguration.getClusterManager();
+		clusterManager.init(this);
+	}
+    
     protected void finalize() throws Throwable {
         super.finalize();
     }
@@ -120,6 +129,11 @@
                     serviceGroupContext =ContextFactory.createServiceGroupContext(
                             messageContext.getConfigurationContext(),axisServiceGroup);
                     applicationSessionServiceGroupContextTable.put(serviceGroupName, serviceGroupContext);
+                    
+                    ClusterManager clusterManager = this.getAxisConfiguration().getClusterManager();
+                    if (clusterManager!=null) {
+                    	clusterManager.addContext(serviceGroupContext);
+                    }
                 }
                 messageContext.setServiceGroupContext(serviceGroupContext);
                 messageContext.setServiceContext(ContextFactory.createServiceContext(
@@ -140,6 +154,12 @@
                     // set the serviceGroupContextID
                     serviceGroupContextId = UUIDGenerator.getUUID();
                     serviceGroupContext.setId(serviceGroupContextId);
+
+                    ClusterManager clusterManager = this.getAxisConfiguration().getClusterManager();
+                    if (clusterManager!=null) {
+                    	clusterManager.addContext(serviceGroupContext);
+                    }
+                    
                     messageContext.setServiceGroupContextId(serviceGroupContextId);
                     registerServiceGroupContextintoSoapSessionTable(serviceGroupContext);
                 }
@@ -550,4 +570,10 @@
 
         }
     }
+
+	public ConfigurationContext getRootContext() {
+		return this;
+	}
+    
+    
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?view=diff&rev=511289&r1=511288&r2=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java Sat Feb 24 08:04:23 2007
@@ -4222,4 +4222,10 @@
             log.warn(getLogIDString() + ":" + methodname + "(): ****WARNING**** " + myClassName + ".activate(configurationContext) needs to be invoked.");
         }
     }
+
+	public ConfigurationContext getRootContext() {
+		return configurationContext;
+	}
+    
+    
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java?view=diff&rev=511289&r1=511288&r2=511289
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/OperationContext.java Sat Feb 24 08:04:23 2007
@@ -1157,4 +1157,8 @@
         return logCorrelationIDString;
     }
     
+	public ConfigurationContext getRootContext() {
+		return this.getConfigurationContext();
+	}
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org