deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject git commit: DELTASPIKE-356 fix JsfMessage which I broke with the refactoring
Date Sat, 11 May 2013 13:49:40 GMT
Updated Branches:
  refs/heads/master 7aea84015 -> acc6c7368


DELTASPIKE-356 fix JsfMessage which I broke with the refactoring


Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/acc6c736
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/acc6c736
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/acc6c736

Branch: refs/heads/master
Commit: acc6c73680f4f2fb0b13c9a4b429d995035a34c7
Parents: 7aea840
Author: Mark Struberg <struberg@apache.org>
Authored: Sat May 11 15:38:40 2013 +0200
Committer: Mark Struberg <struberg@apache.org>
Committed: Sat May 11 15:38:40 2013 +0200

----------------------------------------------------------------------
 .../message/MessageBundleInvocationHandler.java    |    5 +++-
 .../jsf/impl/message/DefaultJsfMessage.java        |   13 +++++++----
 .../message/JsfMessageBundleInvocationHandler.java |   16 ++++++++++----
 .../jsf/impl/message/JsfMessageProducer.java       |   11 ++++++---
 4 files changed, 30 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/acc6c736/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java
index ae84341..3402787 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java
@@ -37,7 +37,10 @@ import org.apache.deltaspike.core.api.message.MessageTemplate;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.core.util.ClassUtils;
 
-
+/**
+ * This Proxy InvocationHandler implements the handling for all our
+ * {@link org.apache.deltaspike.core.api.message.MessageBundle}s.
+ */
 @Dependent
 public class MessageBundleInvocationHandler implements InvocationHandler, Serializable
 {

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/acc6c736/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/DefaultJsfMessage.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/DefaultJsfMessage.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/DefaultJsfMessage.java
index 0be7212..c45a739 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/DefaultJsfMessage.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/DefaultJsfMessage.java
@@ -25,6 +25,7 @@ import javax.faces.component.UIComponent;
 import java.lang.reflect.Proxy;
 
 import org.apache.deltaspike.core.api.message.MessageBundle;
+import org.apache.deltaspike.core.impl.message.MessageBundleInvocationHandler;
 import org.apache.deltaspike.core.util.ClassUtils;
 import org.apache.deltaspike.jsf.api.message.JsfMessage;
 
@@ -35,18 +36,20 @@ import org.apache.deltaspike.jsf.api.message.JsfMessage;
  */
 public class DefaultJsfMessage<T> implements JsfMessage<T>
 {
-    private String clientId = null;
-    private Class<T> type;
+    private final String clientId;
+    private final Class<T> type;
+    private final MessageBundleInvocationHandler invocationHandler;
 
     /**
      * The Message type
      * @param type
      * @param clientId
      */
-    public DefaultJsfMessage(Class<T> type, String clientId)
+    public DefaultJsfMessage(Class<T> type, String clientId, MessageBundleInvocationHandler
invocationHandler)
     {
         this.type = type;
         this.clientId = clientId;
+        this.invocationHandler = invocationHandler;
 
         if (! type.isInterface() || type.getAnnotation(MessageBundle.class) == null)
         {
@@ -58,7 +61,7 @@ public class DefaultJsfMessage<T> implements JsfMessage<T>
     @Override
     public JsfMessage<T> forClientId(String clientId)
     {
-        return new DefaultJsfMessage<T>(type, clientId);
+        return new DefaultJsfMessage<T>(type, clientId, invocationHandler);
     }
 
     @Override
@@ -100,7 +103,7 @@ public class DefaultJsfMessage<T> implements JsfMessage<T>
     private T getMessage(FacesMessage.Severity severity)
     {
         return type.cast(Proxy.newProxyInstance(ClassUtils.getClassLoader(null),
-                new Class<?>[]{type}, new JsfMessageBundleInvocationHandler(severity,
clientId)));
+                new Class<?>[]{type}, new JsfMessageBundleInvocationHandler(severity,
clientId, invocationHandler)));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/acc6c736/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageBundleInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageBundleInvocationHandler.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageBundleInvocationHandler.java
index a75bf8e..e8915ab 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageBundleInvocationHandler.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageBundleInvocationHandler.java
@@ -18,8 +18,10 @@
  */
 package org.apache.deltaspike.jsf.impl.message;
 
+import javax.enterprise.inject.Typed;
 import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
+import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 
 import org.apache.deltaspike.core.api.message.Message;
@@ -30,20 +32,24 @@ import org.apache.deltaspike.jsf.api.message.JsfMessage;
  * This Proxy InvocationHandler automatically registers the
  * returned messages in the FacesContext if a severity is set.
  */
-public class JsfMessageBundleInvocationHandler extends MessageBundleInvocationHandler
+@Typed()
+public class JsfMessageBundleInvocationHandler implements InvocationHandler
 {
-    private FacesMessage.Severity severity;
-    private String clientId;
+    private final FacesMessage.Severity severity;
+    private final String clientId;
+    private final MessageBundleInvocationHandler invocationHandler;
 
-    public JsfMessageBundleInvocationHandler(FacesMessage.Severity severity, String clientId)
+    public JsfMessageBundleInvocationHandler(FacesMessage.Severity severity, String clientId,
+                                             MessageBundleInvocationHandler invocationHandler)
     {
         this.severity = severity;
         this.clientId = clientId;
+        this.invocationHandler = invocationHandler;
     }
 
     public Object invoke(final Object proxy, final Method method, final Object[] args) throws
Throwable
     {
-        Object message = super.invoke(proxy, method, args);
+        Object message = invocationHandler.invoke(proxy, method, args);
 
         if (severity == null)
         {

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/acc6c736/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java
index c035b23..8751468 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java
@@ -26,6 +26,7 @@ import javax.enterprise.inject.spi.InjectionPoint;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 
+import org.apache.deltaspike.core.impl.message.MessageBundleInvocationHandler;
 import org.apache.deltaspike.jsf.api.message.JsfMessage;
 
 /**
@@ -36,7 +37,8 @@ public class JsfMessageProducer
 {
     @Produces
     @Dependent
-    public <M> JsfMessage<M> createJsfMessage(InjectionPoint injectionPoint)
+    public <M> JsfMessage<M> createJsfMessage(InjectionPoint injectionPoint,
+                                              MessageBundleInvocationHandler invocationHandler)
     {
         if (!(injectionPoint.getType() instanceof ParameterizedType))
         {
@@ -52,7 +54,7 @@ public class JsfMessageProducer
         {
             @SuppressWarnings("unchecked")
             Class<M> type = (Class<M>) actualTypes[0];
-            return createJsfMessageFor(injectionPoint, type);
+            return createJsfMessageFor(injectionPoint, type, invocationHandler);
         }
         catch (ClassCastException e)
         {
@@ -60,9 +62,10 @@ public class JsfMessageProducer
         }
     }
 
-    private <M> JsfMessage<M> createJsfMessageFor(InjectionPoint injectionPoint,
Class<M> rawType)
+    private <M> JsfMessage<M> createJsfMessageFor(InjectionPoint injectionPoint,
Class<M> rawType,
+                                                  MessageBundleInvocationHandler invocationHandler)
     {
         // X TODO check if the JsfMessage should get injected into a UIComponent and use
#getClientId()
-        return new DefaultJsfMessage<M>(rawType, null);
+        return new DefaultJsfMessage<M>(rawType, null, invocationHandler);
     }
 }


Mime
View raw message