You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/10/08 14:33:54 UTC

svn commit: r702844 - /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java

Author: skitching
Date: Wed Oct  8 05:33:53 2008
New Revision: 702844

URL: http://svn.apache.org/viewvc?rev=702844&view=rev
Log:
Ensure that Conversation.bind and similar methods don't create proxies of proxies.

Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java?rev=702844&r1=702843&r2=702844&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/AbstractSpringOrchestraScope.java Wed Oct  8 05:33:53 2008
@@ -679,6 +679,20 @@
      */
     Object createProxyFor(Conversation conversation, Object instance)
     {
+        if (instance instanceof SpringProxy)
+        {
+            // This is already a proxy, so don't wrap it again. Doing this check means that
+            // user code can safely write things like
+            //    return ConversationUtils.bindToCurrent(this)
+            // without worrying about whether "this" is a spring bean marked as conversation-scoped
+            // or not. Requiring beans to know about the configuration setup is bad practice.
+            //
+            // Ideally we would check here that this instance is indeed a proxy for the
+            // specified conversation and throw an exception. However that is just a
+            // nice-to-have.
+            return instance;
+        }
+        
         // The currentConversationAdvice constructor requires a beanName parameter. As the
         // instance we are wrapping here is usually not defined in the dependency-injection
         // framework configuration at all, we have to invent a dummy name here.