|
|||||
|
|||||
NanoWar Struts
OverviewThe NanoWar Struts integration kit allows you to write Struts actions that are PicoContainer components. In other words, they can benefit from Dependency Injection. ExampleStruts 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 Struts lets you use DependencyInjection. public class CheeseAction extends Action { 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 Struts application, you can have NanoContainer provide the real CheeseDao (that possibly does some fancy Hibernate stuff or other). Struts Specific ConfigurationUse the PicoRequestProcessor instead of the standard Struts one. In struts-config:xml: <controller processorClass="org.nanocontainer.nanowar.struts.PicoRequestProcessor"/>
If you use the Tiles library, use PicoTilesRequestProcessor instead. In addition to this, you must also follow the instuctions for NanoWar. Example WebApp (includes examples for Struts, WebWork, etc.) |
|||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||