[infinispan-commits] Infinispan SVN: r2081 - branches/4.1.x/core/src/main/java/org/infinispan/notifications.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Tue Jul 20 09:54:23 EDT 2010
Author: DiabloD3
Date: 2010-07-20 09:54:23 -0400 (Tue, 20 Jul 2010)
New Revision: 2081
Modified:
branches/4.1.x/core/src/main/java/org/infinispan/notifications/Listener.java
Log:
Adding Listener documentation fix to 4.1.x
Modified: branches/4.1.x/core/src/main/java/org/infinispan/notifications/Listener.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/notifications/Listener.java 2010-07-20 13:42:59 UTC (rev 2080)
+++ branches/4.1.x/core/src/main/java/org/infinispan/notifications/Listener.java 2010-07-20 13:54:23 UTC (rev 2081)
@@ -154,53 +154,39 @@
* <p/>
* <pre>
* @Listener
- * public class TxGuaranteedListener
+ * public class EventHandler
* {
- * private class TxEventQueue
+ * private ConcurrentMap<GlobalTransaction, Queue<Event>> map = new ConcurrentHashMap<GlobalTransaction, Queue<Event>>();
+ *
+ * @TransactionRegistered
+ * public void startTransaction(TransactionRegisteredEvent event)
* {
- * private ConcurrentMap<Transaction, Queue<Event>> map = new ConcurrentHashMap<Transaction,
- * Queue<Event>>();
- * <p/>
- * public void offer(Event event)
- * {
- * Queue<Event> queue = getQueue(event.getContext().getTransaction());
- * queue.offer(event);
- * }
- * <p/>
- * private Queue<Event> getQueue(Transaction transaction)
- * {
- * Queue<Event> queue = map.get(transaction);
- * if (queue == null)
- * {
- * queue = new ConcurrentLinkedQueue<Event>();
- * map.putIfAbsent(transaction, queue);
- * }
- * <p/>
- * return queue;
- * }
- * <p/>
- * public Queue<Event> takeAll(Transaction transaction)
- * {
- * return map.remove(transaction);
- * }
+ * map.put(event.getGlobalTransaction(), new ConcurrentLinkedQueue<Event>());
* }
- * <p/>
- * private TxEventQueue events = new TxEventQueue();
- * <p/>
- * @CacheEntryModified
+ *
* @CacheEntryCreated
+ * @CacheEntryModified
* @CacheEntryRemoved
- * public void handle(Event event)
+ * public void addEvent(TransactionalEvent event)
* {
- * events.offer(event);
+ * map.get(event.getGlobalTransaction()).add(event);
* }
- * <p/>
+ *
* @TransactionCompleted
- * public void handleTx(TransactionCompletedEvent event)
+ * public void endTransaction(TransactionCompletedEvent event)
* {
- * Queue<Event> completed = events.takeAll(event.getTransaction());
- * if (completed != null && event.isSuccessful())
- * System.out.println("Comitted events = " + completed);
+ * Queue<Event> events = map.get(event.getGlobalTransaction());
+ * map.remove(event.getGlobalTransaction());
+ *
+ * System.out.println("Ended transaction " + event.getGlobalTransaction().getId());
+ *
+ * if(event.isTransactionSuccessful())
+ * {
+ * for(Event e : events)
+ * {
+ * System.out.println("Event " + e);
+ * }
+ * }
* }
* }
* </pre>
More information about the infinispan-commits
mailing list