deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject deltaspike git commit: DELTASPIKE-859 injection of named message-bundles
Date Sat, 21 Mar 2015 16:25:20 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 920f68c80 -> abacdec10


DELTASPIKE-859 injection of named message-bundles


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

Branch: refs/heads/master
Commit: abacdec106575e6f5c9d442c9447f693c53fb714
Parents: 920f68c
Author: gpetracek <gpetracek@apache.org>
Authored: Sat Mar 21 17:23:00 2015 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Sat Mar 21 17:24:43 2015 +0100

----------------------------------------------------------------------
 .../core/impl/message/MessageBundleExtension.java     |  3 +++
 .../test/core/api/message/MinimalMessagesTest.java    | 14 ++++++++++++++
 2 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/abacdec1/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java
index 649c75c..e538ddd 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java
@@ -32,6 +32,7 @@ import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.*;
 
+import org.apache.deltaspike.core.api.literal.DefaultLiteral;
 import org.apache.deltaspike.core.api.message.Message;
 import org.apache.deltaspike.core.api.message.MessageBundle;
 import org.apache.deltaspike.core.api.message.MessageTemplate;
@@ -147,6 +148,8 @@ public class MessageBundleExtension implements Extension, Deactivatable
         beanBuilder.beanLifecycle(new MessageBundleLifecycle<T>(beanManager));
 
         beanBuilder.types(annotatedType.getJavaClass(), Object.class, Serializable.class);
+        beanBuilder.addQualifier(new DefaultLiteral());
+
         beanBuilder.passivationCapable(true);
         beanBuilder.scope(ApplicationScoped.class); // needs to be a normalscope due to a
bug in older Weld versions
         beanBuilder.id("MessageBundleBean#" + annotatedType.getJavaClass().getName());

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/abacdec1/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MinimalMessagesTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MinimalMessagesTest.java
b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MinimalMessagesTest.java
index 4338654..c108133 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MinimalMessagesTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MinimalMessagesTest.java
@@ -47,6 +47,9 @@ public class MinimalMessagesTest
     @Inject
     private CustomMinimalMessages customMinimalMessages;
 
+    @Inject
+    private ElPickedUpMessages injectedElPickedUpMessages;
+
     /**
      * X TODO creating a WebArchive is only a workaround because JavaArchive
      * cannot contain other archives.
@@ -104,4 +107,15 @@ public class MinimalMessagesTest
         Assert.assertEquals("Hello 'null'", elMessage.sayHello(null));
         Assert.assertEquals("Text", elMessage.text());
     }
+
+    @Test
+    public void testInjectionOfNamedMessageBundle()
+    {
+
+        ElPickedUpMessages injectedElMessage = this.injectedElPickedUpMessages;
+        Assert.assertNotNull(injectedElMessage);
+        Assert.assertEquals("Hello DeltaSpike", injectedElMessage.sayHello("DeltaSpike"));
+        Assert.assertEquals("Hello 'null'", injectedElMessage.sayHello(null));
+        Assert.assertEquals("Text", injectedElMessage.text());
+    }
 }


Mime
View raw message