DWR

Remoted class implements generic method with concrete type. Annotations are null in Ajax Filter

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 2.0.1
  • Fix Version/s: 4.0
  • Component/s: Core
  • Description:
    Hide
    I have a remoted class (TextBlockAjaxActions) that implements a generic abstract
    method with a concrete type.

    When the webapp starts, dwr reports:
        BaseCallMarshaller - Warning multiple matching methods. Using first match.

    When I look at the class' getMethods(), I can find two edit() methods:
        public volatile Block TextBlockAjaxActions.edit(Integer)
        public TextBlock TextBlockAjaxActions.edit(Integer)

    I suspect that DWR is passing the abstract Method object to the
    AjaxFilter chain instead of the concrete implementation. I have an
    AjaxFilter (TemplateFilter) that looks at the Method object for the
    @Template annotation but can not find it because it has not been passed
    the concrete Method object.


    Code
    ------------------
    public abstract class AbstractBlockAjaxActions<T extends Block> {
        public abstract T view(Integer itemId);
    }

    @RemoteProxy(
        creatorParams=@Param(name="javascript",value="TextBlockAjaxActions"),
        scope=ScriptScope.APPLICATION
    )
    @Filter(type=TemplateFilter.class)
    public class TextBlockAjaxActions extends
    AbstractBlockAjaxActions<TextBlock> {
        @Override
        @RemoteMethod

    @Template(path="/WEB-INF/jsp/issues/iur/textBlockAjaxActions.view.jsp",var="text")
        public TextBlock view(Integer itemId) {
             // implementation
        }
    }
    ------------------

    As a workaround for this I use the following method in my AjaxFilter

    ------------------

        private Method findConcreteImplementation(Object obj, Method method) {
          if (Modifier.isVolatile(method.getModifiers())) {
             Class clazz = obj == null ? method.getDeclaringClass() : obj.getClass();
              Method[] methods = clazz.getMethods();
              List<Method> options = new ArrayList<Method>();
              for (Method current : methods) {
                if (current.getName().equals(method.getName())) {
                   if (Modifier.isVolatile(current.getModifiers()) == false) {
                      options.add(current);
                   }
                }
             }
              if (options.size() == 1) {
                 method = options.get(0);
              } else {
                 throw new IllegalStateException("Could not find non-volatile implmentation of " + method.getName() + " in " + clazz.getName());
              }
           }
          return method;
       }

    Show
    I have a remoted class (TextBlockAjaxActions) that implements a generic abstract method with a concrete type. When the webapp starts, dwr reports:     BaseCallMarshaller - Warning multiple matching methods. Using first match. When I look at the class' getMethods(), I can find two edit() methods:     public volatile Block TextBlockAjaxActions.edit(Integer)     public TextBlock TextBlockAjaxActions.edit(Integer) I suspect that DWR is passing the abstract Method object to the AjaxFilter chain instead of the concrete implementation. I have an AjaxFilter (TemplateFilter) that looks at the Method object for the @Template annotation but can not find it because it has not been passed the concrete Method object. Code ------------------ public abstract class AbstractBlockAjaxActions<T extends Block> {     public abstract T view(Integer itemId); } @RemoteProxy(     creatorParams=@Param(name="javascript",value="TextBlockAjaxActions"),     scope=ScriptScope.APPLICATION ) @Filter(type=TemplateFilter.class) public class TextBlockAjaxActions extends AbstractBlockAjaxActions<TextBlock> {     @Override     @RemoteMethod @Template(path="/WEB-INF/jsp/issues/iur/textBlockAjaxActions.view.jsp",var="text")     public TextBlock view(Integer itemId) {          // implementation     } } ------------------ As a workaround for this I use the following method in my AjaxFilter ------------------     private Method findConcreteImplementation(Object obj, Method method) {       if (Modifier.isVolatile(method.getModifiers())) {          Class clazz = obj == null ? method.getDeclaringClass() : obj.getClass();           Method[] methods = clazz.getMethods();           List<Method> options = new ArrayList<Method>();           for (Method current : methods) {             if (current.getName().equals(method.getName())) {                if (Modifier.isVolatile(current.getModifiers()) == false) {                   options.add(current);                }             }          }           if (options.size() == 1) {              method = options.get(0);           } else {              throw new IllegalStateException("Could not find non-volatile implmentation of " + method.getName() + " in " + clazz.getName());           }        }       return method;    }

Activity

There are no comments yet on this issue.

People

Dates

  • Created:
    21/Jun/07 8:56 AM
    Updated:
    01/Dec/09 7:00 PM