deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject git commit: DELTASPIKE-403 make MessageBundles PassivationCapable
Date Mon, 12 Aug 2013 13:10:54 GMT
Updated Branches:
  refs/heads/master ea413ab4a -> ede53193d


DELTASPIKE-403 make MessageBundles PassivationCapable


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

Branch: refs/heads/master
Commit: ede53193d6eba06b1f3ee657cb5777f4ca2f8e76
Parents: ea413ab
Author: Mark Struberg <struberg@apache.org>
Authored: Mon Aug 12 15:10:26 2013 +0200
Committer: Mark Struberg <struberg@apache.org>
Committed: Mon Aug 12 15:10:26 2013 +0200

----------------------------------------------------------------------
 .../impl/message/MessageBundleExtension.java    |  8 +++--
 .../test/core/api/message/MessageUser.java      | 37 ++++++++++++++++++++
 .../core/api/message/SimpleMessageTest.java     | 14 +++++++-
 3 files changed, 55 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ede53193/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 213c0f4..6835c84 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
@@ -194,14 +194,16 @@ public class MessageBundleExtension implements Extension, Deactivatable
         }
     }
 
-    private static <T> Bean<T> createMessageBundleBean(Bean<Object> delegate,
-                                                       AnnotatedType<T> annotatedType,
-                                                       BeanManager beanManager)
+    private <T> Bean<T> createMessageBundleBean(Bean<Object> delegate,
+                                                AnnotatedType<T> annotatedType,
+                                                BeanManager beanManager)
     {
         WrappingBeanBuilder<T> beanBuilder = new WrappingBeanBuilder<T>(delegate,
beanManager)
                 .readFromType(annotatedType);
         //X TODO re-visit type.getBaseType() in combination with #addQualifier
         beanBuilder.types(annotatedType.getJavaClass(), Object.class, Serializable.class);
+        beanBuilder.passivationCapable(true);
+        beanBuilder.id("MessageBundleBean#" + annotatedType.getJavaClass().getName());
 
         return beanBuilder.create();
     }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ede53193/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MessageUser.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MessageUser.java
b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MessageUser.java
new file mode 100644
index 0000000..d91d32d
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MessageUser.java
@@ -0,0 +1,37 @@
+/*
+ * 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.deltaspike.test.core.api.message;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import java.io.Serializable;
+
+/**
+ * A SessionScoped (passivating!) user which uses a DeltaSpike message
+ */
+@SessionScoped
+public class MessageUser implements Serializable
+{
+    @Inject
+    private SimpleMessage msg;
+
+    public SimpleMessage getMsg() {
+        return msg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ede53193/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java
b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java
index 5ee43d7..e5dadd8 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java
@@ -52,6 +52,10 @@ public class SimpleMessageTest
     @Inject
     private LocaleResolver localeResolver;
 
+    @Inject
+    private MessageUser messageUser;
+
+
     /**
      * X TODO creating a WebArchive is only a workaround because JavaArchive
      * cannot contain other archives.
@@ -103,10 +107,18 @@ public class SimpleMessageTest
     }
 
     @Test
-    public void testMessageSerialisation() {
+    public void testMessageSerialisation()
+    {
         Serializer<SimpleMessage> simpleMessageSerializer = new Serializer<SimpleMessage>();
 
         SimpleMessage sm2 = simpleMessageSerializer.roundTrip(simpleMessage);
         assertNotNull(sm2);
     }
+
+    @Test
+    public void testPassivationCapability()
+    {
+        assertEquals("Welcome to DeltaSpike", messageUser.getMsg().welcomeToDeltaSpike());
+        assertEquals("Welcome to DeltaSpike", messageUser.getMsg().welcomeWithStringVariable("DeltaSpike"));
+    }
 }


Mime
View raw message