[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Thu Oct 12 21:12:45 EDT 2006
User: gavin
Date: 06/10/12 21:12:45
Modified: src/main/org/jboss/seam/core ConversationEntry.java
Manager.java
Log:
JBSEAM-407 blocking threads needed for ajax
Revision Changes Path
1.21 +12 -11 jboss-seam/src/main/org/jboss/seam/core/ConversationEntry.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ConversationEntry.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ConversationEntry.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- ConversationEntry.java 11 Oct 2006 21:27:30 -0000 1.20
+++ ConversationEntry.java 13 Oct 2006 01:12:45 -0000 1.21
@@ -7,6 +7,8 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
/**
* Metadata about an active conversation. Also used
@@ -30,7 +32,7 @@
private ConversationEntries parent;
- private transient Thread lock;
+ private Semaphore semaphore = new Semaphore(1,true);
public ConversationEntry(String id, List<String> stack, ConversationEntries parent)
{
@@ -174,22 +176,21 @@
this.id = id;
}
- public synchronized boolean lock()
+ public boolean lock()
{
- if ( lock!=null && !lock.equals( Thread.currentThread() ) )
+ try
{
- return false;
+ return semaphore.tryAcquire( Manager.instance().getRequestWait(), TimeUnit.MILLISECONDS );
+ }
+ catch (InterruptedException ie)
+ {
+ throw new RuntimeException(ie);
}
- this.lock = Thread.currentThread();
- return true;
}
- public synchronized void unlock()
+ public void unlock()
{
- if ( lock!=null && lock.equals( Thread.currentThread() ) )
- {
- this.lock = null;
- }
+ semaphore.release();
}
}
\ No newline at end of file
1.94 +12 -1 jboss-seam/src/main/org/jboss/seam/core/Manager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Manager.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Manager.java,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -b -r1.93 -r1.94
--- Manager.java 13 Oct 2006 00:39:42 -0000 1.93
+++ Manager.java 13 Oct 2006 01:12:45 -0000 1.94
@@ -41,7 +41,7 @@
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.93 $
+ * @version $Revision: 1.94 $
*/
@Scope(ScopeType.EVENT)
@Name("org.jboss.seam.core.manager")
@@ -71,6 +71,7 @@
private boolean destroyBeforeRedirect;
private int conversationTimeout = 600000; //10 mins
+ private int requestWait = 1000; //one second
private String conversationIdParameter = "conversationId";
private String conversationIsLongRunningParameter = "conversationIsLongRunning";
@@ -991,4 +992,14 @@
this.updateModelValuesCalled = updateModelValuesCalled;
}
+ public int getRequestWait()
+ {
+ return requestWait;
+ }
+
+ public void setRequestWait(int requestWait)
+ {
+ this.requestWait = requestWait;
+ }
+
}
More information about the jboss-cvs-commits
mailing list