[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...

Manik Surtani manik at jboss.org
Thu Jun 28 12:53:37 EDT 2007


  User: msurtani
  Date: 07/06/28 12:53:37

  Modified:    src/org/jboss/cache/interceptors     TxInterceptor.java
                        PassivationInterceptor.java
                        OptimisticNodeInterceptor.java
                        NotificationInterceptor.java
  Log:
  Notification changes
  
  Revision  Changes    Path
  1.84      +5 -3      JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TxInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -b -r1.83 -r1.84
  --- TxInterceptor.java	29 May 2007 14:18:13 -0000	1.83
  +++ TxInterceptor.java	28 Jun 2007 16:53:37 -0000	1.84
  @@ -239,7 +239,7 @@
   
            setTransactionalContext(ltx, gtx, ctx);
            // register a sync handler for this tx.
  -         registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, cache));
  +         registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, cache), ctx);
   
            if (configuration.isNodeLockingOptimistic())
            {
  @@ -870,7 +870,7 @@
               }
               // see the comment in the LocalSyncHandler for the last isOriginLocal param.
               LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, cache, !ctx.isOriginLocal());
  -            registerHandler(tx, myHandler);
  +            registerHandler(tx, myHandler, ctx);
            }
         }
         else if ((gtx = (GlobalTransaction) rollbackTransactions.get(tx)) != null)
  @@ -892,13 +892,15 @@
       * @param handler
       * @throws Exception
       */
  -   private void registerHandler(Transaction tx, RemoteSynchronizationHandler handler) throws Exception
  +   private void registerHandler(Transaction tx, Synchronization handler, InvocationContext ctx) throws Exception
      {
         OrderedSynchronizationHandler orderedHandler = OrderedSynchronizationHandler.getInstance(tx);
   
         if (log.isTraceEnabled()) log.trace("registering for TX completion: SynchronizationHandler(" + handler + ")");
   
         orderedHandler.registerAtHead(handler);// needs to be invoked first on TX commit
  +
  +      cache.getNotifier().notifyTransactionRegistered(tx, ctx);
      }
   
      /**
  
  
  
  1.43      +3 -3      JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PassivationInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -b -r1.42 -r1.43
  --- PassivationInterceptor.java	30 May 2007 11:35:14 -0000	1.42
  +++ PassivationInterceptor.java	28 Jun 2007 16:53:37 -0000	1.43
  @@ -18,7 +18,7 @@
    * CacheLoader, either before each method call (no TXs), or at TX commit.
    *
    * @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
  - * @version $Id: PassivationInterceptor.java,v 1.42 2007/05/30 11:35:14 msurtani Exp $
  + * @version $Id: PassivationInterceptor.java,v 1.43 2007/06/28 16:53:37 msurtani Exp $
    */
   public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean
   {
  @@ -59,11 +59,11 @@
                  // to get them manually
                  Map attributes = getNodeAttributes(fqn);
                  // notify listeners that this node is about to be passivated
  -               cache.getNotifier().notifyNodePassivated(fqn, true, attributes, ctx, true);
  +               cache.getNotifier().notifyNodePassivated(fqn, true, attributes, ctx);
   
                  loader.put(fqn, attributes);
   
  -               cache.getNotifier().notifyNodePassivated(fqn, false, Collections.emptyMap(), ctx, true);
  +               cache.getNotifier().notifyNodePassivated(fqn, false, Collections.emptyMap(), ctx);
               }
   
               if (getStatisticsEnabled() && configuration.getExposeManagementStatistics())
  
  
  
  1.66      +9 -9      JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticNodeInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -b -r1.65 -r1.66
  --- OptimisticNodeInterceptor.java	8 Jun 2007 15:39:28 -0000	1.65
  +++ OptimisticNodeInterceptor.java	28 Jun 2007 16:53:37 -0000	1.66
  @@ -7,7 +7,6 @@
   package org.jboss.cache.interceptors;
   
   import org.jboss.cache.CacheException;
  -import org.jboss.cache.CacheListener;
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.InvocationContext;
  @@ -18,6 +17,7 @@
   import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodDeclarations;
   import org.jboss.cache.notifications.Notifier;
  +import static org.jboss.cache.notifications.event.NodeModifiedEvent.ModificationType.*;
   import org.jboss.cache.optimistic.DataVersion;
   import org.jboss.cache.optimistic.DefaultDataVersion;
   import org.jboss.cache.optimistic.TransactionWorkspace;
  @@ -282,12 +282,12 @@
         if (workspaceNode == null)
            throw new NodeNotExistsException("optimisticCreateIfNotExistsInterceptor should have created this node!");
         // pre-notify
  -      notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.PUT_MAP, workspaceNode.getData(), ctx);
  +      notifier.notifyNodeModified(workspaceNode.getFqn(), true, PUT_MAP, workspaceNode.getData(), ctx);
         if (eraseExisitng) workspaceNode.clearData();
         workspaceNode.putAll(data);
         workspace.addNode(workspaceNode);
         // post-notify
  -      notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.PUT_MAP, workspaceNode.getData(), ctx);
  +      notifier.notifyNodeModified(workspaceNode.getFqn(), false, PUT_MAP, workspaceNode.getData(), ctx);
      }
   
      private Object putDataKeyValueAndNotify(Object key, Object value, TransactionWorkspace workspace, WorkspaceNode workspaceNode, InvocationContext ctx)
  @@ -297,13 +297,13 @@
   
         Map addedData = Collections.singletonMap(key, value);
         // pre-notify
  -      notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.PUT_DATA, workspaceNode.getData(), ctx);
  +      notifier.notifyNodeModified(workspaceNode.getFqn(), true, PUT_DATA, workspaceNode.getData(), ctx);
   
         Object old = workspaceNode.put(key, value);
         workspace.addNode(workspaceNode);
   
         // post-notify
  -      notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.PUT_DATA, addedData, ctx);
  +      notifier.notifyNodeModified(workspaceNode.getFqn(), false, PUT_DATA, addedData, ctx);
   
         return old;
      }
  @@ -349,14 +349,14 @@
         if (workspaceNode == null) return null;
   
         // pre-notify
  -      notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.REMOVE_DATA, workspaceNode.getData(), ctx);
  +      notifier.notifyNodeModified(workspaceNode.getFqn(), true, REMOVE_DATA, workspaceNode.getData(), ctx);
   
         Object old = workspaceNode.remove(removeKey);
         workspace.addNode(workspaceNode);
   
         Map removedData = Collections.singletonMap(removeKey, old);
         // post-notify
  -      notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.REMOVE_DATA, removedData, ctx);
  +      notifier.notifyNodeModified(workspaceNode.getFqn(), false, REMOVE_DATA, removedData, ctx);
   
         return old;
      }
  @@ -368,13 +368,13 @@
         Map data = new HashMap(workspaceNode.getData());
   
         // pre-notify
  -      notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.REMOVE_DATA, data, ctx);
  +      notifier.notifyNodeModified(workspaceNode.getFqn(), true, REMOVE_DATA, data, ctx);
   
         workspaceNode.clearData();
         workspace.addNode(workspaceNode);
   
         // post-notify
  -      notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.REMOVE_DATA, data, ctx);
  +      notifier.notifyNodeModified(workspaceNode.getFqn(), false, REMOVE_DATA, data, ctx);
      }
   
      private Object getValueForKeyAndNotify(Object[] args, TransactionWorkspace workspace, InvocationContext ctx)
  
  
  
  1.8       +32 -53    JBossCache/src/org/jboss/cache/interceptors/NotificationInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NotificationInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/NotificationInterceptor.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- NotificationInterceptor.java	8 Jun 2007 15:02:40 -0000	1.7
  +++ NotificationInterceptor.java	28 Jun 2007 16:53:37 -0000	1.8
  @@ -3,10 +3,6 @@
   import org.jboss.cache.InvocationContext;
   import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodDeclarations;
  -import org.jboss.cache.notifications.Notifier;
  -import org.jboss.cache.transaction.TransactionEntry;
  -
  -import java.util.List;
   
   /**
    * The interceptor in charge of firing off notifications to cache listeners
  @@ -19,59 +15,42 @@
      public Object invoke(InvocationContext ctx) throws Throwable
      {
         MethodCall call = ctx.getMethodCall();
  +
  +      switch (call.getMethodId())
  +      {
  +         case MethodDeclarations.blockChannelMethodLocal_id:
  +            cache.getNotifier().notifyCacheBlocked(cache, true);
  +            break;
  +         case MethodDeclarations.unblockChannelMethodLocal_id:
  +            cache.getNotifier().notifyCacheUnblocked(cache, true);
  +            break;
  +         default:
  +            // do nothing
  +      }
  +
         // should only kick in as a call returns.
         Object retval = super.invoke(ctx);
   
  -      Notifier n = cache.getNotifier();
  -      // now, if we are in a transactional context, copy all local-context invocations to the transaction entry.
  -      if (ctx.getGlobalTransaction() != null)
  -      {
  -         if (MethodDeclarations.isTransactionLifecycleMethod(call.getMethodId()))
  -         {
               // only invoke on commit.
  -            if (call.getMethodId() == MethodDeclarations.commitMethod_id)
  -            {
  -               // invoke notifications
  -               List<MethodCall> events = ctx.getCacheListenerEvents();
  -               TransactionEntry entry = txTable.get(ctx.getGlobalTransaction());
  -               if (entry != null)
  -               {
  -                  entry.addCacheListenerEvents(events);
  -
  -                  if (log.isTraceEnabled())
  -                     log.trace("Invoking notifications for this transaction.  Notification set: " + entry.getCacheListenerEvents());
  -                  n.invokeQueuedNotifications(ctx, entry.getCacheListenerEvents());
  -               }
  -               else
  -               {
  -                  log.trace("Committing but cache entry is null.");
  -               }
  -            }
  -         }
  -         else
  -         {
  -            // a "normal" method in the transaction. Add notifications to transaction entry.
  -            List<MethodCall> events = ctx.getCacheListenerEvents();
  -            TransactionEntry entry = txTable.get(ctx.getGlobalTransaction());
  -            if (entry == null)
  -            {
  -               log.warn("Transaction entry for " + ctx.getGlobalTransaction() + " is null?");
  -            }
  -            else
  -            {
  -               if (log.isTraceEnabled()) log.trace("Adding " + events + " to transaction entry's notification list");
  -               entry.addCacheListenerEvents(events);
  -               ctx.clearCacheListenerEvents();
  -            }
  -         }
  -      }
  -      else
  +      switch (call.getMethodId())
         {
  -         // fire all queued up notifications now.
  -         if (log.isTraceEnabled()) log.trace("Notifications in queue size: " + ctx.getCacheListenerEvents().size());
  -         if (log.isTraceEnabled()) log.trace("Notifications in queue: " + ctx.getCacheListenerEvents());
  -         n.invokeQueuedNotifications(ctx);
  -         ctx.clearCacheListenerEvents();
  +         case MethodDeclarations.commitMethod_id:
  +            // notify commit
  +            // ctx.is
  +            cache.getNotifier().notifyTransactionCompleted(ctx.getTransaction(), true, ctx);
  +            break;
  +         case MethodDeclarations.rollbackMethod_id:
  +            // notify rollback
  +            cache.getNotifier().notifyTransactionCompleted(ctx.getTransaction(), false, ctx);
  +            break;
  +         case MethodDeclarations.blockChannelMethodLocal_id:
  +            cache.getNotifier().notifyCacheBlocked(cache, false);
  +            break;
  +         case MethodDeclarations.unblockChannelMethodLocal_id:
  +            cache.getNotifier().notifyCacheUnblocked(cache, false);
  +            break;
  +         default:
  +            // do nothing;
         }
   
         return retval;
  
  
  



More information about the jboss-cvs-commits mailing list