[jboss-cvs] JBossCache/src/org/jboss/cache/pojo/notification/annotation ...
Manik Surtani
manik at jboss.org
Fri Jul 13 05:42:24 EDT 2007
User: msurtani
Date: 07/07/13 05:42:24
Modified: src/org/jboss/cache/pojo/notification/annotation
PojoCacheListener.java
Log:
Updated documentation
Revision Changes Path
1.3 +31 -30 JBossCache/src/org/jboss/cache/pojo/notification/annotation/PojoCacheListener.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoCacheListener.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/notification/annotation/PojoCacheListener.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- PojoCacheListener.java 3 Jul 2007 01:44:37 -0000 1.2
+++ PojoCacheListener.java 13 Jul 2007 09:42:24 -0000 1.3
@@ -21,11 +21,6 @@
*/
package org.jboss.cache.pojo.notification.annotation;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
import org.jboss.cache.pojo.notification.NotificationContext;
import org.jboss.cache.pojo.notification.event.AttachedEvent;
import org.jboss.cache.pojo.notification.event.DetachedEvent;
@@ -36,26 +31,31 @@
import org.jboss.cache.pojo.notification.event.TransactionCompletedEvent;
import org.jboss.cache.pojo.notification.event.TransactionRegisteredEvent;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
/**
* Indicates that a class should receive POJO notification events. The class may
* have zero or more annotated notification methods. Each method may have any
* name, but must have a method signature that contains the required event type
* (or super type).
- *
- * <p>
+ * <p/>
+ * <p/>
* There can be multiple methods that are annotated to receive the same event,
* and a method may receive multiple events by using a super type.
- *
+ * <p/>
* <h4>Delivery Semantics</h4>
- * <p>
+ * <p/>
* An event is delivered immediately after the
* respective operation, but before the underlying cache call returns. For this
* reason it is important to keep listener processing logic short-lived. If a
* long running task needs to be performed, it's recommended to use another
* thread.
- *
+ * <p/>
* <h4>Transactional Semantics</h4>
- * <p>
+ * <p/>
* Since the event is delivered during the actual cache call, the transactional
* outcome is not yet known. For this reason, <i>events are always delivered, even
* if the changes they represent are discarded by their containing transaction</i>.
@@ -64,13 +64,13 @@
* along with {@link TransactionCompletedEvent#isSuccessful()} to record events and
* later process them once the transaction has been successfully committed.
* Example 4 demonstrates this.
- *
+ * <p/>
* <h4>Threading Semantics</h4>
- * <p>
+ * <p/>
* A listener implementation must be capable of handling concurrent invocations. Local
* notifications reuse the calling thread; remote notifications reuse the network thread.
- *
- * <p>
+ * <p/>
+ * <p/>
* <b>Summary of Notification Annotations</b>
* <table border="1" cellpadding="1" cellspacing="1" summary="Summary of notification annotations">
* <tr>
@@ -119,7 +119,7 @@
* <td valign="top">A transaction was completed.</td>
* </tr>
* </table>
- *
+ * <p/>
* <h4>Example 1 - Method receiving a single event</h4>
* <pre>
* @PojoCacheListener
@@ -128,11 +128,11 @@
* @Attached
* public void handleAttached(AttachedEvent event)
* {
- * System.out.println("Attached = " event.getSource());
+ * System.out.println("Attached = " + event.getSource());
* }
* }
* </pre>
- *
+ * <p/>
* <h4>Example 2 - Method receiving multiple events</h4>
* <pre>
* @PojoCacheListener
@@ -149,7 +149,7 @@
* }
* }
* </pre>
- *
+ * <p/>
* <h4>Example 3 - Multiple methods receiving the same event</h4>
* <pre>
* @PojoCacheListener
@@ -174,24 +174,24 @@
* }
* }
* </pre>
- *
- * <p>
+ * <p/>
+ * <p/>
* <b>Example 4 - Processing only events with a committed transaction.</b>
- *
+ * <p/>
* <pre>
* @PojoCacheListener
- * public class TxGauranteedListener
+ * public class TxGuaranteedListener
* {
* private class TxEventQueue
* {
* 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);
@@ -200,18 +200,18 @@
* queue = new ConcurrentLinkedQueue<Event>();
* map.putIfAbsent(transaction, queue);
* }
- *
+ * <p/>
* return queue;
* }
- *
+ * <p/>
* public Queue<Event> takeAll(Transaction transaction)
* {
* return map.remove(transaction);
* }
* }
- *
+ * <p/>
* private TxEventQueue events = new TxEventQueue();
- *
+ * <p/>
* @Attached
* @Detached
* @FieldModified
@@ -222,7 +222,7 @@
* {
* events.offer(event);
* }
- *
+ * <p/>
* @TransactionCompleted
* public void handleTx(TransactionCompletedEvent event)
* {
@@ -234,6 +234,7 @@
* </pre>
*
* @author Jason T. Greene
+ * @see org.jboss.cache.notifications.annotation.CacheListener
* @since 2.0
*/
@Retention(RetentionPolicy.RUNTIME)
More information about the jboss-cvs-commits
mailing list