1. Minimum configuration
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
2, when we want to see the DWR automatically generated test page (Using debug/test mode), you can add in the servlet
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
This parameter dwr is false by default. If you choose True. We can http://localhost:port/app/dwr through the URL and you can see each DWR class you deploy. And you can test whether every method of Java code is working correctly. For security reasons, you must set this parameter to false in the formal environment.
3, logging information configuration.
Running DWR under jdk1.3 without java.util.logging, we do not want to force the user to add a logging package, but instead use the HttpServlet.log () method to output the log. If the logging jar package is included in the Classpath, DWR automatically switches the output log with logging.
If you use the HttpServlet.log () method, the following configuration is valid.
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
Valid values are FATAL, ERROR, WARN (the default), INFO and DEBUG
Add under Log4j.properties, Log4j.logger.uk.ltd.getahead.dwr = Debug. This allows you to see the debug log for Dwr.
4, multiple Dwr.xml file configuration
There may be several cases that we enumerate. A servlet, multiple dwr.xml configuration files, multiple servlet, one or more dwr.xml per servlet.
A servlet, multiple dwr.xml configuration files;
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>config-1</param-name>
<param-value>WEB-INF/dwr1.xml</param-value>
</init-param>
<init-param>
<param-name>config-2</param-name>
<param-value>WEB-INF/dwr2.xml</param-value>
</init-param>
</servlet>
In this configuration, the value of the param-name must begin with CONFIG. Param-name can have >=0. If there is no param-name, then the web-inf/dwr.xml will be read. If there are more than 0 param-name, the Web-inf/dwr.xml file will not be read.
Multiple servlet, each servlet corresponds to one or more dwr.xml
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<!--with classes/dwr.xml-->
</servlet>
<servlet>
<servlet-name>dwr-invoker1</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>config-admin</param-name>
<param-value>WEB-INF/dwr1.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>dwr-invoker1</servlet-name>
<url-pattern>/dwr1/*</url-pattern>
</servlet-mapping>
In this case, we can control the permissions according to the Java security, for different URLs, add different roles.
5, several extension points of the DWR (Plug-ins)
DWR the default implementation provided by the following interfaces, the user can inherit the DWR default implementation class to achieve the desired effect. But this at least requires us to read the DWR source code to do the work (Dwr source is very clear, interested to learn), may be in the future to save this part.
Uk.ltd.getahead.dwr.AccessControl
Uk.ltd.getahead.dwr.Configuration
Uk.ltd.getahead.dwr.ConverterManager
Uk.ltd.getahead.dwr.CreatorManager
Uk.ltd.getahead.dwr.Processor
Uk.ltd.getahead.dwr.ExecutionContext