FileDocCategorySizeDatePackage
AccountsCancelInterceptor.javaAPI DocJBoss 4.2.12795Fri Jul 13 20:54:52 BST 2007org.jboss.tutorial.interceptor.bean

AccountsCancelInterceptor

public class AccountsCancelInterceptor extends AccountsInterceptor
author
Kabir Khan
version
$Revision: 60233 $

Fields Summary
javax.jms.QueueConnectionFactory
cf
javax.jms.Queue
queue
javax.jms.QueueConnection
conn
Constructors Summary
Methods Summary
javax.jms.QueueConnectiongetConnection()

      if (conn == null)
      {
         synchronized(cf)
         {
            if (conn == null)
            {
               conn = cf.createQueueConnection();
            }
         }
      }
      
      return conn;
   
public java.lang.ObjectsendCancelMessage(javax.interceptor.InvocationContext ctx)

      QueueSession session = null;
      try
      {
         System.out.println("*** AccountsCancelInterceptor intercepting " + ctx.getMethod().getName());
         System.out.println("*** AccountsConfirmInterceptor - notifying accounts dept");
         session = getConnection().createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
         Message msg = session.createTextMessage("Cancelling order " + ctx.getParameters()[0]);
         QueueSender sender = session.createSender(queue);
         sender.send(msg);
         
         return ctx.proceed();
      }
      catch(Exception e)
      {
         throw new RuntimeException(e);
      }
      finally
      {
         try{session.close();}catch(Exception e) {}
         System.out.println("*** AccountsCancelInterceptor exiting");
      }