myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r956099 - in /myfaces/extensions/cdi/trunk: examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/message/client/ jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/me...
Date Fri, 18 Jun 2010 19:08:27 GMT
Author: gpetracek
Date: Fri Jun 18 19:08:27 2010
New Revision: 956099

URL: http://svn.apache.org/viewvc?rev=956099&view=rev
Log:
EXTCDI-24 solution #3

Removed:
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageContextAware.java
Modified:
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/message/client/ClientAwareMessageResolverProducer.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/FacesMessageInterpolator.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/JsfAwareApplicationMessagesMessageResolver.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageResolver.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/AbstractFormatterAwareMessageInterpolator.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/CompositeMessageInterpolator.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultFormatterFactory.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageInterpolator.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/ELAwareMessageInterpolator.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NumberedArgumentAwareMessageInterpolator.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java

Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/message/client/ClientAwareMessageResolverProducer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/message/client/ClientAwareMessageResolverProducer.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/message/client/ClientAwareMessageResolverProducer.java
(original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/message/client/ClientAwareMessageResolverProducer.java
Fri Jun 18 19:08:27 2010
@@ -28,7 +28,6 @@ import org.apache.myfaces.extensions.cdi
 import javax.enterprise.inject.Produces;
 import javax.enterprise.context.RequestScoped;
 import javax.faces.context.FacesContext;
-import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
 
@@ -52,8 +51,8 @@ public class ClientAwareMessageResolverP
     {
         return new MessageResolver()
         {
-            public String getMessage(String messageDescriptor,
-                                     Locale locale,
+            public String getMessage(MessageContext messageContext,
+                                     String messageDescriptor,
                                      Map<Class, Class<? extends MessagePayload>>
messagePayload)
             {
                 FacesContext facesContext = FacesContext.getCurrentInstance();

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/FacesMessageInterpolator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/FacesMessageInterpolator.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/FacesMessageInterpolator.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/FacesMessageInterpolator.java
Fri Jun 18 19:08:27 2010
@@ -19,7 +19,6 @@
 package org.apache.myfaces.extensions.cdi.javaee.jsf.impl.message;
 
 import org.apache.myfaces.extensions.cdi.message.api.MessageInterpolator;
-import org.apache.myfaces.extensions.cdi.message.api.MessageContextAware;
 import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
 import org.apache.myfaces.extensions.cdi.message.impl.CompositeMessageInterpolator;
 import org.apache.myfaces.extensions.cdi.message.impl.ELAwareMessageInterpolator;
@@ -31,7 +30,7 @@ import java.io.Serializable;
 /**
  * @author Gerhard Petracek
  */
-class FacesMessageInterpolator implements MessageInterpolator, MessageContextAware
+class FacesMessageInterpolator implements MessageInterpolator
 {
     private MessageInterpolator messageInterpolator;
 
@@ -49,25 +48,8 @@ class FacesMessageInterpolator implement
         }
     }
 
-    public String interpolate(String messageText, Serializable... arguments)
+    public String interpolate(MessageContext messageContext, String messageText, Serializable...
arguments)
     {
-        return this.messageInterpolator.interpolate(messageText, arguments);
-    }
-
-    public void setMessageContext(MessageContext messageContext)
-    {
-        if(this.messageInterpolator instanceof MessageContextAware)
-        {
-            ((MessageContextAware)this.messageInterpolator).setMessageContext(messageContext);
-        }
-    }
-
-    public MessageContext getMessageContext()
-    {
-        if(this.messageInterpolator instanceof MessageContextAware)
-        {
-            return ((MessageContextAware)this.messageInterpolator).getMessageContext();
-        }
-        return null;
+        return this.messageInterpolator.interpolate(messageContext, messageText, arguments);
     }
 }

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/JsfAwareApplicationMessagesMessageResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/JsfAwareApplicationMessagesMessageResolver.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/JsfAwareApplicationMessagesMessageResolver.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/message/JsfAwareApplicationMessagesMessageResolver.java
Fri Jun 18 19:08:27 2010
@@ -19,6 +19,7 @@
 package org.apache.myfaces.extensions.cdi.javaee.jsf.impl.message;
 
 import org.apache.myfaces.extensions.cdi.message.api.MessageResolver;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
 import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.JsfUtils;
 
@@ -31,8 +32,8 @@ import java.util.MissingResourceExceptio
  */
 class JsfAwareApplicationMessagesMessageResolver implements MessageResolver
 {
-    public String getMessage(String messageDescriptor,
-                             Locale locale,
+    public String getMessage(MessageContext messageContext,
+                             String messageDescriptor,
                              Map<Class, Class<? extends MessagePayload>> messagePayload)
     {
         if (!isKey(messageDescriptor))
@@ -44,11 +45,11 @@ class JsfAwareApplicationMessagesMessage
         {
             messageDescriptor = extractKey(messageDescriptor);
 
-            return JsfUtils.getCustomFacesMessageBundle(locale).getString(messageDescriptor);
+            return JsfUtils.getCustomFacesMessageBundle(messageContext.getLocale()).getString(messageDescriptor);
         }
         catch (MissingResourceException e)
         {
-            return defaultFacesMessage(messageDescriptor, locale);
+            return defaultFacesMessage(messageDescriptor, messageContext.getLocale());
         }
     }
 

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java
Fri Jun 18 19:08:27 2010
@@ -29,11 +29,13 @@ public interface MessageInterpolator
     /**
      * replaces the arguments of the given message with the given arguments
      *
+     * @param messageContext the current {@link org.apache.myfaces.extensions.cdi.message.api.MessageContext}
+     * instead of a MessageContextAware interface. we need it to avoid expensive operations
like locking or deep cloning
      * @param messageText the message text which has to be interpolated
      * @param arguments a list of numbered and/or named arguments for the current message
      * @return the final (interpolated) message text
      *         if it was possible to replace the parameters with the given attributes
      *         the unmodified messageText otherwise
      */
-    String interpolate(String messageText, Serializable... arguments);
+    String interpolate(MessageContext messageContext, String messageText, Serializable...
arguments);
 }

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageResolver.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageResolver.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageResolver.java
Fri Jun 18 19:08:27 2010
@@ -20,7 +20,6 @@ package org.apache.myfaces.extensions.cd
 
 import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
 
-import java.util.Locale;
 import java.util.Map;
 
 /**
@@ -31,10 +30,12 @@ public interface MessageResolver
     static final String MISSING_RESOURCE_MARKER = "???";
 
     /**
+     * @param messageContext the current {@link org.apache.myfaces.extensions.cdi.message.api.MessageContext}
      * @param messageDescriptor the message key (or in-lined text) of the current message
-     * @param locale the current locale
      * @param payload the payload of the message e.g. to use different message sources
      * @return the final but not interpolated message text
      */
-    String getMessage(String messageDescriptor, Locale locale, Map<Class, Class<? extends
MessagePayload>> payload);
+    String getMessage(MessageContext messageContext,
+                      String messageDescriptor,
+                      Map<Class, Class<? extends MessagePayload>> payload);
 }

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/AbstractFormatterAwareMessageInterpolator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/AbstractFormatterAwareMessageInterpolator.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/AbstractFormatterAwareMessageInterpolator.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/AbstractFormatterAwareMessageInterpolator.java
Fri Jun 18 19:08:27 2010
@@ -19,7 +19,6 @@
 package org.apache.myfaces.extensions.cdi.message.impl;
 
 import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
-import org.apache.myfaces.extensions.cdi.message.api.MessageContextAware;
 import org.apache.myfaces.extensions.cdi.message.api.MessageInterpolator;
 import org.apache.myfaces.extensions.cdi.message.api.Localizable;
 import org.apache.myfaces.extensions.cdi.message.api.Formatter;
@@ -30,12 +29,10 @@ import java.io.Serializable;
  * @author Gerhard Petracek
  */
 abstract class AbstractFormatterAwareMessageInterpolator
-        implements MessageInterpolator, MessageContextAware, Serializable
+        implements MessageInterpolator, Serializable
 {
-    protected MessageContext messageContext;
-
     @SuppressWarnings({"unchecked"})
-    protected Object formatAsString(Object value)
+    protected Object formatAsString(MessageContext messageContext, Object value)
     {
         if (value == null)
         {
@@ -47,30 +44,20 @@ abstract class AbstractFormatterAwareMes
             return value;
         }
 
-        if (this.messageContext.config().getFormatterFactory() != null)
+        if (messageContext.config().getFormatterFactory() != null)
         {
-            Formatter formatter = this.messageContext.config().getFormatterFactory().findFormatter(value.getClass());
+            Formatter formatter = messageContext.config().getFormatterFactory().findFormatter(value.getClass());
             if (formatter != null)
             {
-                return formatter.format(this.messageContext, value);
+                return formatter.format(messageContext, value);
             }
         }
 
         if (value instanceof Localizable)
         {
-            return ((Localizable) value).toString(this.messageContext);
+            return ((Localizable) value).toString(messageContext);
         }
 
         return value;
     }
-
-    public void setMessageContext(MessageContext messageContext)
-    {
-        this.messageContext = messageContext;
-    }
-
-    public MessageContext getMessageContext()
-    {
-        throw new UnsupportedOperationException();
-    }
 }

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/CompositeMessageInterpolator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/CompositeMessageInterpolator.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/CompositeMessageInterpolator.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/CompositeMessageInterpolator.java
Fri Jun 18 19:08:27 2010
@@ -19,7 +19,6 @@
 package org.apache.myfaces.extensions.cdi.message.impl;
 
 import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
-import org.apache.myfaces.extensions.cdi.message.api.MessageContextAware;
 import org.apache.myfaces.extensions.cdi.message.api.MessageInterpolator;
 
 import java.io.Serializable;
@@ -27,39 +26,24 @@ import java.io.Serializable;
 /**
  * @author Gerhard Petracek
  */
-public class CompositeMessageInterpolator implements MessageInterpolator, MessageContextAware,
Serializable
+public class CompositeMessageInterpolator implements MessageInterpolator, Serializable
 {
     private static final long serialVersionUID = 7138747032627702804L;
     private MessageInterpolator[] messageInterpolators;
-    private MessageContext messageContext;
 
     public CompositeMessageInterpolator(MessageInterpolator... messageInterpolators)
     {
         this.messageInterpolators = messageInterpolators;
     }
 
-    public String interpolate(String messageDescriptor, Serializable... arguments)
+    public String interpolate(MessageContext messageContext, String messageDescriptor, Serializable...
arguments)
     {
         String result = messageDescriptor;
         for (MessageInterpolator messageInterpolator : this.messageInterpolators)
         {
-            if (messageInterpolator instanceof MessageContextAware)
-            {
-                ((MessageContextAware) messageInterpolator).setMessageContext(this.messageContext);
-            }
-            result = messageInterpolator.interpolate(result, arguments);
+            result = messageInterpolator.interpolate(messageContext, result, arguments);
         }
 
         return result;
     }
-
-    public void setMessageContext(MessageContext messageContext)
-    {
-        this.messageContext = messageContext;
-    }
-
-    public MessageContext getMessageContext()
-    {
-        throw new UnsupportedOperationException();
-    }
 }
\ No newline at end of file

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultFormatterFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultFormatterFactory.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultFormatterFactory.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultFormatterFactory.java
Fri Jun 18 19:08:27 2010
@@ -81,7 +81,7 @@ public class DefaultFormatterFactory imp
 
             if (found == null)
             {
-                this.logger.warning("default formatter used for: " + type.getName());
+                this.logger.info("default formatter used for: " + type.getName());
                 found = FormatterBuilder.createFormatter(type);
             }
 

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java
Fri Jun 18 19:08:27 2010
@@ -20,7 +20,6 @@ package org.apache.myfaces.extensions.cd
 
 import org.apache.myfaces.extensions.cdi.message.api.Message;
 import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
-import org.apache.myfaces.extensions.cdi.message.api.MessageContextAware;
 import org.apache.myfaces.extensions.cdi.message.api.MessageContextConfigAware;
 import org.apache.myfaces.extensions.cdi.message.api.MessageResolver;
 import org.apache.myfaces.extensions.cdi.message.api.MessageInterpolator;
@@ -347,38 +346,13 @@ class DefaultMessageBuilder implements M
 
     private String resolveMessage(MessageResolver messageResolver, Message baseMessage)
     {
-        if (messageResolver instanceof MessageContextAware)
-        {
-            ((MessageContextAware) messageResolver).setMessageContext(this.messageContext);
-        }
-
-        try
-        {
-            return messageResolver
-                    .getMessage(baseMessage.getDescriptor(), this.messageContext.getLocale(),
baseMessage.getPayload());
-        }
-        finally
-        {
-            cleanupMessageContext(messageResolver);
-        }
+        return messageResolver.getMessage(this.messageContext, baseMessage.getDescriptor(),
baseMessage.getPayload());
     }
 
     private String interpolateMessage(MessageInterpolator messageInterpolator,
                                       String messageDescriptor, Serializable... arguments)
     {
-        if (messageInterpolator instanceof MessageContextAware)
-        {
-            ((MessageContextAware) messageInterpolator).setMessageContext(this.messageContext);
-        }
-
-        try
-        {
-            return messageInterpolator.interpolate(getEscapedTemplate(messageDescriptor),
arguments);
-        }
-        finally
-        {
-            cleanupMessageContext(messageInterpolator);
-        }
+        return messageInterpolator.interpolate(this.messageContext, getEscapedTemplate(messageDescriptor),
arguments);
     }
 
     private String getEscapedTemplate(String messageDescriptor)
@@ -391,14 +365,6 @@ class DefaultMessageBuilder implements M
         return messageDescriptor;
     }
 
-    private void cleanupMessageContext(Object object)
-    {
-        if (object instanceof MessageContextAware)
-        {
-            ((MessageContextAware) object).setMessageContext(null);
-        }
-    }
-
     protected MessageContext getMessageContext()
     {
         return this.messageContext;

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageInterpolator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageInterpolator.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageInterpolator.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageInterpolator.java
Fri Jun 18 19:08:27 2010
@@ -19,6 +19,7 @@
 package org.apache.myfaces.extensions.cdi.message.impl;
 
 import org.apache.myfaces.extensions.cdi.message.api.MessageInterpolator;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
 
 import java.io.Serializable;
 
@@ -29,7 +30,7 @@ class DefaultMessageInterpolator impleme
 {
     private static final long serialVersionUID = -8854087197813424812L;
 
-    public String interpolate(String messageDescriptor, Serializable... arguments)
+    public String interpolate(MessageContext messageContext, String messageDescriptor, Serializable...
arguments)
     {
         return messageDescriptor;
     }

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/ELAwareMessageInterpolator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/ELAwareMessageInterpolator.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/ELAwareMessageInterpolator.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/ELAwareMessageInterpolator.java
Fri Jun 18 19:08:27 2010
@@ -19,6 +19,7 @@
 package org.apache.myfaces.extensions.cdi.message.impl;
 
 import org.apache.myfaces.extensions.cdi.message.api.NamedArgument;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
 import org.apache.myfaces.extensions.cdi.message.impl.spi.ELProvider;
 import org.apache.myfaces.extensions.cdi.message.impl.spi.SimpleELContext;
 
@@ -47,13 +48,13 @@ public class ELAwareMessageInterpolator 
         this.elProvider = elProvider;
     }
 
-    public String interpolate(String messageDescriptor, Serializable... arguments)
+    public String interpolate(MessageContext messageContext, String messageDescriptor, Serializable...
arguments)
     {
         List<NamedArgument> namedArguments = addNamedArguments(arguments);
 
         if (namedArguments.size() > 0)
         {
-            return interpolateNamedArguments(messageDescriptor, namedArguments);
+            return interpolateNamedArguments(messageContext, messageDescriptor, namedArguments);
         }
         return messageDescriptor;
     }
@@ -74,7 +75,9 @@ public class ELAwareMessageInterpolator 
     }
 
     //TODO add warning for unused arguments,...
-    private String interpolateNamedArguments(String messageDescriptor, List<NamedArgument>
namedArguments)
+    private String interpolateNamedArguments(MessageContext messageContext,
+                                             String messageDescriptor,
+                                             List<NamedArgument> namedArguments)
     {
         ExpressionFactory factory = this.elProvider.createExpressionFactory();
         SimpleELContext elContext = this.elProvider.createELContext(this.elProvider.createELResolver());
@@ -82,7 +85,8 @@ public class ELAwareMessageInterpolator 
         for (NamedArgument argument : namedArguments)
         {
             Serializable value = argument.getValue();
-            elContext.setVariable(argument.getName(), factory.createValueExpression(value,
value.getClass()));
+            Class valueType = value != null ? value.getClass() : Object.class;
+            elContext.setVariable(argument.getName(), factory.createValueExpression(value,
valueType));
         }
 
         Matcher matcher = MESSAGE_ARGS_PATTERN.matcher(messageDescriptor);
@@ -99,7 +103,7 @@ public class ELAwareMessageInterpolator 
 
             if (value != null && !isUnresolvedArgument(expression, value))
             {
-                resolvedArgumentValue = formatAsString(value).toString();
+                resolvedArgumentValue = formatAsString(messageContext, value).toString();
             }
             else
             {

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NumberedArgumentAwareMessageInterpolator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NumberedArgumentAwareMessageInterpolator.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NumberedArgumentAwareMessageInterpolator.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NumberedArgumentAwareMessageInterpolator.java
Fri Jun 18 19:08:27 2010
@@ -19,6 +19,7 @@
 package org.apache.myfaces.extensions.cdi.message.impl;
 
 import org.apache.myfaces.extensions.cdi.message.api.NamedArgument;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
 
 import java.io.Serializable;
 import java.text.MessageFormat;
@@ -32,13 +33,13 @@ public class NumberedArgumentAwareMessag
 {
     private static final long serialVersionUID = 8699632465559596371L;
 
-    public String interpolate(String messageDescriptor, Serializable... arguments)
+    public String interpolate(MessageContext messageContext, String messageDescriptor, Serializable...
arguments)
     {
         Serializable[] numberedArguments = addNumberedArguments(arguments);
 
         if (numberedArguments.length > 0)
         {
-            return formatMessage(messageDescriptor, numberedArguments);
+            return formatMessage(messageContext, messageDescriptor, numberedArguments);
         }
 
         return messageDescriptor;
@@ -60,7 +61,7 @@ public class NumberedArgumentAwareMessag
     }
 
     //TODO add warning for unused arguments,...
-    private String formatMessage(String messageDescriptor, Serializable[] arguments)
+    private String formatMessage(MessageContext messageContext, String messageDescriptor,
Serializable[] arguments)
     {
         Object[] localizedArguments = null;
         Object argument;
@@ -69,7 +70,7 @@ public class NumberedArgumentAwareMessag
         for (int i = 0; i < arguments.length; i++)
         {
             argument = arguments[i];
-            localizedArgument = formatAsString(argument);
+            localizedArgument = formatAsString(messageContext, argument);
 
             if (localizedArgument != argument)
             {
@@ -82,8 +83,7 @@ public class NumberedArgumentAwareMessag
             }
         }
 
-        MessageFormat messageFormat = new MessageFormat(
-                messageDescriptor, this.messageContext.getLocale());
+        MessageFormat messageFormat = new MessageFormat(messageDescriptor, messageContext.getLocale());
 
         if (localizedArguments == null)
         {

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java
Fri Jun 18 19:08:27 2010
@@ -19,9 +19,9 @@
 package org.apache.myfaces.extensions.cdi.message.test;
 
 import org.apache.myfaces.extensions.cdi.message.api.MessageResolver;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
 import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
 
-import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
@@ -35,7 +35,9 @@ class TestMessageResolver implements Mes
     private static final String TEST_TECHNICAL_MESSAGES = "org.apache.myfaces.extensions.cdi.message.test.t_messages";
     private static final String TEST_LABELS = "org.apache.myfaces.extensions.cdi.message.test.labels";
 
-    public String getMessage(String key, Locale locale, Map<Class, Class<? extends
MessagePayload>> messagePayload)
+    public String getMessage(MessageContext messageContext,
+                             String key,
+                             Map<Class, Class<? extends MessagePayload>> messagePayload)
     {
         if (!isKey(key))
         {
@@ -48,13 +50,16 @@ class TestMessageResolver implements Mes
 
             if(messagePayload.containsKey(Label.class))
             {
-                return ResourceBundle.getBundle(TEST_LABELS, locale, getClassLoader()).getString(key);
+                return ResourceBundle.getBundle(
+                        TEST_LABELS, messageContext.getLocale(), getClassLoader()).getString(key);
             }
             else if(messagePayload.containsKey(TechnicalMessage.class))
             {
-                return ResourceBundle.getBundle(TEST_TECHNICAL_MESSAGES, locale, getClassLoader()).getString(key);
+                return ResourceBundle.getBundle(
+                        TEST_TECHNICAL_MESSAGES, messageContext.getLocale(), getClassLoader()).getString(key);
             }
-            return ResourceBundle.getBundle(TEST_MESSAGES, locale, getClassLoader()).getString(key);
+            return ResourceBundle.getBundle(
+                    TEST_MESSAGES, messageContext.getLocale(), getClassLoader()).getString(key);
         }
         catch (MissingResourceException e)
         {

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java?rev=956099&r1=956098&r2=956099&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java
Fri Jun 18 19:08:27 2010
@@ -19,10 +19,10 @@
 package org.apache.myfaces.extensions.cdi.message.test;
 
 import org.apache.myfaces.extensions.cdi.message.api.MessageResolver;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
 import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
 import org.apache.myfaces.extensions.cdi.message.api.payload.MessageSeverity;
 
-import java.util.Locale;
 import java.util.Map;
 
 /**
@@ -32,7 +32,9 @@ class TestPayloadAwareMessageResolver im
 {
     private boolean isPayloadAvailable = false; 
 
-    public String getMessage(String key, Locale locale, Map<Class, Class<? extends
MessagePayload>> payload)
+    public String getMessage(MessageContext messageContext,
+                             String key,
+                             Map<Class, Class<? extends MessagePayload>> payload)
     {
         if(MessageSeverity.Warn.class.equals(payload.get(MessageSeverity.class)))
         {



Mime
View raw message