Author: azeez
Date: Tue May 22 22:32:06 2007
New Revision: 540846

URL: http://svn.apache.org/viewvc?view=rev&rev=540846
Log:
Avoid sending Update messages if there are no properties to be updated


Modified:
    
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java
    
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java
    
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateConfigurationContextCommand.java
    
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateContextCommand.java
    
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceContextCommand.java
    
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceGroupContextCommand.java
    
webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/UpdateStateTestCase.java

Modified: 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java?view=diff&rev=540846&r1=540845&r2=540846
==============================================================================
--- 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java
 Tue May 22 22:32:06 2007
@@ -29,39 +29,45 @@
  */
 public final class ContextClusteringCommandFactory {
 
-    public static ContextClusteringCommand getUpdateMessage(AbstractContext 
context,
+    public static ContextClusteringCommand getUpdateCommand(AbstractContext 
context,
                                                             Map 
excludedPropertyPatterns) {
 
         ContextClusteringCommand cmd = null;
+        UpdateContextCommand updateCmd = (UpdateContextCommand) cmd;
         if (context instanceof ConfigurationContext) {
-            cmd = new UpdateConfigurationContextCommand();
-            fillProperties((UpdateContextCommand) cmd,
+            updateCmd = new UpdateConfigurationContextCommand();
+            fillProperties(updateCmd,
                            context,
                            excludedPropertyPatterns);
         } else if (context instanceof ServiceGroupContext) {
             ServiceGroupContext sgCtx = (ServiceGroupContext) context;
-            cmd = new UpdateServiceGroupContextCommand();
-            UpdateServiceGroupContextCommand updateSgCmd = 
(UpdateServiceGroupContextCommand) cmd;
+            updateCmd = new UpdateServiceGroupContextCommand();
+            UpdateServiceGroupContextCommand updateSgCmd =
+                    (UpdateServiceGroupContextCommand) updateCmd;
 
             
updateSgCmd.setServiceGroupName(sgCtx.getDescription().getServiceGroupName());
             updateSgCmd.setServiceGroupContextId(sgCtx.getId());
-            fillProperties((UpdateContextCommand) cmd,
+            fillProperties(updateCmd,
                            context,
                            excludedPropertyPatterns);
             //TODO: impl
         } else if (context instanceof ServiceContext) {
             ServiceContext serviceCtx = (ServiceContext) context;
-            cmd = new UpdateServiceContextCommand();
-            UpdateServiceContextCommand updateServiceCmd = 
(UpdateServiceContextCommand) cmd;
+            updateCmd = new UpdateServiceContextCommand();
+            UpdateServiceContextCommand updateServiceCmd =
+                    (UpdateServiceContextCommand) updateCmd;
 
             // TODO impl
             updateServiceCmd.setServiceGroupName(serviceCtx.getGroupName());
             
updateServiceCmd.setServiceName(serviceCtx.getAxisService().getName());
-            fillProperties((UpdateContextCommand) cmd,
+            fillProperties(updateCmd,
                            context,
                            excludedPropertyPatterns);
         }
         context.clearPropertyDifferences(); // Once we send the diffs, we 
should clear the diffs
+        if(updateCmd != null && updateCmd.isPropertiesEmpty()){
+            cmd = null;
+        }
         return cmd;
     }
 
@@ -125,7 +131,7 @@
         return false;
     }
 
-    public static ContextClusteringCommand getCreateMessage(AbstractContext 
abstractContext) {
+    public static ContextClusteringCommand getCreateCommand(AbstractContext 
abstractContext) {
         if (abstractContext instanceof ServiceGroupContext) {
             ServiceGroupContext sgCtx = (ServiceGroupContext) abstractContext;
             ServiceGroupContextCommand cmd = new 
CreateServiceGroupContextCommand();
@@ -148,7 +154,7 @@
         return null;
     }
 
-    public static ContextClusteringCommand getRemoveMessage(AbstractContext 
abstractContext) {
+    public static ContextClusteringCommand getRemoveCommand(AbstractContext 
abstractContext) {
         if (abstractContext instanceof ServiceGroupContext) {
             ServiceGroupContext sgCtx = (ServiceGroupContext) abstractContext;
             ServiceGroupContextCommand cmd = new 
DeleteServiceGroupContextCommand();

Modified: 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java?view=diff&rev=540846&r1=540845&r2=540846
==============================================================================
--- 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java
 Tue May 22 22:32:06 2007
@@ -48,18 +48,20 @@
     }
 
     public void addContext(final AbstractContext context) throws 
ClusteringFault {
-        
processor.process(ContextClusteringCommandFactory.getCreateMessage(context));
+        
processor.process(ContextClusteringCommandFactory.getCreateCommand(context));
     }
 
     public void removeContext(AbstractContext context) throws ClusteringFault {
-        
processor.process(ContextClusteringCommandFactory.getRemoveMessage(context));
+        
processor.process(ContextClusteringCommandFactory.getRemoveCommand(context));
     }
 
     public void updateContext(AbstractContext context) throws ClusteringFault {
         ContextClusteringCommand message =
-                ContextClusteringCommandFactory.getUpdateMessage(context,
+                ContextClusteringCommandFactory.getUpdateCommand(context,
                                                                  
excludedReplicationPatterns);
-        processor.process(message);
+        if (message != null) {
+            processor.process(message);
+        }
     }
 
     public boolean isContextClusterable(AbstractContext context) {

Modified: 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateConfigurationContextCommand.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateConfigurationContextCommand.java?view=diff&rev=540846&r1=540845&r2=540846
==============================================================================
--- 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateConfigurationContextCommand.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateConfigurationContextCommand.java
 Tue May 22 22:32:06 2007
@@ -39,6 +39,10 @@
         return UPDATE_CONFIGURATION_CONTEXT;
     }
 
+    public boolean isPropertiesEmpty(){
+        return propertyUpdater.getProperties().isEmpty();
+    }
+
     public void addProperty(PropertyDifference diff) {
         if (propertyUpdater.getProperties() == null) {
             propertyUpdater.setProperties(new HashMap());

Modified: 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateContextCommand.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateContextCommand.java?view=diff&rev=540846&r1=540845&r2=540846
==============================================================================
--- 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateContextCommand.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateContextCommand.java
 Tue May 22 22:32:06 2007
@@ -24,4 +24,6 @@
  */
 public interface UpdateContextCommand extends Serializable {
     void addProperty(PropertyDifference diff);
+
+    boolean isPropertiesEmpty();
 }

Modified: 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceContextCommand.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceContextCommand.java?view=diff&rev=540846&r1=540845&r2=540846
==============================================================================
--- 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceContextCommand.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceContextCommand.java
 Tue May 22 22:32:06 2007
@@ -65,6 +65,10 @@
 //        propertyUpdater.updateProperties(sgCtx);
     }
 
+    public boolean isPropertiesEmpty() {
+        return propertyUpdater.getProperties().isEmpty();
+    }
+
     public int getCommandType() {
         return UPDATE_SERVICE_CONTEXT;
     }

Modified: 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceGroupContextCommand.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceGroupContextCommand.java?view=diff&rev=540846&r1=540845&r2=540846
==============================================================================
--- 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceGroupContextCommand.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/commands/UpdateServiceGroupContextCommand.java
 Tue May 22 22:32:06 2007
@@ -41,6 +41,10 @@
         return UPDATE_SERVICE_GROUP_CONTEXT;
     }
 
+    public boolean isPropertiesEmpty() {
+        return propertyUpdater.getProperties().isEmpty();
+    }
+    
     public void addProperty(PropertyDifference diff) {
         if (propertyUpdater.getProperties() == null) {
             propertyUpdater.setProperties(new HashMap());

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=540846&r1=540845&r2=540846
==============================================================================
--- 
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
 Tue May 22 22:32:06 2007
@@ -49,7 +49,8 @@
     public void setUp() throws Exception {
         super.setUp();
         if (skipChannelTests) {
-            String message = "Cannot run the clustering test setUp.Please make 
sure that your network service is enabled. Skipping the test...";
+            String message = "Cannot run the clustering test setUp.Please make 
sure that your " +
+                             "network service is enabled. Skipping the 
test...";
             log.error(message);
             return;
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to