axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r517114 [1/2] - in /webservices/axis2/trunk/java: etc/ modules/clustering/ modules/clustering/src/org/apache/axis2/cluster/handlers/ modules/clustering/src/org/apache/axis2/cluster/tribes/ modules/clustering/src/org/apache/axis2/cluster/tri...
Date Mon, 12 Mar 2007 06:51:28 GMT
Author: chamikara
Date: Sun Mar 11 23:51:26 2007
New Revision: 517114

URL: http://svn.apache.org/viewvc?view=rev&rev=517114
Log:
Modified the Handler.flowComplete () method to throw an AxisFault.
Updated the clustering API (accodring to the mail that was sent to the list).
Updated the clustering Impl to reflect these changes.
Updated the clustering tests to not to fail in offline mode and added the module back the the build.  

Added:
    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/configuration/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/configuration/TribesConfigurationManager.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextCommandMessage.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextListenerEventType.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextType.java
      - copied, changed from r516876, 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/context/ContextUpdateEntryCommandMessage.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextUpdater.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/TribesContextManager.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/TribesContextManagerListener.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesChannelInfo.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesMemberInfo.java
      - copied, changed from r516876, 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/info/TribesInfoWebService.java
      - copied, changed from r516876, webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesInfoWebService.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusteringFault.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/configuration/
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/configuration/ConfigurationEvent.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/configuration/ConfigurationManager.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/configuration/ConfigurationManagerListener.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/configuration/ConfigurationType.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextEvent.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextManager.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextManagerListener.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextType.java
Removed:
    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/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
Modified:
    webservices/axis2/trunk/java/etc/project.properties
    webservices/axis2/trunk/java/modules/clustering/project.xml
    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/TribesClusterManager.java
    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/kernel/src/org/apache/axis2/cluster/ClusterManager.java
    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/ConfigurationContextFactory.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ServiceGroupContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/Handler.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/Phase.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/handlers/AbstractHandler.java
    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=517114&r1=517113&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/etc/project.properties (original)
+++ webservices/axis2/trunk/java/etc/project.properties Sun Mar 11 23:51:26 2007
@@ -74,7 +74,7 @@
 modules/jaxbri/project.xml,\
 modules/jaxws/project.xml,\
 modules/jaxws-api/project.xml,\
-#modules/clustering/project.xml
+modules/clustering/project.xml
 
 # -------------------------------------------------------------------
 #                JUnit

Modified: webservices/axis2/trunk/java/modules/clustering/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/project.xml?view=diff&rev=517114&r1=517113&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/project.xml (original)
+++ webservices/axis2/trunk/java/modules/clustering/project.xml Sun Mar 11 23:51:26 2007
@@ -122,7 +122,15 @@
             <properties>
                 <module>true</module>
             </properties>
-        </dependency>   
+        </dependency>   
+        <dependency>
+            <groupId>org.apache.neethi</groupId>
+            <artifactId>neethi</artifactId>
+            <version>${neethi.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
     </dependencies>
     <build/>
     <reports/>

Modified: 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=diff&rev=517114&r1=517113&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/handlers/ReplicationHandler.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/handlers/ReplicationHandler.java Sun Mar 11 23:51:26 2007
@@ -18,15 +18,21 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.cluster.ClusteringFault;
+import org.apache.axis2.cluster.context.ContextManager;
 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;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class ReplicationHandler extends AbstractHandler {
 
+    private static final Log log = LogFactory.getLog(ReplicationHandler.class);
+    
 	public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
 
 		replicateState(msgContext);
@@ -34,30 +40,40 @@
 		return InvocationResponse.CONTINUE;
 	}
 
-	public void flowComplete(MessageContext msgContext) {
+	public void flowComplete(MessageContext msgContext) throws AxisFault {
 		super.flowComplete(msgContext);
 
 		replicateState(msgContext);
 	}
 
-	private void replicateState(MessageContext message) {
+	private void replicateState(MessageContext message) throws ClusteringFault {
 
 		ConfigurationContext configurationContext = message.getConfigurationContext();
 		AxisConfiguration axisConfiguration = configurationContext.getAxisConfiguration();
 		ClusterManager clusterManager = axisConfiguration.getClusterManager();
 
 		if (clusterManager != null) {
+			
+			ContextManager contextManager = clusterManager.getContextManager();
+			if (contextManager==null) {
+				if (log.isDebugEnabled()) {
+					String msg = "Cannot replicate contexts since the ClusterManager has not defined a ContextManager";
+					log.error(msg);
+				}
+			}
+			
 			ServiceContext serviceContext = message.getServiceContext();
 			ServiceGroupContext serviceGroupContext = message.getServiceGroupContext();
 
-			clusterManager.updateState(configurationContext);
+			
+			contextManager.updateState(configurationContext);
 
 			if (serviceGroupContext != null) {
-				clusterManager.updateState(serviceGroupContext);
+				contextManager.updateState(serviceGroupContext);
 			}
 
 			if (serviceContext != null) {
-				clusterManager.updateState(serviceContext);
+				contextManager.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=517114
==============================================================================
--- 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 Sun Mar 11 23:51:26 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";
+	
+}

Modified: 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=diff&rev=517114&r1=517113&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java Sun Mar 11 23:51:26 2007
@@ -17,20 +17,25 @@
 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.cluster.ClusteringFault;
+import org.apache.axis2.cluster.configuration.ConfigurationManager;
+import org.apache.axis2.cluster.context.ContextEvent;
+import org.apache.axis2.cluster.context.ContextManager;
+import org.apache.axis2.cluster.tribes.configuration.TribesConfigurationManager;
+import org.apache.axis2.cluster.tribes.context.ContextListenerEventType;
+import org.apache.axis2.cluster.tribes.context.ContextType;
+import org.apache.axis2.cluster.tribes.context.ContextUpdater;
+import org.apache.axis2.cluster.tribes.context.ContextCommandMessage;
+import org.apache.axis2.cluster.tribes.context.TribesContextManager;
+import org.apache.axis2.cluster.tribes.context.ContextUpdateEntryCommandMessage;
+import org.apache.axis2.cluster.tribes.info.TransientTribesChannelInfo;
+import org.apache.axis2.cluster.tribes.info.TransientTribesMemberInfo;
 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;
@@ -42,362 +47,162 @@
 
 public class TribesClusterManager implements ClusterManager, ChannelListener {
 
-	private static final Log log = LogFactory.getLog(TribesClusterManager.class);
-
-	private ConfigurationContext configContext;
 
+	TribesConfigurationManager descriptionManager = null;
+	TribesContextManager contextManager = null;
+	ConfigurationContext configContext = null;
 	private Channel channel;
+	private ContextUpdater updater;
+	private static long timeout = 1000L; // this should be configured in the axis2.xml
+	
+    private static final Log log = LogFactory.getLog(TribesClusterManager.class);
+    
+    public TribesClusterManager () {
+		contextManager = new TribesContextManager ();
+		descriptionManager = new TribesConfigurationManager ();
+    }
+	
+	public ContextManager getContextManager() {
+		return contextManager;
+	}
 
-	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 ConfigurationManager getConfigurationManager() {
+		return descriptionManager;
+	}
 
-	public void init(ConfigurationContext context) {
+	public void init(ConfigurationContext context) throws ClusteringFault {
 		log.debug("initializing tibes");
 
-		this.configContext = context;
+		try {
+			this.configContext = context;
 
-		TransientTribesChannelInfo channelInfo = new TransientTribesChannelInfo();
-		TransientTribesMemberInfo memberInfo = new TransientTribesMemberInfo();
+			TransientTribesChannelInfo channelInfo = new TransientTribesChannelInfo();
+			TransientTribesMemberInfo memberInfo = new TransientTribesMemberInfo();
 
-		configContext.setProperty("MEMBER_INFO", memberInfo);
-		configContext.setProperty("CHANNEL_INFO", channelInfo);
+			configContext.setProperty("MEMBER_INFO", memberInfo);
+			configContext.setProperty("CHANNEL_INFO", channelInfo);
 
-		channel = new GroupChannel();
-		try {
+			channel = new GroupChannel();
 			channel.addChannelListener(this);
 			channel.addChannelListener(channelInfo);
 			channel.addMembershipListener(memberInfo);
 			channel.start(Channel.DEFAULT);
-			ctxManager = new ContextManager(channel, timeout, context.getAxisConfiguration()
+			updater = new ContextUpdater (channel, TribesClusterManager.timeout, context.getAxisConfiguration()
 					.getSystemClassLoader());
+			
+			contextManager.setChannel(channel);
+			contextManager.setUpdater(updater);
+			contextManager.setConfigContext(context);
+			
+			registerTribesInfoService(configContext);
 		} catch (ChannelException e) {
-			log.error("Error starting Tribes channel", e);
+			String message = "Error starting Tribes channel";
+			throw new ClusteringFault (message, e);
 		}
-
-		registerTribesInfoService(configContext);
 	}
 
-	private void registerTribesInfoService(ConfigurationContext configContext2) {
+	private void registerTribesInfoService(ConfigurationContext configContext2) throws ClusteringFault {
 		try {
 			AxisService service = AxisService.createService(
-					"org.apache.axis2.cluster.tribes.TribesInfoWebService", configContext
+					"org.apache.axis2.cluster.tribes.info.TribesInfoWebService", configContext
 							.getAxisConfiguration(), RPCMessageReceiver.class);
 
 			configContext.getAxisConfiguration().addService(service);
 		} catch (AxisFault e) {
-			log.error("Unable to create Tribes info web service", e);
+			String message = "Unable to create Tribes info web service";
+			throw new ClusteringFault (message, 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;
+	public void messageReceived(Serializable msg, Member sender) {
 
-			// The new serialization code sets the service group name as it's id initially
-			if (srvGrpCtx.getId().equals(srvGrpCtx.getDescription().getServiceGroupName())) {
-				return;
-			}
+		if (!(msg instanceof ContextCommandMessage)) {
+			return;
+		}
 
-			ctxManager.addServiceGroupContext(contextId);
+		ContextCommandMessage comMsg = (ContextCommandMessage) msg;
 
-			comMsg = new TribesCommandMessage(CommandType.CREATE_SERVICE_GROUP_CONTEXT, "",
-					contextId, srvGrpCtx.getDescription().getServiceGroupName(),
-					ContextType.SERVICE_GROUP_CONTEXT);
+		// 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.
 
-			send(comMsg);
+		if (comMsg.getCommandName().equals(CommandType.CREATE_SERVICE_GROUP_CONTEXT)) {
 
-			// now iterate through the list of service contexts and replicate them
-			List<TribesCommandMessage> list = orphanedServiceCtxs.get(srvGrpCtx.getDescription()
-					.getServiceGroupName());
+			// add to the duplicate list to prevent cyclic replication
+			contextManager.addToDuplicateServiceGroupContexts(comMsg.getContextId());
+			updater.addServiceGroupContext(comMsg.getContextId());
 
-			if (list != null) {
-				for (TribesCommandMessage command : list) {
-					ctxManager.addServiceContext(contextId, command.getContextId());
-					command.setParentId(contextId);
+			ContextEvent event = new ContextEvent();
+			event.setContextType(ContextType.SERVICE_GROUP_CONTEXT);
+			event.setContextID(comMsg.getContextId());
+			event.setParentContextID(comMsg.getParentId());
+			event.setDescriptionID(comMsg.getAxisDescriptionName());
 
-					send(command);
+			contextManager.notifyListeners(event, ContextListenerEventType.ADD_CONTEXT);
 
-				}
+		} else if (comMsg.getCommandName().equals(CommandType.CREATE_SERVICE_CONTEXT)) {
 
-				orphanedServiceCtxs.remove(srvGrpCtx.getDescription().getServiceGroupName());
-			}
-		}
-	}
+			// add to the duplicate list to prevent cyclic replication
+			contextManager.addToDuplicateServiceContexts(comMsg.getParentId()
+					+ comMsg.getContextId());
+			updater.addServiceContext(comMsg.getParentId(), comMsg.getContextId());
 
-	/*
-	 * 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);
-		}
+			ContextEvent event = new ContextEvent();
+			event.setContextType(ContextType.SERVICE_CONTEXT);
+			event.setContextID(comMsg.getContextId());
+			event.setParentContextID(comMsg.getParentId());
+			event.setDescriptionID(comMsg.getAxisDescriptionName());
 
-		send(comMsg);
-	}
+			contextManager.notifyListeners(event, ContextListenerEventType.ADD_CONTEXT);
 
-	/*
-	 * 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);
-		}
+		} else if (comMsg.getCommandName().equals(CommandType.UPDATE_STATE)) {
 
-		if (mapEntryMsgs != null) {
-			for (TribesMapEntryMessage msg : mapEntryMsgs) {
-				send(msg);
-			}
-		}
+			if (comMsg.getContextType() == ContextType.SERVICE_GROUP_CONTEXT) {
 
-		TribesCommandMessage comMsg = new TribesCommandMessage(CommandType.UPDATE_STATE,
-				parentContextId, contextId, contextId, contextType);
+				ContextEvent event = new ContextEvent();
+				event.setContextType(ContextType.SERVICE_GROUP_CONTEXT);
+				event.setContextID(comMsg.getContextId());
+				event.setParentContextID(comMsg.getParentId());
+				event.setDescriptionID(comMsg.getAxisDescriptionName());
 
-		send(comMsg);
-	}
+				contextManager.notifyListeners(event, ContextListenerEventType.UPDATE_CONTEXT);
 
-	public boolean accept(Serializable msg, Member sender) {
-		// return msg instanceof TribesCommandMessage;
-		return true;
-	}
+			} else if (comMsg.getContextType() == ContextType.SERVICE_CONTEXT) {
 
-	public void messageReceived(Serializable msg, Member sender) {
+				ContextEvent event = new ContextEvent();
+				event.setContextType(ContextType.SERVICE_CONTEXT);
+				event.setContextID(comMsg.getContextId());
+				event.setParentContextID(comMsg.getParentId());
+				event.setDescriptionID(comMsg.getAxisDescriptionName());
 
-		try {
+				contextManager.notifyListeners(event, ContextListenerEventType.UPDATE_CONTEXT);
 
-			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)) {
 
+			ContextUpdateEntryCommandMessage mapEntryMsg = (ContextUpdateEntryCommandMessage) comMsg;
+			if (mapEntryMsg.getCtxType() == ContextUpdateEntryCommandMessage.SERVICE_GROUP_CONTEXT) {
+				Map props = updater.getServiceGroupProps(comMsg.getContextId());
+				if (mapEntryMsg.getOperation() == ContextUpdateEntryCommandMessage.ADD_OR_UPDATE_ENTRY) {
+					props.put(mapEntryMsg.getKey(), mapEntryMsg.getValue());
+				} else {
+					props.remove(mapEntryMsg.getKey());
 				}
-
-			} 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());
-					}
+			} else if (mapEntryMsg.getCtxType() == ContextUpdateEntryCommandMessage.SERVICE_CONTEXT) {
+				Map props = updater.getServiceProps(comMsg.getParentId(), comMsg.getContextId());
+				if (mapEntryMsg.getOperation() == ContextUpdateEntryCommandMessage.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;
+	public boolean accept(Serializable msg, Member sender) {
+		// return msg instanceof TribesCommandMessage;
+		return true;
 	}
 
 }

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/configuration/TribesConfigurationManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/configuration/TribesConfigurationManager.java?view=auto&rev=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/configuration/TribesConfigurationManager.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/configuration/TribesConfigurationManager.java Sun Mar 11 23:51:26 2007
@@ -0,0 +1,57 @@
+/*
+ * 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.configuration;
+
+import org.apache.axis2.cluster.configuration.ConfigurationManager;
+import org.apache.axis2.cluster.configuration.ConfigurationManagerListener;
+import org.apache.neethi.Policy;
+
+public class TribesConfigurationManager implements ConfigurationManager {
+
+	public void addConfigurationManagerListener(ConfigurationManagerListener listener) {
+		throw new UnsupportedOperationException ();
+	}
+
+	public void applyPolicy(String serviceGroupName, Policy policy) {
+		throw new UnsupportedOperationException ();
+	}
+
+	public void commit() {
+		throw new UnsupportedOperationException ();
+	}
+
+	public void loadServiceGroup(String serviceGroupName) {
+		throw new UnsupportedOperationException ();
+	}
+
+	public void prepare() {
+		throw new UnsupportedOperationException ();		
+	}
+
+	public void reloadConfiguration() {
+		throw new UnsupportedOperationException ();		
+	}
+
+	public void rollback() {
+		throw new UnsupportedOperationException ();		
+	}
+
+	public void unloadServiceGroup(String serviceGroupName) {
+		throw new UnsupportedOperationException ();		
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextCommandMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextCommandMessage.java?view=auto&rev=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextCommandMessage.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextCommandMessage.java Sun Mar 11 23:51:26 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.context;
+
+import java.io.Serializable;
+
+public class ContextCommandMessage implements Serializable {
+
+	private String commandName;
+
+	private String parentId;
+
+	private String contextId;
+
+	private String axisDescriptionName;
+
+	private int contextType;
+
+	public ContextCommandMessage() {
+	}
+
+	public ContextCommandMessage(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/context/ContextListenerEventType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextListenerEventType.java?view=auto&rev=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextListenerEventType.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextListenerEventType.java Sun Mar 11 23:51:26 2007
@@ -0,0 +1,23 @@
+/*
+ * 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.context;
+
+public class ContextListenerEventType {
+	public final static int ADD_CONTEXT = 1;
+	public final static int REMOVE_CONTEXT = 2;
+	public final static int UPDATE_CONTEXT = 3;
+}

Copied: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextType.java (from r516876, 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/context/ContextType.java?view=diff&rev=517114&p1=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextType.java&r1=516876&p2=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextType.java&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/ContextType.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextType.java Sun Mar 11 23:51:26 2007
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.apache.axis2.cluster.tribes;
+package org.apache.axis2.cluster.tribes.context;
 
 public class ContextType {
 

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextUpdateEntryCommandMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextUpdateEntryCommandMessage.java?view=auto&rev=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextUpdateEntryCommandMessage.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextUpdateEntryCommandMessage.java Sun Mar 11 23:51:26 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.context;
+
+import java.io.Serializable;
+
+
+public class ContextUpdateEntryCommandMessage extends ContextCommandMessage {
+
+	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 ContextUpdateEntryCommandMessage(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/src/org/apache/axis2/cluster/tribes/context/ContextUpdater.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextUpdater.java?view=auto&rev=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextUpdater.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextUpdater.java Sun Mar 11 23:51:26 2007
@@ -0,0 +1,287 @@
+/*
+ * 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.context;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.axis2.cluster.tribes.CommandType;
+import org.apache.catalina.tribes.Channel;
+
+public class ContextUpdater {
+
+	private Channel channel;
+
+	private long timeout = 1000;
+
+	private ClassLoader classLoader;
+
+	private Map serviceCtxProps = null;
+	private Map serviceGrpCtxProps = null;
+
+	public Map getServiceCtxProps() {
+		return serviceCtxProps;
+	}
+
+	public Map getServiceGrpCtxProps() {
+		return serviceGrpCtxProps;
+	}
+
+	public ContextUpdater(Channel channel, long timeout, ClassLoader classLoader) {
+		this.channel = channel;
+		this.timeout = timeout;
+		this.classLoader = classLoader;
+		serviceCtxProps = new HashMap ();
+		serviceGrpCtxProps = new HashMap ();
+	}
+
+	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 (Map) serviceGrpCtxProps.get(groupId);
+	}
+
+	public Map getServiceProps(String parentId, String serviceCtxName) {
+		String key = parentId + "_" + serviceCtxName;
+		return (Map) serviceCtxProps.get(key);
+	}
+
+	public List updateStateOnServiceContext(String parentId,
+			String serviceCtxName, Map newProps) {
+		String key = parentId + "_" + serviceCtxName;
+		HashMap oldProps = (HashMap) serviceCtxProps.get(key);
+		if (oldProps == null) {
+			oldProps = new HashMap();
+			serviceCtxProps.put(key, oldProps);
+		}
+
+		List commandList = new ArrayList();
+
+		try {
+			// using set operations to figure out the diffs
+
+			// figuring out entries to remove
+			Set diffForRemove = new HashSet();
+			diffForRemove.addAll(oldProps.keySet());
+			diffForRemove.removeAll(newProps.keySet());
+
+			// figuring out new entires
+			Set diffForAddOrUpdate = new HashSet();
+			diffForAddOrUpdate.addAll(newProps.keySet());
+			diffForAddOrUpdate.removeAll(oldProps.keySet());
+
+			// figuring out entries to update
+			for (Iterator it= newProps.keySet().iterator();it.hasNext();) {
+				
+				String paramKey = (String) it.next();
+				
+				Object oldValue = oldProps.get(paramKey);
+				Object newValue = newProps.get(paramKey);
+
+				if (oldValue != null && !oldValue.equals(newValue)) {
+					diffForAddOrUpdate.add(paramKey);
+				}
+			}
+
+			for (Iterator it= diffForAddOrUpdate.iterator();it.hasNext();) {
+				
+				String paramKey = (String) it.next();
+				
+				Object value = newProps.get(paramKey);
+				if (value instanceof Serializable) {
+					oldProps.put(paramKey, value);
+					commandList.add(new ContextUpdateEntryCommandMessage(
+							CommandType.UPDATE_STATE_MAP_ENTRY, parentId,
+							serviceCtxName, serviceCtxName, paramKey,
+							(Serializable) value,
+							ContextUpdateEntryCommandMessage.SERVICE_CONTEXT,
+							ContextUpdateEntryCommandMessage.ADD_OR_UPDATE_ENTRY));
+					// oldProps.replicate(paramKey, true);
+				}
+			}
+
+			for (Iterator it= diffForRemove.iterator();it.hasNext();) {
+				
+				String paramKey = (String) it.next();
+				
+				oldProps.remove(paramKey);
+				commandList.add(new ContextUpdateEntryCommandMessage(
+						CommandType.UPDATE_STATE_MAP_ENTRY, parentId,
+						serviceCtxName, serviceCtxName, paramKey, "",
+						ContextUpdateEntryCommandMessage.SERVICE_CONTEXT,
+						ContextUpdateEntryCommandMessage.REMOVE_ENTRY));
+
+				// oldProps.replicate(paramKey, true);
+			}
+		} catch (RuntimeException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return commandList;
+	}
+
+	public List updateStateOnServiceGroupContext(String ctxId,
+			Map newProps) {
+		HashMap oldProps = (HashMap) serviceGrpCtxProps.get(ctxId);
+		if (oldProps == null) {
+			oldProps = new HashMap();
+			serviceCtxProps.put(ctxId, oldProps);
+		}
+
+		List commandList = new ArrayList ();
+
+		try {
+			// using set operations to figure out the diffs
+
+			// figuring out entries to remove
+			Set diffForRemove = new HashSet();
+			diffForRemove.addAll(oldProps.keySet());
+			diffForRemove.removeAll(newProps.keySet());
+
+			// figuring out entries to update
+			Set diffForAddOrUpdate = new HashSet ();
+			diffForAddOrUpdate.addAll(newProps.keySet());
+			diffForAddOrUpdate.removeAll(oldProps.keySet());
+
+			// figuring out entries to update
+			for (Iterator it=newProps.keySet().iterator();it.hasNext();) {
+				
+				String paramKey = (String) it.next();
+				
+				Object oldValue = oldProps.get(paramKey);
+				Object newValue = newProps.get(paramKey);
+
+				if (oldValue != null && !oldValue.equals(newValue)) {
+					diffForAddOrUpdate.add(paramKey);
+				}
+			}
+
+			for (Iterator it=diffForAddOrUpdate.iterator();it.hasNext();) {
+				
+				String paramKey = (String) it.next();
+				
+				Object value = newProps.get(paramKey);
+				if (value instanceof Serializable) {
+					oldProps.put(paramKey, value);
+					commandList.add(new ContextUpdateEntryCommandMessage(
+							CommandType.UPDATE_STATE_MAP_ENTRY, "", ctxId,
+							ctxId, paramKey, (Serializable) value,
+							ContextUpdateEntryCommandMessage.SERVICE_GROUP_CONTEXT,
+							ContextUpdateEntryCommandMessage.ADD_OR_UPDATE_ENTRY));
+					// oldProps.replicate(paramKey, true); //
+					// map.replicate(true) will replicate all
+				}
+			}
+
+			for (Iterator it=diffForRemove.iterator();it.hasNext();) {
+				
+				String paramKey = (String) it.next();
+				
+				commandList.add(new ContextUpdateEntryCommandMessage(
+						CommandType.UPDATE_STATE_MAP_ENTRY, "", ctxId, ctxId,
+						paramKey, "",
+						ContextUpdateEntryCommandMessage.SERVICE_GROUP_CONTEXT,
+						ContextUpdateEntryCommandMessage.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/context/TribesContextManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/TribesContextManager.java?view=auto&rev=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/TribesContextManager.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/TribesContextManager.java Sun Mar 11 23:51:26 2007
@@ -0,0 +1,313 @@
+/*
+ * 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.context;
+
+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.cluster.ClusteringFault;
+import org.apache.axis2.cluster.context.ContextEvent;
+import org.apache.axis2.cluster.context.ContextManager;
+import org.apache.axis2.cluster.context.ContextManagerListener;
+import org.apache.axis2.cluster.handlers.ReplicationHandler;
+import org.apache.axis2.cluster.tribes.CommandType;
+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.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.Member;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class TribesContextManager implements ContextManager {
+
+    private static final Log log = LogFactory.getLog(TribesContextManager.class);
+    
+	private ConfigurationContext configContext;
+	private Channel channel;
+	private ContextUpdater updater;
+
+	private Map orphanedServiceCtxs = new HashMap ();
+	private ArrayList addedServiceGrpCtxs = new ArrayList ();
+	private ArrayList addedServiceCtxs = new ArrayList ();
+	private ArrayList listeners = null;
+	
+	public TribesContextManager (ConfigurationContext configurationContext, Channel channel, ContextUpdater updater) {
+		this ();
+		this.configContext = configurationContext;
+		this.channel = channel;
+		this.updater = updater;
+	}
+	
+	public TribesContextManager () {
+		listeners = new ArrayList ();
+	}
+	
+	
+	public void notifyListeners(ContextEvent event, int eventType) {
+
+		for (Iterator it = listeners.iterator(); it.hasNext();) {
+			ContextManagerListener listener = (ContextManagerListener) it.next();
+
+			if (eventType == ContextListenerEventType.ADD_CONTEXT)
+				listener.contextAdded(event);
+			else if (eventType == ContextListenerEventType.REMOVE_CONTEXT)
+				listener.contextRemoved(event);
+			else if (eventType == ContextListenerEventType.UPDATE_CONTEXT)
+				listener.contextUpdated(event);
+		}
+		
+	}
+	
+	public void addContext(AbstractContext context) throws ClusteringFault {
+		ContextCommandMessage 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 (addedServiceCtxs.contains (parentContextId + contextId)) {
+				return; // this is a duplicate replication request
+			}
+
+			if (updater.getServiceGroupProps(parentContextId) != null) {
+				updater.addServiceContext(parentContextId, contextId);
+				comMsg = new ContextCommandMessage(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 ContextCommandMessage(CommandType.CREATE_SERVICE_CONTEXT,
+						parentContextId, contextId, contextId, ContextType.SERVICE_CONTEXT);
+
+				AxisServiceGroup serviceGroupDesc = ((ServiceContext) context)
+						.getServiceGroupContext().getDescription();
+				List list = (List) orphanedServiceCtxs.get(serviceGroupDesc
+						.getServiceGroupName());
+				if (list == null) {
+					list = new ArrayList();
+					orphanedServiceCtxs.put(serviceGroupDesc.getServiceGroupName(), list);
+				}
+				list.add(comMsg);
+			}
+		} else if (context instanceof ServiceGroupContext) {
+
+			if (addedServiceGrpCtxs.contains (contextId)) {
+				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;
+			}
+
+			updater.addServiceGroupContext(contextId);
+
+			comMsg = new ContextCommandMessage(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 list = (List) orphanedServiceCtxs.get(srvGrpCtx.getDescription()
+					.getServiceGroupName());
+
+			if (list != null) {
+				for (Iterator it=list.iterator();it.hasNext();) {
+					
+					ContextCommandMessage command = (ContextCommandMessage) it.next();
+					updater.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) throws ClusteringFault {
+		ContextCommandMessage comMsg = null;
+
+		String contextId = getContextID(context);
+		String parentContextId = getContextID(context.getParent());
+
+		if (context instanceof ServiceContext) {
+			updater.removeServiceContext(parentContextId, contextId);
+			comMsg = new ContextCommandMessage(CommandType.CREATE_SERVICE_GROUP_CONTEXT,
+					parentContextId, contextId, contextId, ContextType.SERVICE_CONTEXT);
+		} else if (context instanceof ServiceGroupContext) {
+			updater.removeServiceGroupContext(contextId);
+			comMsg = new ContextCommandMessage(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) throws ClusteringFault {
+
+		String contextId = getContextID(context);
+		String parentContextId = getContextID(context.getParent());
+
+		Map props = context.getProperties();
+
+		List mapEntryMsgs = null;
+
+		int contextType = 0;
+		if (context instanceof ServiceContext) {
+			contextType = ContextType.SERVICE_CONTEXT;
+			mapEntryMsgs = updater
+					.updateStateOnServiceContext(parentContextId, contextId, props);
+		} else if (context instanceof ServiceGroupContext) {
+			contextType = ContextType.SERVICE_GROUP_CONTEXT;
+			mapEntryMsgs = updater.updateStateOnServiceGroupContext(contextId, props);
+		}
+
+		if (mapEntryMsgs != null) {
+			for (Iterator it=mapEntryMsgs.iterator();it.hasNext();) {
+				ContextUpdateEntryCommandMessage msg = (ContextUpdateEntryCommandMessage) it.next();
+				send(msg);
+			}
+		}
+
+		ContextCommandMessage comMsg = new ContextCommandMessage(CommandType.UPDATE_STATE,
+				parentContextId, contextId, contextId, contextType);
+
+		send(comMsg);
+	}
+
+
+	private void send(ContextCommandMessage msg) throws ClusteringFault {
+		Member[] group = channel.getMembers();
+		log.debug("Group size " + group.length);
+		// send the message
+
+		for (int i=0;i<group.length;i++) {
+			printMember(group[i]);
+		}
+
+		try {
+			channel.send(group, msg, 0);
+		} catch (ChannelException e) {
+			log.error("" + msg, e);
+			String message = "Error sending command message : " + msg;
+			throw new ClusteringFault (message, 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;
+	}
+
+	public void addToDuplicateServiceGroupContexts (String id) {
+		
+	}
+	
+	public void addToDuplicateServiceContexts (String id) {
+		
+	}
+
+	public void addContextManagerListener(ContextManagerListener listener) {
+		listeners.add(listener);
+	}
+
+
+	public void setChannel(Channel channel) {
+		this.channel = channel;
+	}
+
+	public void setUpdater(ContextUpdater updater) {
+		this.updater = updater;
+		
+		//updating the listeners
+		for (Iterator it = listeners.iterator();it.hasNext();) {
+			TribesContextManagerListener listener = (TribesContextManagerListener) it.next();
+			listener.setUpdater(updater);
+		}
+	}
+
+	public void setConfigContext(ConfigurationContext configContext) {
+		this.configContext = configContext;
+	}
+	
+	
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/TribesContextManagerListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/TribesContextManagerListener.java?view=auto&rev=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/TribesContextManagerListener.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/TribesContextManagerListener.java Sun Mar 11 23:51:26 2007
@@ -0,0 +1,121 @@
+/*
+ * 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.context;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.cluster.context.ContextEvent;
+import org.apache.axis2.cluster.context.ContextManagerListener;
+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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class TribesContextManagerListener implements ContextManagerListener {
+
+	ContextUpdater updater = null;
+	ConfigurationContext configurationContext = null;
+	private static final Log log = LogFactory.getLog(TribesContextManagerListener.class);
+	
+	public TribesContextManagerListener (ConfigurationContext configurationContext) {
+		this.configurationContext = configurationContext;
+	}
+	
+	public ContextUpdater getUpdater() {
+		return updater;
+	}
+
+	public void setUpdater(ContextUpdater updater) {
+		this.updater = updater;
+	}
+
+	public void contextAdded(ContextEvent event) {
+		
+		try {
+			
+			if (event.getContextType()==ContextType.SERVICE_GROUP_CONTEXT) {
+				AxisServiceGroup axisServiceGroup = configurationContext.getAxisConfiguration()
+								.getServiceGroup(event.getDescriptionID());
+				ServiceGroupContext ctx = new ServiceGroupContext(configurationContext, axisServiceGroup);
+				ctx.setId(event.getContextID());
+				configurationContext.registerServiceGroupContextintoSoapSessionTable(ctx);
+			} else if (event.getContextType()==ContextType.SERVICE_CONTEXT) {
+				AxisService axisService = configurationContext.getAxisConfiguration().
+								getService(event.getContextID ());
+				ServiceGroupContext srvGrpCtx = configurationContext.getServiceGroupContext(event
+								.getParentContextID ());
+				// This will create service context if one is not available
+				srvGrpCtx.getServiceContext(axisService);
+			}
+			
+		} catch (AxisFault e) {
+			e.printStackTrace();
+		}
+		
+	}
+
+	public void contextRemoved(ContextEvent event) {
+
+	}
+
+	public void contextUpdated(ContextEvent event) {
+
+		if (event.getContextType()==ContextType.SERVICE_GROUP_CONTEXT) {
+			
+			ServiceGroupContext srvGrpCtx = configurationContext.getServiceGroupContext(
+							event.getContextID());
+			Map props = updater.getServiceGroupProps(event.getContextID());
+			if (props != null)
+				srvGrpCtx.setProperties(props);
+				
+		} else if (event.getContextType() == ContextType.SERVICE_CONTEXT) {
+
+			ServiceGroupContext srvGrpCtx = configurationContext.getServiceGroupContext
+							(event.getParentContextID ());
+			Iterator iter = srvGrpCtx.getServiceContexts();
+			String serviceCtxName = event.getDescriptionID();
+			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 = updater.getServiceProps(event.getParentContextID(), event.getContextID());
+
+				if (srvProps != null) {
+					serviceContext.setProperties(srvProps);
+				}
+
+			} else {
+				String message = "Cannot find the ServiceContext with the ID:" + serviceCtxName;
+				log.error(message);
+			}
+
+		}
+		
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesChannelInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesChannelInfo.java?view=auto&rev=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesChannelInfo.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesChannelInfo.java Sun Mar 11 23:51:26 2007
@@ -0,0 +1,94 @@
+/*
+ * 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.info;
+
+import java.io.Serializable;
+
+import org.apache.axis2.cluster.tribes.CommandType;
+import org.apache.axis2.cluster.tribes.context.ContextCommandMessage;
+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 ContextCommandMessage) {
+			ContextCommandMessage comMsg = (ContextCommandMessage) 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;
+	}
+
+}

Copied: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesMemberInfo.java (from r516876, 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/info/TransientTribesMemberInfo.java?view=diff&rev=517114&p1=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesMemberInfo.java&r1=516876&p2=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesMemberInfo.java&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TransientTribesMemberInfo.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesMemberInfo.java Sun Mar 11 23:51:26 2007
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.apache.axis2.cluster.tribes;
+package org.apache.axis2.cluster.tribes.info;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -24,9 +24,9 @@
 
 public class TransientTribesMemberInfo implements MembershipListener {
 
-	private List<Member> liveNodes = new ArrayList<Member>();
+	private List liveNodes = new ArrayList();
 
-	private List<Member> deadNodes = new ArrayList<Member>();
+	private List deadNodes = new ArrayList();
 
 	public void memberAdded(Member member) {
 		liveNodes.add(member);
@@ -38,11 +38,11 @@
 		deadNodes.add(member);
 	}
 
-	public List<Member> getLiveNodes() {
+	public List getLiveNodes() {
 		return liveNodes;
 	}
 
-	public List<Member> getDeadNodes() {
+	public List getDeadNodes() {
 		return deadNodes;
 	}
 }

Copied: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TribesInfoWebService.java (from r516876, 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/info/TribesInfoWebService.java?view=diff&rev=517114&p1=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesInfoWebService.java&r1=516876&p2=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TribesInfoWebService.java&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesInfoWebService.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TribesInfoWebService.java Sun Mar 11 23:51:26 2007
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-package org.apache.axis2.cluster.tribes;
+package org.apache.axis2.cluster.tribes.info;
 
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.axiom.om.OMAbstractFactory;
@@ -39,8 +40,8 @@
 		TransientTribesMemberInfo memberInfo = (TransientTribesMemberInfo) configCtx
 				.getProperty("MEMBER_INFO");
 
-		List<Member> liveMembers = memberInfo.getLiveNodes();
-		List<Member> deadMembers = memberInfo.getDeadNodes();
+		List liveMembers = memberInfo.getLiveNodes();
+		List deadMembers = memberInfo.getDeadNodes();
 
 		SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
 		OMNamespace omNs = factory.createOMNamespace("http://org.apache.axis2.cluster.tribes/xsd",
@@ -49,7 +50,8 @@
 		OMElement memberInfoOM = factory.createOMElement("memberInfo", omNs);
 
 		OMElement liveMemberOM = factory.createOMElement("liveMemberInfo", omNs);
-		for (Member member : liveMembers) {
+		for (Iterator it=liveMembers.iterator();it.hasNext();) {
+			Member member = (Member) it.next();
 			OMElement memberOM = factory.createOMElement("member", omNs);
 			memberOM.addAttribute(factory.createOMAttribute("name", omNs, member.getName()));
 			memberOM.addAttribute(factory.createOMAttribute("host", omNs, String.valueOf(member
@@ -62,7 +64,8 @@
 		}
 
 		OMElement deadMemberOM = factory.createOMElement("deadMemberInfo", omNs);
-		for (Member member : deadMembers) {
+		for (Iterator it=deadMembers.iterator();it.hasNext();) {
+			Member member = (Member) it.next();
 			OMElement memberOM = factory.createOMElement("member", omNs);
 			memberOM.addAttribute(factory.createOMAttribute("name", omNs, member.getName()));
 			memberOM.addAttribute(factory.createOMAttribute("host", omNs, String.valueOf(member

Modified: 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=diff&rev=517114&r1=517113&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ClusterManagerTestCase.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ClusterManagerTestCase.java Sun Mar 11 23:51:26 2007
@@ -19,11 +19,17 @@
 import junit.framework.TestCase;
 
 import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.cluster.ClusteringFault;
+import org.apache.axis2.cluster.tribes.context.TribesContextManager;
+import org.apache.axis2.cluster.tribes.context.TribesContextManagerListener;
 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;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public abstract class ClusterManagerTestCase extends TestCase {
 
@@ -50,18 +56,24 @@
 	protected String serviceName = "testService";
 
 	protected abstract ClusterManager getClusterManager();
+	
+	protected boolean skipChannelTests = false; 
 
+    private static final Log log = LogFactory.getLog(ClusterManagerTestCase.class);
+    
 	protected void setUp() throws Exception {
 
 		clusterManager1 = getClusterManager();
 		clusterManager2 = getClusterManager();
 
-		//ConfigContext of the Node1
 		configurationContext1 = ConfigurationContextFactory.createDefaultConfigurationContext();
-
-		//ConfigContext of the Node2
 		configurationContext2 = ConfigurationContextFactory.createDefaultConfigurationContext();
 
+		TribesContextManagerListener listener1 = new TribesContextManagerListener (configurationContext1);
+		clusterManager1.getContextManager(). addContextManagerListener (listener1);
+		TribesContextManagerListener listener2 = new TribesContextManagerListener (configurationContext2);
+		clusterManager2.getContextManager(). addContextManagerListener (listener2);	
+		
 		//giving both Nodes the same deployment configuration
 
 		axisConfiguration1 = configurationContext1.getAxisConfiguration();
@@ -77,8 +89,16 @@
 		axisConfiguration2.addServiceGroup(serviceGroup2);
 
 		//Initiating ClusterManagers
-		clusterManager1.init(configurationContext1);
-		clusterManager2.init(configurationContext2);
+		try {
+			clusterManager1.init(configurationContext1);
+			clusterManager2.init(configurationContext2);
+		} catch (ClusteringFault e) {
+			String message = "Could not initialize ClusterManagers. Please check the network connection";
+			if (log.isErrorEnabled())
+				log.error(message);
+			
+			skipChannelTests = true;
+		}
 	}
 
 	protected void tearDown() throws Exception {

Modified: 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=diff&rev=517114&r1=517113&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ManageContextTestCase.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ManageContextTestCase.java Sun Mar 11 23:51:26 2007
@@ -21,12 +21,22 @@
 import org.apache.axis2.context.ContextFactory;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 
 public abstract class ManageContextTestCase extends ClusterManagerTestCase {
 
+    private static final Log log = LogFactory.getLog(ClusterManagerTestCase.class);
+    
 	public void testAddContext () throws Exception {
 		
+		if (skipChannelTests) {
+			String message = "Cannot runc the clustering test.Please make sure that your network service is enabled. Skipping the test...";
+			log.error(message);
+			return;
+		}
+		
 		//Adding contexts to the Node1
 		ServiceGroupContext serviceGroupContext1 = ContextFactory.createServiceGroupContext(configurationContext1, serviceGroup1);
 		String sgcID = UUIDGenerator.getUUID();
@@ -35,14 +45,15 @@
 		ServiceContext serviceContext1 = ContextFactory.createServiceContext(serviceGroupContext1, service1);
 		
 		//adding the Contexts to the first configContext 
-		clusterManager1.addContext(serviceGroupContext1);
-		clusterManager1.addContext(serviceContext1);
+		clusterManager1.getContextManager().addContext(serviceGroupContext1);
+		clusterManager1.getContextManager().addContext(serviceContext1);
 		
 		//give a time interval
 		Thread.sleep(5000);
 		
 		//The second configContext should have the newly added contexts.
 		ServiceGroupContext serviceGroupContext2 = configurationContext2.getServiceGroupContext(sgcID);
+		System.out.println("sgs ID 2:" + sgcID);
 		assertNotNull(serviceGroupContext2);
 		
 		Iterator iter = serviceGroupContext2.getServiceContexts();
@@ -56,7 +67,11 @@
 	}
 	
 	public void testRemoveContext () {
-		
+		if (skipChannelTests) {
+			String message = "Cannot runc the clustering test.Please make sure that your network service is enabled. Skipping the test...";
+			log.error(message);
+			return;
+		}
 	}
 	
 	

Modified: 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=diff&rev=517114&r1=517113&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/UpdateStateTestCase.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/UpdateStateTestCase.java Sun Mar 11 23:51:26 2007
@@ -22,9 +22,13 @@
 import org.apache.axis2.context.ContextFactory;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public abstract class UpdateStateTestCase extends ClusterManagerTestCase {
 
+    private static final Log log = LogFactory.getLog(UpdateStateTestCase.class);
+    
 	ServiceContext serviceContext1 = null;
 
 	ServiceGroupContext serviceGroupContext1 = null;
@@ -60,18 +64,24 @@
 		serviceGroupContext1.setProperty(key2, val2);
 		serviceContext1.setProperty(key3, val3);
 
-		clusterManager1.addContext(serviceGroupContext1);
-		clusterManager1.addContext(serviceContext1);
+		clusterManager1.getContextManager().addContext(serviceGroupContext1);
+		clusterManager1.getContextManager().addContext(serviceContext1);
 
-		clusterManager1.updateState(configurationContext1);
-		clusterManager1.updateState(serviceGroupContext1);
-		clusterManager1.updateState(serviceContext1);
+		clusterManager1.getContextManager().updateState(configurationContext1);
+		clusterManager1.getContextManager().updateState(serviceGroupContext1);
+		clusterManager1.getContextManager().updateState(serviceContext1);
 
 		Thread.sleep(1000);
 	}
 
 	public void testAddProperty() throws Exception {
 
+		if (skipChannelTests) {
+			String message = "Cannot runc the clustering test.Please make sure that your network service is enabled. Skipping the test...";
+			log.error(message);
+			return;
+		}
+		
 		//TODO uncomment this when configCtx proeprty updates are supported
 		//		Object val = configurationContext2.getProperty(key1);
 		//		assertNotNull(val);
@@ -99,11 +109,17 @@
 
 	public void testRemoveProperty() throws Exception {
 
+		if (skipChannelTests) {
+			String message = "Cannot runc the clustering test.Please make sure that your network service is enabled. Skipping the test...";
+			log.error(message);
+			return;
+		}
+		
 		serviceGroupContext1.getProperties().remove(key2);
 		serviceContext1.getProperties().remove(key3);
 
-		clusterManager1.updateState(serviceContext1);
-		clusterManager1.updateState(serviceGroupContext1);
+		clusterManager1.getContextManager().updateState(serviceContext1);
+		clusterManager1.getContextManager().updateState(serviceGroupContext1);
 
 		Thread.sleep(1000);
 
@@ -125,11 +141,17 @@
 
 	public void testUpdateProperty() throws Exception {
 
+		if (skipChannelTests) {
+			String message = "Cannot runc the clustering test.Please make sure that your network service is enabled. Skipping the test...";
+			log.error(message);
+			return;
+		}
+		
 		serviceGroupContext1.setProperty(key2, val3);
 		serviceContext1.setProperty(key3, val2);
 
-		clusterManager1.updateState(serviceContext1);
-		clusterManager1.updateState(serviceGroupContext1);
+		clusterManager1.getContextManager().updateState(serviceContext1);
+		clusterManager1.getContextManager().updateState(serviceGroupContext1);
 
 		Thread.sleep(1000);
 

Modified: 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=diff&rev=517114&r1=517113&r2=517114
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java Sun Mar 11 23:51:26 2007
@@ -16,25 +16,12 @@
 
 package org.apache.axis2.cluster;
 
-import org.apache.axis2.context.AbstractContext;
+import org.apache.axis2.cluster.configuration.ConfigurationManager;
+import org.apache.axis2.cluster.context.ContextManager;
 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);
-
-}
+    public void init(ConfigurationContext context) throws ClusteringFault;
+    public ContextManager getContextManager ();
+    public ConfigurationManager getConfigurationManager ();
+}
\ No newline at end of file



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


Mime
View raw message