没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > spring-composition |
spring-composition
|
0 | 0 | 41 |
贡献者 | 讨论 | 代码提交 |
My name is Sam Alston and my colleague is Hector Rovira. We are Java Web Developers and heavy users of the Spring Framework. In fact, many of the web applications we've been a part of rely upon the Spring MVC framework.
As our applications have grown, Hector identified some areas were we could reuse code, but only if we had Controllers that relied more on Composition rather than Inheritance (which is the current pattern to follow when using AbstractController, SimpleFormController, MultiActionController, etc...) He noticed that the Validators are injected into the Form Controllers, and proposed that we carried the same pattern into other areas of the controller lifecycle. So the new design offers several interfaces that hook into the lifecycles of the Action and Form Controllers.
We have developed Composition-based Controllers that are easily configured through Spring application context files and injected with reusable ReferenceDataProviders, RequestObjectProviders, ModelProviders, FormBinders, etc... As a result of this, we have achieved our goal of making our code more reusable, our unit tests more concise and practical. We have also noticed that less code is being written to facilitate integration.
Here is a short outline of the new Classes and Interfaces:
CompositionActionController o Extends from AbstractController
o Injected with the following objects:
+ View name - The view to be used with the Action
+ RequestAction(s) - The functionality (business logic) to be executed when receiving the request
+ ModelProvider(s) - provides one or more objects to be injected into the given ModelAndView
CancellableCompositionFormController o Extends from CancellableFormController
o Injected with the following objects:
+ Form View name - The view presented to the user on the first request
+ Success View name - The view to be used in the success scenario
+ Cancel View name - The view to be used in the cancel scenario
+ InitBinder(s) - Binds editors into the ServletRequestDataBinder
+ FormBackerProvider(s) - Provides (or modifies) a command object
+ ReferenceDataProvider(s) - Provides one or more objects to be used in the form's ModelAndView (Similar to ModelProvider)
+ FormBinder(s) - Performs complex form binding on the command object
+ Validator(s) - Assures the content matches the command object's requirements
+ SubmitAction(s) - The functionality (business logic) to be executed when receiving a Submit request
+ CancelAction(s) - The functionality (business logic) to be executed when receiving a Cancel request
CompositionWizardFormController o Extends from AbstractWizardFormController
o Injected with all the same objects as the the CancellableCompositionFormController, except that the FormBinders, Validators and ReferenceDataProviders are registered on a per-page basis.
The entire code base can be found at http://code.google.com/p/spring-composition , along with a simple demo application.
Alternatively, you can download the code directly from here:
Binary - http://spring-composition.googlecode.com/files/spring-composition-1.0-SNAPSHOT.jar Source - http://spring-composition.googlecode.com/files/spring-composition-1.0-SNAPSHOT-sources.jar Javadocs - http://spring-composition.googlecode.com/files/spring-composition-1.0-SNAPSHOT-javadoc.jar Demo Binary - http://spring-composition.googlecode.com/files/demo.war Demo Source - http://spring-composition.googlecode.com/files/demo-sources.jar Feel free to contact us if you have any questions or comments. We sincerely hope that you find this work to be a useful contribution to your framework!
Sam Alston Hector Rovira