JMSAdvisor jmsAdvisor = (JMSAdvisor)mi.getAdvisor();
   public Object invoke(Invocation invocation) throws Throwable   {      if (invocation instanceof MethodInvocation)      {         MethodInvocation mi = (MethodInvocation)invocation;         Method m = mi.getMethod();         String methodName = m.getName();         JMSAdvisor jmsAdvisor = (JMSAdvisor)mi.getAdvisor();                  if ("createConsumerDelegate".equals(methodName))         {                        if (log.isTraceEnabled()) { log.trace("Checking if user has permissions to create consumer"); }                        //read permission required on the destination            Destination dest = (Destination)mi.getArguments()[0];                        check(mi, dest, CheckType.READ);                        //if creating a durable subscription then need create permission                        String subscriptionName = (String)mi.getArguments()[3];            if (subscriptionName != null)            {               //durable               check(mi, dest, CheckType.CREATE);            }                     }          else if ("createProducerDelegate".equals(methodName))         {            //write permission required on the destination                        //Null represents an anonymous producer - the destination            //for this is specified at send time                        if (log.isTraceEnabled()) { log.trace("Checking if user has permissions to create producer"); }                        Destination dest = (Destination)mi.getArguments()[0];                        if (dest != null)            {                              check(mi, dest, CheckType.WRITE);            }         }          else if ("createBrowserDelegate".equals(methodName))         {            //read permission required on the destination                        if (log.isTraceEnabled()) { log.trace("Checking if user has permissions to create browser"); }                        Destination dest = (Destination)mi.getArguments()[0];                        check(mi, dest, CheckType.READ);         }          else if ("send".equals(methodName))         {            //anonymous producer                        //if destination is not null then write permissions required                        if (log.isTraceEnabled()) { log.trace("Checking if user has permissions to send on anon. producer"); }                        Destination dest = (Destination)mi.getArguments()[0];                        if (dest != null)            {               //Anonymous producer               check(mi, dest, CheckType.WRITE);            }         }               }            return invocation.invokeNext();   }