FileDocCategorySizeDatePackage
CurrentMessageInjectorInterceptor.javaAPI DocJBoss 4.2.13265Fri Jul 13 20:53:56 BST 2007org.jboss.ejb3.mdb

CurrentMessageInjectorInterceptor

public class CurrentMessageInjectorInterceptor extends Object implements org.jboss.aop.advice.Interceptor
Comment
author
Bill Burke
version
$Revision: 60233 $

Fields Summary
protected static final Logger
log
private Field[]
fields
private Method[]
methods
Constructors Summary
public CurrentMessageInjectorInterceptor(Field[] fields, Method[] methods)


       
   
      this.fields = fields;
      if (fields != null)
      {
         for (Field field : fields)
         {
            field.setAccessible(true);
         }
      }
      this.methods = methods;
      if (methods != null)
      {
         for (Method method : methods)
         {
            method.setAccessible(true);
         }
      }
   
Methods Summary
public java.lang.StringgetName()

      return this.getClass().getName();
   
public java.lang.Objectinvoke(org.jboss.aop.joinpoint.Invocation invocation)

      Object target = invocation.getTargetObject();
      Object message = invocation.getMetaData().getMetaData(ConsumerContainer.CONSUMER_MESSAGE, ConsumerContainer.CONSUMER_MESSAGE);
      if (fields != null)
      {
         for (Field field : fields)
         {
            field.set(target, message);
         }
      }
      if (methods != null)
      {
         for (Method method : methods)
         {
            method.invoke(target, message);
         }

      }
      try
      {
      return invocation.invokeNext();
      }
      finally
      {
         // clear so we don't leak.
         if (fields != null)
         {
            for (Field field : fields)
            {
               field.set(target, null);
            }
         }
         if (methods != null)
         {
            for (Method method : methods)
            {
               Object[] args = new Object[method.getParameterTypes().length];
               for (int i = 0 ; i < args.length; ++i)
                  args[i] = null;
               method.invoke(target, args);
            }
         }
      }