With DWR 3 around the corner (the first milestone is available right now) is time to have a look at the new features it brings to the table. In fact, it packs so many, that I'm going to talk just about those related to Spring.
As you know (or should :-), by now DWR has a nice integration with Spring and specially Spring MVC, thanks to the custom namespace it provides. Nonetheless the team has make an effort to improve it. And the results are astounding! Let's review the new features:
- Remoting beans from a parent (root) context
Until now, when using <dwr:controller> just the beans in the same context where proxied. From now on, the root context can define candidate beans as well.
- New defaults
DWR will offer default names for your controller and remoted beans. In the former case the bean will be called dwrController. In the later, the bean will be available in your client code with the same name as the bean, capitalized. So <bean id="sample" class="..."> will be remoted as Sample.js
- Explicitly setting an application context
As of now, the default web application context was always used. The new version allows a developer to set a specific application context in the DWR Spring servlet. DWR will scan this context looking for candidate beans.
- Namespace support improved
Release 3 will add the <dwr:url-mapping /> tag. If declared in your XML (along with a <dwr:controller />) all the needed mappings will be automatically created and handled.
- Configure everything using annotations
Spring beans annotated with @RemoteProxy and @RemoteMethod will be automatically proxied and available in the browser. To activate this feature a new <dwr:annotation-config /> tag has been developed. Just one caveat, this kind of configuration does not work for advised / scoped proxies for the time being. You have to revert to the common <dwr:remote /> and <aop:scoped-proxy /> in that case.
- Classpath scanning
DWR will scan the classpath looking for classes annotated with @RemoteProxy and create the bean definitions directly (so you can ommit the @Component annotation). A new <dwr:component-scan/> tag has been created for it. A side note here, the code is not yet available (it's not in the milestone) because it requires Spring 2.5.2+ which has not been publicly released yet.
- Several other minor changes and bug fixes
A lot of work behind the scenes. For example, a bean name can now be preceded by a slash so it's automatically mapped.