myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r939964 - in /myfaces/extensions/cdi/trunk/jse-modules/message-module: api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/ impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/ impl/src/test/java/org/apache/myfaces...
Date Sat, 01 May 2010 09:50:31 GMT
Author: gpetracek
Date: Sat May  1 09:50:30 2010
New Revision: 939964

URL: http://svn.apache.org/viewvc?rev=939964&view=rev
Log:
[EXTCDI-21] changed names, stand-alone message-builder and additional test-cases

Added:
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageBuilder.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageFactory.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageFactory.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/SimpleMessageBuilder.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageBuilder.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageFactory.java
Modified:
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/AbstractMessage.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/AbstractMessageWithSeverity.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/Message.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageContext.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/CompositeMessageInterpolator.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultInternalMessage.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessage.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/DefaultMessageContext.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/main/java/org/apache/myfaces/extensions/cdi/message/impl/UnmodifiableMessageContext.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ExtensibilityTest.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/SimpleMessageTest.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessage.java

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/AbstractMessage.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/AbstractMessage.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/AbstractMessage.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/AbstractMessage.java Sat May  1 09:50:30 2010
@@ -35,7 +35,7 @@ import java.util.Collections;
  */
 public abstract class AbstractMessage implements Message, MessageContextConfigAware<Message>
 {
-    protected String messageTemplate;
+    protected String messageDescriptor;
     protected Set<NamedArgument> namedArguments = new HashSet<NamedArgument>();
     protected List<Serializable> arguments = new ArrayList<Serializable>();
     protected Map<Class, Class<? extends MessagePayload>> messagePayload =
@@ -48,13 +48,13 @@ public abstract class AbstractMessage im
 
     public AbstractMessage(Message message)
     {
-        this(message.getTemplate(), message.getArguments());
+        this(message.getDescriptor(), message.getArguments());
         this.messagePayload = message.getPayload();
     }
 
-    public AbstractMessage(String messageTemplate, Serializable... arguments)
+    public AbstractMessage(String messageDescriptor, Serializable... arguments)
     {
-        this.messageTemplate = messageTemplate;
+        this.messageDescriptor = messageDescriptor;
 
         for (Serializable argument : arguments)
         {
@@ -72,9 +72,9 @@ public abstract class AbstractMessage im
         cleanup();
     }
 
-    public AbstractMessage(String messageTemplate, Set<NamedArgument> namedArguments)
+    public AbstractMessage(String messageDescriptor, Set<NamedArgument> namedArguments)
     {
-        this.messageTemplate = messageTemplate;
+        this.messageDescriptor = messageDescriptor;
         this.namedArguments = namedArguments;
         this.arguments = null;
     }
@@ -181,9 +181,9 @@ public abstract class AbstractMessage im
         this.arguments.add(argument);
     }
 
-    public String getTemplate()
+    public String getDescriptor()
     {
-        return this.messageTemplate;
+        return this.messageDescriptor;
     }
 
     public Serializable[] getArguments()
@@ -281,7 +281,7 @@ public abstract class AbstractMessage im
         {
             return false;
         }
-        if (!messageTemplate.equals(that.messageTemplate))
+        if (!messageDescriptor.equals(that.messageDescriptor))
         {
             return false;
         }
@@ -301,7 +301,7 @@ public abstract class AbstractMessage im
     @Override
     public int hashCode()
     {
-        int result = messageTemplate.hashCode();
+        int result = messageDescriptor.hashCode();
         result = 31 * result + (namedArguments != null ? namedArguments.hashCode() : 0);
         result = 31 * result + (arguments != null ? arguments.hashCode() : 0);
         result = 31 * result + (messagePayload != null ? messagePayload.hashCode() : 0);

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/AbstractMessageWithSeverity.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/AbstractMessageWithSeverity.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/AbstractMessageWithSeverity.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/AbstractMessageWithSeverity.java Sat May  1 09:50:30 2010
@@ -34,19 +34,19 @@ public abstract class AbstractMessageWit
         super(message);
     }
 
-    public AbstractMessageWithSeverity(String messageTemplate,
+    public AbstractMessageWithSeverity(String messageDescriptor,
                                        Class<? extends MessagePayload> severity,
                                        Serializable... arguments)
     {
-        super(messageTemplate, arguments);
+        super(messageDescriptor, arguments);
         addPayload(severity);
     }
 
-    public AbstractMessageWithSeverity(String messageTemplate,
+    public AbstractMessageWithSeverity(String messageDescriptor,
                                        Class<? extends MessagePayload> severity,
                                        Set<NamedArgument> namedArguments)
     {
-        super(messageTemplate, namedArguments);
+        super(messageDescriptor, namedArguments);
         addPayload(severity);
     }
 

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/Message.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/Message.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/Message.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/Message.java Sat May  1 09:50:30 2010
@@ -30,9 +30,9 @@ import java.util.Map;
 public interface Message extends Localizable, Serializable
 {
     /**
-     * @return the message template (or inline-text) of the current message
+     * @return the message key (or inline-text) of the current message
      */
-    String getTemplate();
+    String getDescriptor();
 
     /**
      * @return all named and numbered arguments

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageBuilder.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/MessageBuilder.java?rev=939964&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageBuilder.java (added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageBuilder.java Sat May  1 09:50:30 2010
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.extensions.cdi.message.api;
+
+import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
+
+import java.io.Serializable;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface MessageBuilder extends Serializable
+{
+    /**
+     * @param messagePayload payload for the current message
+     * @return the current instance of the message builder to allow a fluent api
+     */
+    MessageBuilder payload(Class<? extends MessagePayload>... messagePayload);
+
+    /**
+     * @param messageDescriptor message key (or inline-text) for the current message
+     * @return the current instance of the message builder to allow a fluent api
+     */
+    MessageBuilder text(String messageDescriptor);
+
+    /**
+     * @param arguments numbered and/or named argument(s) for the current message
+     * @return the current instance of the message builder to allow a fluent api
+     */
+    MessageBuilder argument(Serializable... arguments);
+
+    /**
+     * helper method to add named arguments easily
+     * @param name the name/key of the named argument
+     * @param value the value of the named argument
+     * @return the current instance of the message builder to allow a fluent api
+     */
+    MessageBuilder namedArgument(String name, Serializable value);
+
+    /**
+     * adds the message which was built via the fluent api
+     * @return the message which was built via the fluent api
+     */
+    Message add();
+
+    /**
+     * @return the message which was built via the fluent api
+     */
+    Message create();
+
+    /**
+     * @return the text of the message which was built via the fluent api
+     */
+    String toText();
+
+    /**
+     * converts a given message to the text via the current context
+     * @param message the message which should be converted
+     * @return the converted text of the given message
+     */
+    String toText(Message message);
+}

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageContext.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/MessageContext.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageContext.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageContext.java Sat May  1 09:50:30 2010
@@ -18,8 +18,6 @@
  */
 package org.apache.myfaces.extensions.cdi.message.api;
 
-import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
-
 import java.io.Serializable;
 
 /**
@@ -62,58 +60,4 @@ public interface MessageContext extends 
      * @param message a message which should be added to the current context (message handlers)
      */
     void addMessage(Message message);
-
-    interface MessageBuilder
-    {
-        /**
-         * @param messagePayload payload for the current message
-         * @return the current instance of the message builder to allow a fluent api
-         */
-        MessageBuilder payload(Class<? extends MessagePayload>... messagePayload);
-
-        /**
-         * @param messageTemplate message template (or inline-text) for the current message
-         * @return the current instance of the message builder to allow a fluent api
-         */
-        MessageBuilder text(String messageTemplate);
-
-        /**
-         * @param arguments numbered and/or named argument(s) for the current message
-         * @return the current instance of the message builder to allow a fluent api
-         */
-        MessageBuilder argument(Serializable... arguments);
-
-        /**
-         * helper method to add named arguments easily
-         * @param name the name/key of the named argument
-         * @param value the value of the named argument
-         * @return the current instance of the message builder to allow a fluent api
-         */
-        MessageBuilder namedArgument(String name, Serializable value);
-
-        //see MessageContext for add(Message)
-
-        /**
-         * adds the message which was built via the fluent api
-         * @return the message which was built via the fluent api
-         */
-        Message add();
-
-        /**
-         * @return the message which was built via the fluent api
-         */
-        Message create();
-
-        /**
-         * @return the text of the message which was built via the fluent api
-         */
-        String toText();
-
-        /**
-         * converts a given message to the text via the current context
-         * @param message the message which should be converted
-         * @return the converted text of the given message
-         */
-        String toText(Message message);
-    }
 }

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageFactory.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/MessageFactory.java?rev=939964&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageFactory.java (added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageFactory.java Sat May  1 09:50:30 2010
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.extensions.cdi.message.api;
+
+import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
+
+import java.io.Serializable;
+
+/**
+ * allows to customize the creation of a message.
+ * only use it if you would like to create a different type of message via the fluent api
+ * ({@link org.apache.myfaces.extensions.cdi.message.api.MessageBuilder})
+ * in all other cases you can also use {@link org.apache.myfaces.extensions.cdi.message.api.MessageResolver}
+ * e.g. to customize messages e.g. based on payload
+ *
+ * @author Gerhard Petracek
+ */
+public interface MessageFactory extends Serializable
+{
+    /**
+     * @param messageDescriptor the message key (or inline-message) for the message
+     * @param messagePayload the initial payload of the message
+     * @return a new message instance
+     */
+    Message create(String messageDescriptor,  Class<? extends MessagePayload> messagePayload);
+}

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=939964&r1=939963&r2=939964&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 Sat May  1 09:50:30 2010
@@ -29,9 +29,11 @@ public interface MessageInterpolator
     /**
      * replaces the arguments of the given message with the given arguments
      *
-     * @param messageTemplate the message template or text which has to be interpolated
+     * @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 message text if an interpolation was possible - the unmodified messageTemplate otherwise
+     * @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 messageTemplate, Serializable... arguments);
+    String interpolate(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=939964&r1=939963&r2=939964&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 Sat May  1 09:50:30 2010
@@ -31,10 +31,10 @@ public interface MessageResolver
     static final String MISSING_RESOURCE_MARKER = "???";
 
     /**
-     * @param key the message template (or in-lined text) of the current message
+     * @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 key, Locale locale, Map<Class, Class<? extends MessagePayload>> payload);
+    String getMessage(String messageDescriptor, Locale locale, 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/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=939964&r1=939963&r2=939964&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 Sat May  1 09:50:30 2010
@@ -38,9 +38,9 @@ public class CompositeMessageInterpolato
         this.messageInterpolators = messageInterpolators;
     }
 
-    public String interpolate(String messageTemplate, Serializable... arguments)
+    public String interpolate(String messageDescriptor, Serializable... arguments)
     {
-        String result = messageTemplate;
+        String result = messageDescriptor;
         for (MessageInterpolator messageInterpolator : this.messageInterpolators)
         {
             if (messageInterpolator instanceof MessageContextAware)

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultInternalMessage.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/DefaultInternalMessage.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultInternalMessage.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultInternalMessage.java Sat May  1 09:50:30 2010
@@ -33,31 +33,31 @@ public class DefaultInternalMessage exte
 {
     private static final long serialVersionUID = 7940762016110497679L;
 
-    public DefaultInternalMessage(String messageTemplate, Serializable... arguments)
+    public DefaultInternalMessage(String messageDescriptor, Serializable... arguments)
     {
-        super(messageTemplate, MessageSeverity.Info.class, arguments);
+        super(messageDescriptor, MessageSeverity.Info.class, arguments);
         addPayload(InternalMessage.class);
     }
 
-    public DefaultInternalMessage(String messageTemplate, Set<NamedArgument> namedArguments)
+    public DefaultInternalMessage(String messageDescriptor, Set<NamedArgument> namedArguments)
     {
-        super(messageTemplate, MessageSeverity.Info.class, namedArguments);
+        super(messageDescriptor, MessageSeverity.Info.class, namedArguments);
         addPayload(InternalMessage.class);
     }
 
-    public DefaultInternalMessage(String messageTemplate,
+    public DefaultInternalMessage(String messageDescriptor,
                                   Class<? extends MessagePayload> severity,
                                   Serializable... arguments)
     {
-        super(messageTemplate, severity, arguments);
+        super(messageDescriptor, severity, arguments);
         addPayload(InternalMessage.class);
     }
 
-    public DefaultInternalMessage(String messageTemplate,
+    public DefaultInternalMessage(String messageDescriptor,
                                   Class<? extends MessagePayload> severity,
                                   Set<NamedArgument> namedArguments)
     {
-        super(messageTemplate, severity, namedArguments);
+        super(messageDescriptor, severity, namedArguments);
         addPayload(InternalMessage.class);
     }
 }
\ 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/DefaultMessage.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/DefaultMessage.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessage.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessage.java Sat May  1 09:50:30 2010
@@ -40,28 +40,28 @@ public class DefaultMessage extends Abst
         super(message);
     }
 
-    public DefaultMessage(String messageTemplate, Serializable... arguments)
+    public DefaultMessage(String messageDescriptor, Serializable... arguments)
     {
-        super(messageTemplate, MessageSeverity.Info.class, arguments);
+        super(messageDescriptor, MessageSeverity.Info.class, arguments);
     }
 
-    public DefaultMessage(String messageTemplate, Set<NamedArgument> namedArguments)
+    public DefaultMessage(String messageDescriptor, Set<NamedArgument> namedArguments)
     {
-        super(messageTemplate, MessageSeverity.Info.class, namedArguments);
+        super(messageDescriptor, MessageSeverity.Info.class, namedArguments);
     }
 
-    public DefaultMessage(String messageTemplate,
+    public DefaultMessage(String messageDescriptor,
                           Class<? extends MessagePayload> severity,
                           Serializable... arguments)
     {
-        super(messageTemplate, severity, arguments);
+        super(messageDescriptor, severity, arguments);
     }
 
-    public DefaultMessage(String messageTemplate,
+    public DefaultMessage(String messageDescriptor,
                           Class<? extends MessagePayload> severity,
                           Set<NamedArgument> namedArguments)
     {
-        super(messageTemplate, severity, namedArguments);
+        super(messageDescriptor, severity, namedArguments);
     }
 
     @Override
@@ -77,7 +77,7 @@ public class DefaultMessage extends Abst
     public String toString(MessageContext messageContext)
     {
         return messageContext.message()
-                .text(getTemplate())
+                .text(getDescriptor())
                 .argument(getArguments())
                 .payload(getMessagePayload())
                 .toText();

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=939964&r1=939963&r2=939964&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 Sat May  1 09:50:30 2010
@@ -26,6 +26,8 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.message.api.MessageInterpolator;
 import org.apache.myfaces.extensions.cdi.message.api.NamedArgument;
 import org.apache.myfaces.extensions.cdi.message.api.Localizable;
+import org.apache.myfaces.extensions.cdi.message.api.MessageBuilder;
+import org.apache.myfaces.extensions.cdi.message.api.MessageFactory;
 import org.apache.myfaces.extensions.cdi.message.api.Formatter;
 import org.apache.myfaces.extensions.cdi.message.api.Default;
 import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
@@ -43,7 +45,7 @@ import java.util.HashMap;
 /**
  * @author Gerhard Petracek
  */
-class DefaultMessageBuilder implements MessageContext.MessageBuilder, Serializable
+class DefaultMessageBuilder implements MessageBuilder
 {
     private static final long serialVersionUID = 892218539314030675L;
 
@@ -52,15 +54,30 @@ class DefaultMessageBuilder implements M
     private Set<NamedArgument> namedArguments;
     private MessageContext messageContext;
     private Map<Class, Class<? extends MessagePayload>> messagePayload;
-    private String messageTemplate;
+    private String messageDescriptor;
 
-    public DefaultMessageBuilder(MessageContext messageContext)
+    private MessageFactory messageFactory;
+
+    protected DefaultMessageBuilder()
+    {
+    }
+
+    public DefaultMessageBuilder(MessageContext messageContext, MessageFactory messageFactory)
     {
         reset();
         this.messageContext = new UnmodifiableMessageContext(messageContext.cloneContext());
+
+        if(messageFactory != null)
+        {
+            this.messageFactory = messageFactory;
+        }
+        else
+        {
+            this.messageFactory = new DefaultMessageFactory();
+        }
     }
 
-    public MessageContext.MessageBuilder payload(Class<? extends MessagePayload>... messagePayload)
+    public MessageBuilder payload(Class<? extends MessagePayload>... messagePayload)
     {
         Class key;
 
@@ -76,13 +93,13 @@ class DefaultMessageBuilder implements M
         return this;
     }
 
-    public MessageContext.MessageBuilder text(String messageTemplate)
+    public MessageBuilder text(String messageDescriptor)
     {
-        this.messageTemplate = messageTemplate;
+        this.messageDescriptor = messageDescriptor;
         return this;
     }
 
-    public MessageContext.MessageBuilder argument(Serializable... arguments)
+    public MessageBuilder argument(Serializable... arguments)
     {
         for (Serializable argument : arguments)
         {
@@ -99,7 +116,7 @@ class DefaultMessageBuilder implements M
         return this;
     }
 
-    public MessageContext.MessageBuilder namedArgument(String name, Serializable value)
+    public MessageBuilder namedArgument(String name, Serializable value)
     {
         this.namedArguments.add(new DefaultNamedArgument(name, value));
         return this;
@@ -114,16 +131,14 @@ class DefaultMessageBuilder implements M
 
     private Message buildMessage()
     {
-        if (this.messageTemplate == null)
+        if (this.messageDescriptor == null)
         {
-            throw new IllegalStateException("messageTemplate is missing");
+            throw new IllegalStateException("messageDescriptor is missing");
         }
 
-        Class<? extends MessagePayload> severity = getMessageSeverity();
+        Message result = createNewMessage();
 
-        Message result = new DefaultMessage(this.messageTemplate, severity);
-
-        if(result instanceof MessageContextConfigAware)
+        if(result instanceof MessageContextConfigAware && this.messageContext != null)
         {
             ((MessageContextConfigAware)result).setMessageContextConfig(this.messageContext.config());
         }
@@ -134,6 +149,15 @@ class DefaultMessageBuilder implements M
         return result;
     }
 
+    private Message createNewMessage()
+    {
+        if(this.messageFactory != null)
+        {
+            return this.messageFactory.create(this.messageDescriptor, getMessageSeverity());
+        }
+        return new DefaultMessage(this.messageDescriptor, getMessageSeverity());
+    }
+
     private Class<? extends MessagePayload> getMessageSeverity()
     {
         Class<? extends MessagePayload> severity = this.messagePayload.get(MessageSeverity.class);
@@ -169,9 +193,9 @@ class DefaultMessageBuilder implements M
         }
     }
 
-    private void reset()
+    protected void reset()
     {
-        this.messageTemplate = null;
+        this.messageDescriptor = null;
         this.messagePayload = new HashMap<Class, Class<? extends MessagePayload>>();
         this.argumentList = new ArrayList<Serializable>();
         this.namedArguments = new HashSet<NamedArgument>();
@@ -200,7 +224,7 @@ class DefaultMessageBuilder implements M
 
     private String getMessageText(Message baseMessage)
     {
-        String message = baseMessage.getTemplate();
+        String message = baseMessage.getDescriptor();
 
         MessageResolver messageResolver = this.messageContext.config().getMessageResolver();
         if (messageResolver != null)
@@ -228,9 +252,9 @@ class DefaultMessageBuilder implements M
 
     private String checkedResult(String result, Message baseMessage)
     {
-        if (result == null || isKey(baseMessage.getTemplate()) || isKeyWithoutMarkers(result, baseMessage))
+        if (result == null || isKey(baseMessage.getDescriptor()) || isKeyWithoutMarkers(result, baseMessage))
         {
-            String oldTemplate = extractTemplate(baseMessage.getTemplate()); //minor performance tweak for inline-msg
+            String oldTemplate = extractTemplate(baseMessage.getDescriptor()); //minor performance tweak for inline-msg
 
             if (result == null || result.equals(oldTemplate))
             {
@@ -243,7 +267,7 @@ class DefaultMessageBuilder implements M
 
     private boolean isKeyWithoutMarkers(String result, Message baseMessage)
     {
-        return (!result.contains(" ") && result.endsWith(baseMessage.getTemplate()));
+        return (!result.contains(" ") && result.endsWith(baseMessage.getDescriptor()));
     }
 
     private String getArguments(Message message)
@@ -338,7 +362,7 @@ class DefaultMessageBuilder implements M
         try
         {
             return messageResolver
-                    .getMessage(baseMessage.getTemplate(), this.messageContext.getLocale(), baseMessage.getPayload());
+                    .getMessage(baseMessage.getDescriptor(), this.messageContext.getLocale(), baseMessage.getPayload());
         }
         finally
         {
@@ -347,7 +371,7 @@ class DefaultMessageBuilder implements M
     }
 
     private String interpolateMessage(MessageInterpolator messageInterpolator,
-                                      String messageTemplate, Serializable... arguments)
+                                      String messageDescriptor, Serializable... arguments)
     {
         if (messageInterpolator instanceof MessageContextAware)
         {
@@ -356,7 +380,7 @@ class DefaultMessageBuilder implements M
 
         try
         {
-            return messageInterpolator.interpolate(getEscapedTemplate(messageTemplate), arguments);
+            return messageInterpolator.interpolate(getEscapedTemplate(messageDescriptor), arguments);
         }
         finally
         {
@@ -364,14 +388,14 @@ class DefaultMessageBuilder implements M
         }
     }
 
-    private String getEscapedTemplate(String messageTemplate)
+    private String getEscapedTemplate(String messageDescriptor)
     {
         //TODO
-        if (messageTemplate.startsWith("\\{"))
+        if (messageDescriptor.startsWith("\\{"))
         {
-            return messageTemplate.substring(1);
+            return messageDescriptor.substring(1);
         }
-        return messageTemplate;
+        return messageDescriptor;
     }
 
     private void cleanupMessageContext(Object object)
@@ -381,4 +405,9 @@ class DefaultMessageBuilder implements M
             ((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/DefaultMessageContext.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/DefaultMessageContext.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageContext.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageContext.java Sat May  1 09:50:30 2010
@@ -22,6 +22,8 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
 import org.apache.myfaces.extensions.cdi.message.api.MessageContextConfig;
 import org.apache.myfaces.extensions.cdi.message.api.MessageFilter;
+import org.apache.myfaces.extensions.cdi.message.api.MessageBuilder;
+import org.apache.myfaces.extensions.cdi.message.api.MessageFactory;
 
 import java.util.List;
 import java.util.Locale;
@@ -38,19 +40,31 @@ public class DefaultMessageContext imple
     private static final long serialVersionUID = -110779217295211303L;
 
     private MessageContextConfig config = new DefaultMessageContextConfig();
+    private MessageFactory messageFactory;
 
     public DefaultMessageContext()
     {
     }
 
+    public DefaultMessageContext(MessageFactory messageFactory)
+    {
+        this.messageFactory = messageFactory;
+    }
+
     DefaultMessageContext(MessageContextConfig config)
     {
         this.config = config;
     }
 
+    DefaultMessageContext(MessageContextConfig config, MessageFactory messageFactory)
+    {
+        this.config = config;
+        this.messageFactory = messageFactory;
+    }
+
     public MessageBuilder message()
     {
-        return new DefaultMessageBuilder(this);
+        return new DefaultMessageBuilder(this, this.messageFactory);
     }
 
     public MessageContextConfig config()
@@ -60,6 +74,7 @@ public class DefaultMessageContext imple
 
     public <T extends MessageContext> T typed(Class<T> contextType)
     {
+        //noinspection unchecked
         return (T) this;
     }
 
@@ -131,6 +146,7 @@ public class DefaultMessageContext imple
 
         DefaultMessageContext that = (DefaultMessageContext) o;
 
+        //noinspection RedundantIfStatement
         if (!config.equals(that.config))
         {
             return false;

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageFactory.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/DefaultMessageFactory.java?rev=939964&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageFactory.java (added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageFactory.java Sat May  1 09:50:30 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.extensions.cdi.message.impl;
+
+import org.apache.myfaces.extensions.cdi.message.api.MessageFactory;
+import org.apache.myfaces.extensions.cdi.message.api.Message;
+import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
+
+/**
+ * @author Gerhard Petracek
+ */
+class DefaultMessageFactory implements MessageFactory
+{
+    private static final long serialVersionUID = 721557343207858857L;
+
+    public Message create(String messageDescriptor, Class<? extends MessagePayload> messagePayload)
+    {
+        return new DefaultMessage(messageDescriptor, messagePayload);
+    }
+}

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=939964&r1=939963&r2=939964&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 Sat May  1 09:50:30 2010
@@ -29,8 +29,8 @@ class DefaultMessageInterpolator impleme
 {
     private static final long serialVersionUID = -8854087197813424812L;
 
-    public String interpolate(String messageTemplate, Serializable... arguments)
+    public String interpolate(String messageDescriptor, Serializable... arguments)
     {
-        return messageTemplate;
+        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=939964&r1=939963&r2=939964&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 Sat May  1 09:50:30 2010
@@ -47,15 +47,15 @@ public class ELAwareMessageInterpolator 
         this.elProvider = elProvider;
     }
 
-    public String interpolate(String messageTemplate, Serializable... arguments)
+    public String interpolate(String messageDescriptor, Serializable... arguments)
     {
         List<NamedArgument> namedArguments = addNamedArguments(arguments);
 
         if (namedArguments.size() > 0)
         {
-            return interpolateNamedArguments(messageTemplate, namedArguments);
+            return interpolateNamedArguments(messageDescriptor, namedArguments);
         }
-        return messageTemplate;
+        return messageDescriptor;
     }
 
     private List<NamedArgument> addNamedArguments(Serializable[] arguments)
@@ -74,7 +74,7 @@ public class ELAwareMessageInterpolator 
     }
 
     //TODO add warning for unused arguments,...
-    private String interpolateNamedArguments(String messageTemplate, List<NamedArgument> namedArguments)
+    private String interpolateNamedArguments(String messageDescriptor, List<NamedArgument> namedArguments)
     {
         ExpressionFactory factory = this.elProvider.createExpressionFactory();
         SimpleELContext elContext = this.elProvider.createELContext(this.elProvider.createELResolver());
@@ -85,7 +85,7 @@ public class ELAwareMessageInterpolator 
             elContext.setVariable(argument.getName(), factory.createValueExpression(value, value.getClass()));
         }
 
-        Matcher matcher = MESSAGE_ARGS_PATTERN.matcher(messageTemplate);
+        Matcher matcher = MESSAGE_ARGS_PATTERN.matcher(messageDescriptor);
         StringBuffer buffer = new StringBuffer();
         while (matcher.find())
         {

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=939964&r1=939963&r2=939964&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 Sat May  1 09:50:30 2010
@@ -32,16 +32,16 @@ public class NumberedArgumentAwareMessag
 {
     private static final long serialVersionUID = 8699632465559596371L;
 
-    public String interpolate(String messageTemplate, Serializable... arguments)
+    public String interpolate(String messageDescriptor, Serializable... arguments)
     {
         Serializable[] numberedArguments = addNumberedArguments(arguments);
 
         if (numberedArguments.length > 0)
         {
-            return formatMessage(messageTemplate, numberedArguments);
+            return formatMessage(messageDescriptor, numberedArguments);
         }
 
-        return messageTemplate;
+        return messageDescriptor;
     }
 
     private Serializable[] addNumberedArguments(Serializable[] arguments)
@@ -60,7 +60,7 @@ public class NumberedArgumentAwareMessag
     }
 
     //TODO add warning for unused arguments,...
-    private String formatMessage(String messageTemplate, Serializable[] arguments)
+    private String formatMessage(String messageDescriptor, Serializable[] arguments)
     {
         Object[] localizedArguments = null;
         Object argument;
@@ -83,7 +83,7 @@ public class NumberedArgumentAwareMessag
         }
 
         MessageFormat messageFormat = new MessageFormat(
-                messageTemplate, this.messageContext.getLocale());
+                messageDescriptor, this.messageContext.getLocale());
 
         if (localizedArguments == null)
         {

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/SimpleMessageBuilder.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/SimpleMessageBuilder.java?rev=939964&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/SimpleMessageBuilder.java (added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/SimpleMessageBuilder.java Sat May  1 09:50:30 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.extensions.cdi.message.impl;
+
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
+import org.apache.myfaces.extensions.cdi.message.api.MessageBuilder;
+
+/**
+ * just for manual usages (see the test-case)
+ *
+ * @author Gerhard Petracek
+ */
+public class SimpleMessageBuilder extends DefaultMessageBuilder
+{
+    private static final long serialVersionUID = -3453104710956154815L;
+
+    protected SimpleMessageBuilder()
+    {
+        super();
+        reset();
+    }
+
+    protected SimpleMessageBuilder(MessageContext messageContext)
+    {
+        super(messageContext, null);
+    }
+
+    public static MessageBuilder message()
+    {
+        return new SimpleMessageBuilder();
+    }
+
+    public static MessageBuilder message(MessageContext messageContext)
+    {
+        return new SimpleMessageBuilder(messageContext);
+    }
+
+    @Override
+    public String toText()
+    {
+        if (getMessageContext() == null)
+        {
+            throw new IllegalStateException(getClass().getName() + ".toText called outside a message context " +
+                    "please use SimpleMessageBuilder.message(messageContext).text(...).toText()");
+        }
+        return super.toText();
+    }
+}

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/UnmodifiableMessageContext.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/UnmodifiableMessageContext.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/UnmodifiableMessageContext.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/UnmodifiableMessageContext.java Sat May  1 09:50:30 2010
@@ -22,6 +22,7 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
 import org.apache.myfaces.extensions.cdi.message.api.MessageContextConfig;
 import org.apache.myfaces.extensions.cdi.message.api.MessageFilter;
+import org.apache.myfaces.extensions.cdi.message.api.MessageBuilder;
 
 import java.util.List;
 import java.util.Locale;

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ExtensibilityTest.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/ExtensibilityTest.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ExtensibilityTest.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ExtensibilityTest.java Sat May  1 09:50:30 2010
@@ -20,6 +20,8 @@ package org.apache.myfaces.extensions.cd
 
 import org.apache.myfaces.extensions.cdi.message.api.LocaleResolver;
 import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
+import org.apache.myfaces.extensions.cdi.message.api.Message;
+import org.apache.myfaces.extensions.cdi.message.impl.DefaultMessageContext;
 import static org.junit.Assert.*;
 import org.junit.Test;
 
@@ -43,6 +45,14 @@ public class ExtensibilityTest extends A
     }
 
     @Test
+    public void newMessageFactoryTest()
+    {
+        Message message = new DefaultMessageContext(new TestMessageFactory()).message().text("{hello}").create();
+
+        assertEquals(TestMessage.class, message.getClass());
+    }
+
+    @Test
     public void newContextTest()
     {
         MessageContext newMessageContext = this.messageContext.cloneContext();

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/SimpleMessageTest.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/SimpleMessageTest.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/SimpleMessageTest.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/SimpleMessageTest.java Sat May  1 09:50:30 2010
@@ -21,7 +21,9 @@ package org.apache.myfaces.extensions.cd
 import org.apache.myfaces.extensions.cdi.message.api.LocaleResolver;
 import org.apache.myfaces.extensions.cdi.message.api.Message;
 import org.apache.myfaces.extensions.cdi.message.impl.DefaultMessage;
+import org.apache.myfaces.extensions.cdi.message.impl.SimpleMessageBuilder;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 import org.junit.Test;
 
 import java.util.Locale;
@@ -32,7 +34,7 @@ import java.util.Locale;
 public class SimpleMessageTest extends AbstractTest
 {
     @Test
-    public void resolveInlineMessageTest()
+    public void createInlineMessageTest()
     {
         Message message = this.messageContext.message().text("hello open message").create();
 
@@ -40,6 +42,22 @@ public class SimpleMessageTest extends A
     }
 
     @Test
+    public void createInlineMessageViaMessageBuilderTest()
+    {
+        Message message = SimpleMessageBuilder.message().text("hello open message").create();
+
+        assertEquals("hello open message", message.toString(this.messageContext));
+    }
+
+    @Test
+    public void createInlineMessageViaCustomMessageBuilderTest()
+    {
+        Message message = new TestMessageBuilder().text("hello open message").create();
+
+        assertEquals("hello open message", message.toString(this.messageContext));
+    }
+
+    @Test
     public void resolveMessageTest()
     {
         Message message = this.messageContext.message().text("{hello}").create();
@@ -52,6 +70,7 @@ public class SimpleMessageTest extends A
     {
         Message message = this.messageContext.message().text("{hello}").create();
 
+        @SuppressWarnings({"deprecation"})
         String messageText = this.messageContext.message().toText(message); //TODO use a different config
 
         checkDefaultHelloMessage(messageText);
@@ -136,6 +155,28 @@ public class SimpleMessageTest extends A
         checkDefaultHelloMessage(messageText);
     }
 
+    @Test
+    public void resolveInlineMessageWithMessageBuilderWithoutAContextTest()
+    {
+        try
+        {
+            SimpleMessageBuilder.message().text("hello open message").toText();
+        }
+        catch(IllegalStateException e)
+        {
+            return;
+        }
+        fail();
+    }
+
+    @Test
+    public void resolveInlineMessageWithMessageBuilderWithContextTest()
+    {
+        String message = SimpleMessageBuilder.message(this.messageContext).text("hello open message").toText();
+
+        assertEquals("hello open message", message);
+    }
+
     private LocaleResolver createGermanLocaleResolver()
     {
         return new LocaleResolver()

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessage.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/TestMessage.java?rev=939964&r1=939963&r2=939964&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessage.java (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessage.java Sat May  1 09:50:30 2010
@@ -27,28 +27,30 @@ import java.util.Set;
 
 class TestMessage extends DefaultMessage
 {
+    private static final long serialVersionUID = 4209087914276552447L;
+
     public TestMessage(Message message)
     {
         super(message);
     }
 
-    public TestMessage(String messageTemplate, Object... arguments)
+    public TestMessage(String messageDescriptor, Object... arguments)
     {
-        super(messageTemplate, arguments);
+        super(messageDescriptor, arguments);
     }
 
-    public TestMessage(String messageTemplate, Set<NamedArgument> namedArguments)
+    public TestMessage(String messageDescriptor, Set<NamedArgument> namedArguments)
     {
-        super(messageTemplate, namedArguments);
+        super(messageDescriptor, namedArguments);
     }
 
-    public TestMessage(String messageTemplate, Class<? extends MessagePayload> severity, Object... arguments)
+    public TestMessage(String messageDescriptor, Class<? extends MessagePayload> severity, Object... arguments)
     {
-        super(messageTemplate, severity, arguments);
+        super(messageDescriptor, severity, arguments);
     }
 
-    public TestMessage(String messageTemplate, Class<? extends MessagePayload> severity, Set<NamedArgument> namedArguments)
+    public TestMessage(String messageDescriptor, Class<? extends MessagePayload> severity, Set<NamedArgument> namedArguments)
     {
-        super(messageTemplate, severity, namedArguments);
+        super(messageDescriptor, severity, namedArguments);
     }
 }

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageBuilder.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/TestMessageBuilder.java?rev=939964&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageBuilder.java (added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageBuilder.java Sat May  1 09:50:30 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.extensions.cdi.message.test;
+
+import org.apache.myfaces.extensions.cdi.message.impl.SimpleMessageBuilder;
+
+/**
+ * @author Gerhard Petracek
+ */
+class TestMessageBuilder extends SimpleMessageBuilder
+{
+    private static final long serialVersionUID = -92376642213127412L;
+
+    public TestMessageBuilder()
+    {
+    }
+}

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageFactory.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/TestMessageFactory.java?rev=939964&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageFactory.java (added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageFactory.java Sat May  1 09:50:30 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.extensions.cdi.message.test;
+
+import org.apache.myfaces.extensions.cdi.message.api.MessageFactory;
+import org.apache.myfaces.extensions.cdi.message.api.Message;
+import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
+
+/**
+ * @author Gerhard Petracek
+ */
+class TestMessageFactory implements MessageFactory
+{
+    private static final long serialVersionUID = -2561554895243475186L;
+
+    public Message create(String messageDescriptor, Class<? extends MessagePayload> messagePayload)
+    {
+        return new TestMessage(messageDescriptor, messagePayload);
+    }
+}



Mime
View raw message