节点文献
三层结构中基于反射机制、程序生成器的Struts框架进化研究
【作者】 金望正;
【作者基本信息】 浙江大学 , 计算机软件与理论, 2004, 硕士
【摘要】 近年来,随着软件重用技术研究的不断深入,软件框架作为一种重要的复用技术之一正日益受到人们的重视。框架是一种实现大粒度软件复用的有效途径。 从框架的使用角度来分类,框架可分为白盒与黑盒框架。白盒框架更灵活,但不容易被使用。黑盒框架则刚好相反。框架开始通常是白盒框架,随着框架的逐渐成熟,会一步步进化为黑盒框架,从而提高对复用活动的支持。 Struts是一个广泛使用的开源的web应用程序框架,它帮助程序开发者更快更简单地创建web应用程序,其中的Action组件部分是一个典型的白盒框架。 Java中的反射机制是一种功能强大的API,它提供了创建一个直到运行时才知道类名的类的实例、调用一个直到运行时才知道方法名的方法等等特性。利用reflection API,我们可以创建灵活的应用程序。 程序生成器就是一个程序,它接受一块软件的一个高层规范,并且产生它的实现。利用程序生成器,我们只需在规范(specification)表达是“什么”,由生成器产生具体代码。程序生成器代表了程序族,而不仅仅是单一的特定系统的程序,生成的程序更容易维护,也更正确。 本文主要以Struts+EJB+数据库三层结构中对数据库表的增、删、改操作为示例,探讨如何采用Java语言中的反射机制和程序生成器技术将Struts框架的Action组件部分由白盒框架进化为黑盒框架。首先给出了基于白盒Struts框架的对数据库表的增、删、改操作的一个实现,然后分别采用反射机制和程序生成器技术将Struts框架的Action组件部分在这一目标领域里进化为黑盒框架,从而使所有对数据库的增、删、改不再需要编程,只需在XML文件中进行相应配置即可,达到减少重复代码的数量,提高程序的可维护性,降低开发成本的目的。
【Abstract】 Recently, with the study on software reuse technology ,software framework as a import reuse technology is now receiving more and more attentions .Framework is a important approach to large-grained software reuse.Framework can be grouped into black-box framework and white-box framework according to using manner. White-box framework is flexible,but can not be used easily,however,black-box is quite the reverse. In the beginning,a framework is always a white-box framework,it will evolve into a black-box framework gradually, and improve the support to reuse activity.Struts is a widely used open source web application framework.It helps developers develop web application quickly and easily.The Action component partion of Struts is a typical white-framework.Java reflection API is a powerful application program interface that can: create an instance of a class whose name is not known until runtime,invoke a method on an object, even if the method is not known until runtime. With the reflection API we can develop flexible applications.Program generator is a program that accepts a software’s high level specification and produce its implementationl. With the program generator,all the thing we should do is express "what",generator will generates the code. Program generator represents a family of programs ,not just a program,the generated programs are more maintainable and correct.In this paper, how to evolve the Action component part of struts framework into black-box framework using Java reflection and program generator respectively is discussed, taking the adding,deleting,modifying in a database in Struts+EJB-kiatabase three layers architecture as an Example.I first present a white-box framework based implementaion that adding,deleting,modifying a database,then how to evolve the Action component part of struts framework into black-box framework using Java reflection and program generator respectively in the target domain is discussed,thereby all these operations can implement without programmingjust config in a xml file, reach the objective of reducing the duplicate codes,improving the maintainability,cutting down the cost of developing applications.
【Key words】 Struts; Framework; Framework Evolution; Domain Analysis; Reflection; EJB; XML; Program Generator;
- 【网络出版投稿人】 浙江大学 【网络出版年期】2004年 02期
- 【分类号】TP311.1
- 【被引频次】9
- 【下载频次】237