DWR

Plugin requires List of Classes

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 2.0.5, 2.0.6, 3.0.M1, 3.0.RC1
  • Fix Version/s: 4.0
  • Component/s: Core
  • Documentation Required:
    No
  • Description:
    Hide
    There is a quirk in the ability to plug classes into DWR. You need to keep the setting as a list, ie keep at least two classnames (having only one classname will make the setting be handled as a non-list setting which will go wrong later).

    http://directwebremoting.org/dwr/documentation/server/configuration/servlet/plugin.html

    On this page the example listed will not work as is:
    <init-param>
        <param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>
        <param-value>com.example.MyCustomServerLoadMonitor</param-value>
     </init-param>

    In order for this to work you need to repeat the class in a list format:
    <init-param>
        <param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>
        <param-value>com.example.MyCustomServerLoadMonitor, com.example.MyCustomServerLoadMonitor</param-value>
    </init-param>

    Obviously, this is incorrect.

    I have looked into this and here are some notes:
    Relevant code from DefaultContainer
    public void addParameter(String askFor, Object valueParam) throws ContainerConfigurationException
    {
             Object value = valueParam;
             // Maybe the value is a classname that needs instantiating
             if (value instanceof String)
             {
                 try
                 {
                     Class<?> impl = LocalUtil.classForName((String) value);
                     value = impl.newInstance();
                 }


    When the parameter is added if it a class is found with a matching name it is instantiated.

    Then in StartupUtil we get the parameter:

    String abstractionImplNames = container.getParameter(LocalUtil.originalDwrClassName(ContainerAbstraction.class.getName()));

      public String getParameter(String name)
         {
             Object value = beans.get(name);
             return (value == null) ? null : value.toString();
         }

    The parameter is a class and we are calling toString which gives us package.className@whatever - of course this blows up. Adding the, prevents DWR from setting the parameter value to a class which is why the list format works.

    Show
    There is a quirk in the ability to plug classes into DWR. You need to keep the setting as a list, ie keep at least two classnames (having only one classname will make the setting be handled as a non-list setting which will go wrong later). http://directwebremoting.org/dwr/documentation/server/configuration/servlet/plugin.html On this page the example listed will not work as is: <init-param>     <param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>     <param-value>com.example.MyCustomServerLoadMonitor</param-value>  </init-param> In order for this to work you need to repeat the class in a list format: <init-param>     <param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>     <param-value>com.example.MyCustomServerLoadMonitor, com.example.MyCustomServerLoadMonitor</param-value> </init-param> Obviously, this is incorrect. I have looked into this and here are some notes: Relevant code from DefaultContainer public void addParameter(String askFor, Object valueParam) throws ContainerConfigurationException {          Object value = valueParam;          // Maybe the value is a classname that needs instantiating          if (value instanceof String)          {              try              {                  Class<?> impl = LocalUtil.classForName((String) value);                  value = impl.newInstance();              } When the parameter is added if it a class is found with a matching name it is instantiated. Then in StartupUtil we get the parameter: String abstractionImplNames = container.getParameter(LocalUtil.originalDwrClassName(ContainerAbstraction.class.getName()));   public String getParameter(String name)      {          Object value = beans.get(name);          return (value == null) ? null : value.toString();      } The parameter is a class and we are calling toString which gives us package.className@whatever - of course this blows up. Adding the, prevents DWR from setting the parameter value to a class which is why the list format works.

Activity

There are no comments yet on this issue.

People

Dates

  • Created:
    01/Mar/11 5:43 AM
    Updated:
    02/Mar/11 5:50 AM