click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r958187 - in /click/trunk/click/framework/src/org/apache/click: Context.java service/DefaultMessagesMapService.java service/MessagesMapService.java util/MessagesMap.java
Date Sat, 26 Jun 2010 06:17:28 GMT
Author: sabob
Date: Sat Jun 26 06:17:28 2010
New Revision: 958187

URL: http://svn.apache.org/viewvc?rev=958187&view=rev
Log:
made locale an explicit dependency and cut down on threadlocal overhead

Modified:
    click/trunk/click/framework/src/org/apache/click/Context.java
    click/trunk/click/framework/src/org/apache/click/service/DefaultMessagesMapService.java
    click/trunk/click/framework/src/org/apache/click/service/MessagesMapService.java
    click/trunk/click/framework/src/org/apache/click/util/MessagesMap.java

Modified: click/trunk/click/framework/src/org/apache/click/Context.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/Context.java?rev=958187&r1=958186&r2=958187&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/Context.java (original)
+++ click/trunk/click/framework/src/org/apache/click/Context.java Sat Jun 26 06:17:28 2010
@@ -634,10 +634,10 @@ public class Context {
      * @return a new messages map with the messages for the target.
      */
     public Map<String, String> createMessagesMap(Class<?> baseClass, String globalResource)
{
-        MessagesMapService messagesMapService = 
+        MessagesMapService messagesMapService =
             clickServlet.getConfigService().getMessagesMapService();
-        
-        return messagesMapService.createMessagesMap(baseClass, globalResource);
+
+        return messagesMapService.createMessagesMap(baseClass, globalResource, getLocale());
     }
 
     /**

Modified: click/trunk/click/framework/src/org/apache/click/service/DefaultMessagesMapService.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/DefaultMessagesMapService.java?rev=958187&r1=958186&r2=958187&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/service/DefaultMessagesMapService.java
(original)
+++ click/trunk/click/framework/src/org/apache/click/service/DefaultMessagesMapService.java
Sat Jun 26 06:17:28 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.click.service;
 
+import java.util.Locale;
 import java.util.Map;
 
 import javax.servlet.ServletContext;
@@ -46,19 +47,20 @@ public class DefaultMessagesMapService i
     }
 
     /**
-     * Return a MessagesMap instance for the target baseClass and global 
-     * resource name.
-     * 
+     * Return a MessagesMap instance for the target baseClass, global resource
+     * name and locale.
+     *
      * @param baseClass the target class
      * @param globalResource the global resource bundle name
-     * 
+     * @param the users Locale
+     *
      * @return a MessagesMap instance.
-     * 
-     * @see MessagesMapService#createMessagesMap(Class, String)
+     *
+     * @see MessagesMapService#createMessagesMap(java.lang.Class, java.lang.String, java.util.Locale)
      * @see MessagesMap#MessagesMap(Class, String)
      */
     public Map<String, String> createMessagesMap(Class<?> baseClass,
-            String globalResource) {
-        return new MessagesMap(baseClass, globalResource);
+        String globalResource, Locale locale) {
+        return new MessagesMap(baseClass, globalResource, locale);
     }
 }

Modified: click/trunk/click/framework/src/org/apache/click/service/MessagesMapService.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/MessagesMapService.java?rev=958187&r1=958186&r2=958187&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/service/MessagesMapService.java (original)
+++ click/trunk/click/framework/src/org/apache/click/service/MessagesMapService.java Sat Jun
26 06:17:28 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.click.service;
 
+import java.util.Locale;
 import java.util.Map;
 
 import javax.servlet.ServletContext;
@@ -48,13 +49,13 @@ import javax.servlet.ServletContext;
  *
  * public class CustomMessagesMapService implements MessagesMapService {
  *
- *     public Map<String, String> createMessagesMap(Class&lt;?&gt; baseClass,
String globalResource) {
- *         return new MessagesMap(baseClass, globalResource); 
+ *     public Map<String, String> createMessagesMap(Class&lt;?&gt; baseClass,
String globalResource, Locale locale) {
+ *         return new MyMessagesMap(baseClass, globalResource, locale);
  *     }
  * } </pre>
  */
 public interface MessagesMapService {
-    
+
     /**
      * Initialize the MessagesMapService with the given application servlet context.
      * <p/>
@@ -69,14 +70,16 @@ public interface MessagesMapService {
      * Destroy the MessagesMapService.
      */
     public void onDestroy();
-    
+
     /**
      * Return a new messages map for the given baseClass (a page or control)
-     * and the given global resource bundle name. 
-
+     * and the given global resource bundle name.
+     *
      * @param baseClass the target class
-     * @param globalResource the global resource bundle name     
+     * @param globalResource the global resource bundle name
+     * @param the users Locale
      * @return a new messages map with the messages for the target.
      */
-    public Map<String, String> createMessagesMap(Class<?> baseClass, String globalResource);
+    public Map<String, String> createMessagesMap(Class<?> baseClass,
+        String globalResource, Locale locale);
 }

Modified: click/trunk/click/framework/src/org/apache/click/util/MessagesMap.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/util/MessagesMap.java?rev=958187&r1=958186&r2=958187&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/util/MessagesMap.java (original)
+++ click/trunk/click/framework/src/org/apache/click/util/MessagesMap.java Sat Jun 26 06:17:28
2010
@@ -107,12 +107,27 @@ public class MessagesMap implements Map<
      * @param globalResource the global resource bundle name
      */
     public MessagesMap(Class<?> baseClass, String globalResource) {
+        this(baseClass, globalResource, Context.getThreadLocalContext().getLocale());
+    }
+
+    /**
+     * Create a resource bundle messages <tt>Map</tt> adaptor for the given
+     * object's class resource bundle, the global resource bundle and
+     * <tt>Context</tt>.
+     * <p/>
+     * Messages located in the object's resource bundle will override any
+     * messages defined in the global resource bundle.
+     *
+     * @param baseClass the target class
+     * @param globalResource the global resource bundle name
+     * @param the resource bundle locale.
+     */
+    public MessagesMap(Class<?> baseClass, String globalResource, Locale locale) {
         Validate.notNull(baseClass, "Null object parameter");
 
         this.baseClass = baseClass;
-        this.locale = Context.getThreadLocalContext().getLocale();
-
         this.globalBaseName = globalResource;
+        this.locale = locale;
     }
 
     // --------------------------------------------------------- Public Methods



Mime
View raw message