1、 毕 业 设 计(论 文) 外文文献翻译 系 别: XXXXXXXXXXXX 专 业: XXXXXXXXXXXX 班 级: XXXXXXXXXXXX 学生姓名: XXX 导师姓名: XXXX 职称: XXXX 起止时间: 2009 年 3 月 2 日 至 2009 年 6 月 12 日 英文原文 Spring contains a lot of functionality and features, which are well-organized in seven modules shown in the diagram below. This section discusses each
2、the of modules in turn. The Core package is the most fundamental part of the framework and provides the Dependency Injection features allowing you to manage bean container functionality. The basic concept here is the BeanFactory, which provides a factory pattern removing the need for programmatic si
3、ngletons and allowing you to decouple the configuration and specification of dependencies from your actual program logic. On top of the Core package sits the Context package, providing a way to access beans in a framework-style manner, somewhat resembling a JNDI-registry. The context package inherit
4、s its features from the beans package and adds support for text messaging using e.g. resource bundles, event-propagation, resource-loading and transparent creation of contexts by, for example, a servlet container. The DAO package provides a JDBC-abstraction layer that removes the need to do tedious
5、JDBC coding and parsing of database-vendor specific error codes. Also, the JDBC package provides a way to do programmatic as well as declarative transaction management, not only for classes implementing special interfaces, but for all your POJOs (plain old java objects). The ORM package provides int
6、egration layers for popular object-relational mapping APIs, including JDO, Hibernate and iBatis. Using the ORM package you can use all those O/R-mappers in combination with all the other features Spring offers, like simple declarative transaction management mentioned before. Springs AOP package prov
7、ides an AOP Alliance compliant aspect-oriented programming implementation allowing you to define, for example, method-interceptors and pointcuts to cleanly decouple code implementing functionality that should logically speaking be separated. Using source-level metadata functionality you can incorpor
8、ate all kinds of behavioral information into your code, a little like .NET attributes. Springs Web package provides basic web-oriented integration features, such as multipart functionality, initialization of contexts using servlet listeners and a web-oriented application context. When using Spring t
9、ogether with WebWork or Struts, this is the package to integrate with. Springs Web MVC package provides a Model-View-Controller implementation for web-applications. Springs MVC implementation is not just any implementation, it provides a clean separation between domain model code and web forms and a
10、llows you to use all the other features of the Spring Framework like validation. Springs web MVC framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, locale and theme resolution as well as support for upload files
11、. The default handler is a very simple Controller interface, just offering a ModelAndView handleRequest(request,response) method. This can already be used for application controllers, but you will prefer the included implementation hierarchy, consisting of, for example AbstractController, AbstractCo
12、mmandController and SimpleFormController. Application controllers will typically be subclasses of those. Note that you can choose an appropriate base class: If you dont have a form, you dont need a FormController. This is a major difference to Struts. You can use any object as a command or form obje
13、ct - theres no need to implement an interface or derive from a base class. Springs data binding is highly flexible, for example, it treats type mismatches as validation errors that can be evaluated by the application, not as system errors. So you dont need to duplicate your business objects properti
14、es as Strings in your form objects, just to be able to handle invalid submissions, or to convert the Strings properly. Instead, it is often preferable to bind directly to your business objects. This is another major difference to Struts which is built around required base classes like Action and Act
15、ionForm - for every type of action. Compared to WebWork, Spring has more differentiated object roles. It supports the notion of a Controller, an optional command or form object, and a model that gets passed to the view. The model will normally include the command or form object but also arbitrary re
16、ference data. Instead, a WebWork Action combines all those roles into one single object. WebWork does allow you to use existing business objects as part of your form, but only by making them bean properties of the respective Action class. Finally, the same Action instance that handles the request is
17、 used for evaluation and form population in the view. Thus, reference data needs to be modeled as bean properties of the Action too. These are arguably too many roles for one object. Springs view resolution is extremely flexible. A Controller implementation can even write a view directly to the resp
18、onse, returning null as ModelAndView. In the normal case, a ModelAndView instance consists of a view name and a model Map, containing bean names and corresponding objects (like a command or form, containing reference data). View name resolution is highly configurable, either via bean names, via a pr
19、operties file, or via your own ViewResolver implementation. The abstract model Map allows for complete abstraction of the view technology, without any hassle. Any renderer can be integrated directly, whether JSP, Velocity, or any other rendering technology. The model Map is simply transformed into a
20、n appropriate format, such as JSP request attributes or a Velocity template model. Pluggability of other MVC implementations There are several reasons why some projects will prefer to use other MVC implementations. Many teams expect to leverage their existing investment in skills and tools. In addit
21、ion, there is a large body of knowledge and experience avalailable for the Struts framework. Thus, if you can live with Struts architectural flaws, it can still be a viable choice for the web layer. The same applies to WebWork and other web MVC frameworks. If you dont want to use Springs web MVC, bu
22、t intend to leverage other solutions that Spring offers, you can integrate the web MVC framework of your choice with Spring easily. Simply start up a Spring root application context via its ContextLoaderListener, and access it via its ServletContext attribute (or Springs respective helper method) fr
23、om within a Struts or WebWork action. Note that there arent any plugins involved, so no dedicated integration is necessary. From the web layers point of view, youll simply use Spring as a library, with the root application context instance as the entry point. All your registered beans and all of Springs services can be at your fingertips even without