Last active
December 28, 2015 23:59
-
-
Save jeffbicca/7582694 to your computer and use it in GitHub Desktop.
Revisions
-
jeffbicca revised this gist
Dec 2, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ @Singleton @TransactionAttribute(TransactionAttributeType.NEVER) // useful when you need to turn off the EJB transaction control. public class AsyncService implements Serializable { private Repository repository; -
jeffbicca created this gist
Nov 21, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ @ApplicationScoped public class AsyncProcessManager implements Serializable { private Map<AsyncProcess, Future<Object>> asyncProcesses = new ConcurrentHashMap<AsyncProcess, Future<Object>>(); public void addProcess(AsyncProcess process) { // put the process into the map. } public void removeProcess(AsyncProcess process) { // remove the process from the map. } public boolean existsProcessFor(User user) { // check if there is any process for the user. } public boolean isDone(AsyncProcess process) { Future<Object> theAsyncExecution = findAsyncExecutionFor(process); return theAsyncExecution != null && theAsyncExecution.isDone(); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ @Singleton public class AsyncService implements Serializable { private Repository repository; @Asynchronous @Lock(LockType.READ) @AccessTimeout(-1) public Future<Object> operation1() { // implementation return new AsyncResult<Object>(null); } @Asynchronous @Lock(LockType.READ) @AccessTimeout(-1) public Future<Object> operation2() { // implementation return new AsyncResult<Object>(null); } @Asynchronous @Lock(LockType.READ) @AccessTimeout(-1) public Future<Object> operationN() { // implementation return new AsyncResult<Object>(null); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ <a4j:poll id="poll" interval="5000" execute="@this" render="@form" enabled="#{not (asyncProcessManager.isDone(selectedProcess))}"/>