james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r799828 - /james/jsieve/trunk/mailet/src/main/java/org/apache/jsieve/mailet/ActionDispatcher.java
Date Sat, 01 Aug 2009 11:00:12 GMT
Author: rdonkin
Date: Sat Aug  1 11:00:12 2009
New Revision: 799828

URL: http://svn.apache.org/viewvc?rev=799828&view=rev
Log:
JSIEVE-68 Switch to thread safe map https://issues.apache.org/jira/browse/JSIEVE-68

Modified:
    james/jsieve/trunk/mailet/src/main/java/org/apache/jsieve/mailet/ActionDispatcher.java

Modified: james/jsieve/trunk/mailet/src/main/java/org/apache/jsieve/mailet/ActionDispatcher.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/mailet/src/main/java/org/apache/jsieve/mailet/ActionDispatcher.java?rev=799828&r1=799827&r2=799828&view=diff
==============================================================================
--- james/jsieve/trunk/mailet/src/main/java/org/apache/jsieve/mailet/ActionDispatcher.java
(original)
+++ james/jsieve/trunk/mailet/src/main/java/org/apache/jsieve/mailet/ActionDispatcher.java
Sat Aug  1 11:00:12 2009
@@ -19,8 +19,8 @@
 
 package org.apache.jsieve.mailet;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import javax.mail.MessagingException;
 
@@ -33,6 +33,8 @@
 
 /**
  * Dynamically dispatches an Action depending on the type of Action received at runtime.

+ * <h4>Thread Safety</h4>
+ * <p>An instance maybe safe accessed concurrently by multiple threads.</p>
  */
 public class ActionDispatcher
 {   
@@ -41,7 +43,7 @@
      * handle the Action.
      * <Action, MailAction>
      */ 
-    private Map<Class, MailAction> fieldMailActionMap;
+    private ConcurrentMap<Class, MailAction> fieldMailActionMap;
 
     /**
      * Constructor for ActionDispatcher.
@@ -63,7 +65,7 @@
      */
     public void execute(final Action anAction, final Mail aMail, final ActionContext context)
throws MessagingException
     {
-        MailAction mailAction = getMethodMap().get(anAction.getClass());
+        final MailAction mailAction = getMethodMap().get(anAction.getClass());
         mailAction.execute(anAction, aMail, context);
     }
 
@@ -71,7 +73,7 @@
      * Returns the methodMap.
      * @return Map
      */
-    public Map<Class, MailAction> getMethodMap()
+    public ConcurrentMap<Class, MailAction> getMethodMap()
     {
         return fieldMailActionMap;
     }    
@@ -80,9 +82,9 @@
      * Returns a new methodMap.
      * @return Map
      */
-    private Map<Class, MailAction> defaultMethodMap()
+    private ConcurrentMap<Class, MailAction> defaultMethodMap()
     {
-        Map<Class, MailAction> actionMap = new HashMap<Class, MailAction>(4);
+        final ConcurrentMap<Class, MailAction> actionMap = new ConcurrentHashMap<Class,
MailAction>(4);
         actionMap.put(ActionFileInto.class, new FileIntoAction());
         actionMap.put(ActionKeep.class, new KeepAction());
         actionMap.put(ActionRedirect.class, new RedirectAction());
@@ -94,7 +96,7 @@
      * Sets the mail action mail.
      * @param mailActionMap <Action, MailAction> not null
      */
-    protected void setMethodMap(Map<Class, MailAction>  mailActionMap)
+    protected void setMethodMap(ConcurrentMap<Class, MailAction>  mailActionMap)
     {
         fieldMailActionMap = mailActionMap;
     }



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


Mime
View raw message