|
|||||
|
|||||
NanoWar WebWork
OverviewThe NanoWar WebWork integration kit allows you to write WebWork/WebWork2 actions that are PicoContainer components. In other words, they can benefit from Dependency Injection. ExampleWebWork actions often integrate with business logic and/or persistence logic. In a non-Dependency Injection environment, the actions tend to be tightly coupled to the business logic and persistence layer tiers, and therefore hard to test in isolation. NanoWar WebWork lets you use Dependency Injection. public class CheeseAction extends ActionSupport { private final CheeseDao dao; public CheeseAction(CheeseDao dao) { this.dao = dao; } } The particularly nice thing about this is that it allows you to test the Action in isolation (by passing in a mock CheeseDao). And when you deploy the WebWork application, you can have NanoContainer provide the real CheeseDao (that possibly does some fancy Hibernate stuff or other). WebWork Specific ConfigurationFirst, follow the instructions for NanoWar WebWork 1.x ConfigurationUse the PicoServletDispatcher instead of the standard WebWork one. In web.xml: <servlet> <servlet-name>WebWork</servlet-name> <servlet-class>org.nanocontainer.nanowar.webwork.PicoWebWork1ServletDispatcher</servlet-class> <load-on-startup>1</load-on-startup> </servlet> WebWork 2.0 ConfigurationUse the PicoServletDispatcher instead of the standard WebWork 2 one. In web.xml: <servlet> <servlet-name>WebWork</servlet-name> <servlet-class>org.nanocontainer.nanowar.webwork.PicoWebWork2ServletDispatcher</servlet-class> <load-on-startup>1</load-on-startup> </servlet> WebWork 2.1 ConfigurationMap ServletRequestContainerFilter and PicoObjectFactoryFilter to WebWork's ServletDispatcher. In web.xml: <filter> <filter-name>NanoWar</filter-name> <filter-class>org.nanocontainer.nanowar.ServletRequestContainerFilter</filter-class> </filter> <filter> <filter-name>NanoWar-WebWork2</filter-name> <filter-class>org.nanocontainer.nanowar.webwork.PicoObjectFactoryFilter</filter-class> </filter> <filter-mapping> <filter-name>NanoWar</filter-name> <servlet-name>WebWork</servlet-name> </filter-mapping> <filter-mapping> <filter-name>NanoWar-WebWork2</filter-name> <servlet-name>WebWork</servlet-name> </filter-mapping>
|
|||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||