myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r891432 - in /myfaces/extensions/scripting/trunk: core/core/src/main/java/org/apache/myfaces/scripting/api/ examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/
Date Wed, 16 Dec 2009 21:31:54 GMT
Author: werpu
Date: Wed Dec 16 21:31:53 2009
New Revision: 891432

URL: http://svn.apache.org/viewvc?rev=891432&view=rev
Log:
added mutexes on the correct parts of the system so that the iteration over the beans does
not happen at the same time as the alteration

Modified:
    myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java
    myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean2.java
    myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean3.java

Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java?rev=891432&r1=891431&r2=891432&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java
(original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/api/BaseWeaver.java
Wed Dec 16 21:31:53 2009
@@ -254,26 +254,38 @@
 
     public void requestRefresh() {
         if (WeavingContext.getRefreshContext().isRecompileRecommended(getScriptingEngine()))
{
-            fullRecompile();
-            refreshAllManagedBeans();
-        } else {
-            //shortcut to avoid heavier operations in the beginning
-            long globalBeanRefreshTimeout = WeavingContext.getRefreshContext().getPersonalScopedBeanRefresh();
-            if (globalBeanRefreshTimeout == -1l) return;
-
-            Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
-            Long timeOut = (Long) sessionMap.get(ScriptingConst.SESS_BEAN_REFRESH_TIMER);
-            if (timeOut == null || timeOut < globalBeanRefreshTimeout) {
-                refreshPersonalScopedBeans();
+            // we set a lock over the compile and bean refresh
+            //and an inner check again to avoid unneeded compile triggers
+            synchronized (BEAN_LOCK) {
+                if (WeavingContext.getRefreshContext().isRecompileRecommended(getScriptingEngine()))
{
+                    recompileRefresh();
+                    return;
+                }
             }
         }
+        personalScopeRefresh();
+
+    }
+
+    private void personalScopeRefresh() {
+        //shortcut to avoid heavier operations in the beginning
+        long globalBeanRefreshTimeout = WeavingContext.getRefreshContext().getPersonalScopedBeanRefresh();
+        if (globalBeanRefreshTimeout == -1l) return;
+
+        Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
+        Long timeOut = (Long) sessionMap.get(ScriptingConst.SESS_BEAN_REFRESH_TIMER);
+        if (timeOut == null || timeOut < globalBeanRefreshTimeout) {
+            refreshPersonalScopedBeans();
+        }
+    }
+
+    private void recompileRefresh() {
+        fullRecompile();
+        refreshAllManagedBeans();
     }
 
 
     protected void refreshAllManagedBeans() {
-        //TODO set a mutex and a double check here to avoid
-        //double dropping the entire managed beans
-        //in case of multiuser access
 
         if (FacesContext.getCurrentInstance() == null) {
             return;//no npe allowed
@@ -315,9 +327,7 @@
                     Class managedBeanClass = entry.getValue().getManagedBeanClass();
                     if (WeavingContext.isDynamic(managedBeanClass)) {
                         //managed bean class found we drop the class from our session
-                        synchronized (BEAN_LOCK) {
-                            removeBeanReferences(entry.getValue());
-                        }
+                        removeBeanReferences(entry.getValue());
                     }
                     //one bean tainted we have to taint all dynamic beans otherwise we will
get classcast
                     //exceptions

Modified: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean2.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean2.java?rev=891432&r1=891431&r2=891432&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean2.java
(original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean2.java
Wed Dec 16 21:31:53 2009
@@ -12,17 +12,17 @@
 import java.io.InputStreamReader;
 import java.io.IOException;
 
-
+@ManagedBean(name = "javatestbean")
+@SessionScoped
 public class TestBean2 {
 
 
-
     String sayHello = "hello worldgggg";
     String hello2 = "hello from added attribute";
     String hello3 = "hello from  added attribute 2";
  
     public String getSayHello() {
-        return "aaa Java dynamic  bean - "+TestClass2.hello2 + hello3;
+        return "Testbean2 Java dynamic  bean - "+TestClass2.hello2 + hello3;
     }
 
     public String getSayHello2() {

Modified: myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean3.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean3.java?rev=891432&r1=891431&r2=891432&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean3.java
(original)
+++ myfaces/extensions/scripting/trunk/examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/test/TestBean3.java
Wed Dec 16 21:31:53 2009
@@ -15,8 +15,8 @@
 import java.io.IOException;
 import java.nio.CharBuffer;
 
-@ManagedBean(name = "javatestbean")
-@SessionScoped
+
+
 public class TestBean3 {
     String sayHello = "hello world";
     String hello2 = "hello from added attribute";



Mime
View raw message