deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-488 improved compatibility
Date Mon, 06 Jan 2014 11:26:37 GMT
Updated Branches:
  refs/heads/master fb8ef1c51 -> 30e9e1023


DELTASPIKE-488 improved compatibility


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

Branch: refs/heads/master
Commit: 30e9e10235dd54205d362ff2e609be3b7987645f
Parents: fb8ef1c
Author: gpetracek <gpetracek@apache.org>
Authored: Mon Jan 6 12:22:51 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Mon Jan 6 12:24:35 2014 +0100

----------------------------------------------------------------------
 .../GroupedConversationArtifactProducer.java    |  6 ++++--
 .../GroupedConversationContext.java             |  2 +-
 .../core/impl/util/ConversationUtils.java       | 20 ++++++++++++++++++--
 3 files changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/30e9e102/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationArtifactProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationArtifactProducer.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationArtifactProducer.java
index fe387c7..5ecaf36 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationArtifactProducer.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationArtifactProducer.java
@@ -26,6 +26,7 @@ import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationMana
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
 
@@ -44,9 +45,10 @@ public class GroupedConversationArtifactProducer
 
     @Produces
     @Dependent
-    public GroupedConversation getGroupedConversation(InjectionPoint injectionPoint)
+    public GroupedConversation getGroupedConversation(InjectionPoint injectionPoint, BeanManager
beanManager)
     {
-        ConversationKey conversationKey = ConversationUtils.convertToConversationKey(injectionPoint.getBean());
+        ConversationKey conversationKey =
+            ConversationUtils.convertToConversationKey(injectionPoint.getBean(), beanManager);
         return new InjectableGroupedConversation(conversationKey, getGroupedConversationManager());
     }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/30e9e102/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java
index 55bc043..ea9b612 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java
@@ -64,7 +64,7 @@ public class GroupedConversationContext extends AbstractContext implements
Group
     @Override
     protected ContextualStorage getContextualStorage(Contextual<?> contextual, boolean
createIfNotExist)
     {
-        ConversationKey conversationKey = ConversationUtils.convertToConversationKey(contextual);
+        ConversationKey conversationKey = ConversationUtils.convertToConversationKey(contextual,
this.beanManager);
         return this.conversationBeanHolder.getContextualStorage(this.beanManager, conversationKey,
createIfNotExist);
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/30e9e102/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java
index 08e4028..c24d538 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java
@@ -18,12 +18,15 @@
  */
 package org.apache.deltaspike.core.impl.util;
 
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
 import org.apache.deltaspike.core.api.scope.ConversationGroup;
 import org.apache.deltaspike.core.impl.scope.conversation.ConversationKey;
 
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.inject.Typed;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.PassivationCapable;
 import java.lang.annotation.Annotation;
 import java.util.Set;
 
@@ -36,10 +39,23 @@ public abstract class ConversationUtils
 
     public static ConversationKey convertToConversationKey(Contextual<?> contextual)
     {
+        return convertToConversationKey(contextual, BeanManagerProvider.getInstance().getBeanManager());
+    }
+
+    public static ConversationKey convertToConversationKey(Contextual<?> contextual,
BeanManager beanManager)
+    {
         if (!(contextual instanceof Bean))
         {
-            throw new IllegalArgumentException(
-                contextual.getClass().getName() + " is not of type " + Bean.class.getName());
+            if (contextual instanceof PassivationCapable)
+            {
+                contextual = BeanManagerProvider.getInstance().getBeanManager()
+                    .getPassivationCapableBean(((PassivationCapable) contextual).getId());
+            }
+            else
+            {
+                throw new IllegalArgumentException(
+                        contextual.getClass().getName() + " is not of type " + Bean.class.getName());
+            }
         }
 
         Bean<?> bean = (Bean<?>) contextual;


Mime
View raw message