使用XML,Spring,和struts以MVC为设计模式的分布式应用程序框架

来源:互联网 发布:sql注入语句 编辑:程序博客网 时间:2024/04/27 22:19
MVC Design Pattern for themulti framework

distributed applicationsusing XML, spring and struts

framework

By:Praveen Gupta ,India.Source: 01/2010 | DOAJ

Themodel view controller (MVC) is a fundamental design pattern for the separationbetween user interface logic and business logic. Since applications are verylarge in size these days and the MVC design pattern can weak the coupling amongthe different application tiers of application. this paper presents a web application framework based on MVC in J2EE platform, andextends it with XML so that the framework is more flexible, expansible and easyto maintain. This is a multi tier system including presentation layer, businesslayer,data persistence layer and database layer. This separate codes, andimprove maintainability and reusability of the application. In this paper, weimplemented MVC using spring and struts framework. Our research study show thatapplying multiple framework to design the applications using MVC concepts makesapplications easier compare to a single framework. 

 

I. INTRODUCTION

Webis the very complex issues these days. Since the desire of the companies andorganizations are increasing so the complexity and the performance of the webprogramming matters. Complexity with the different types of communicationdevices is increasing. The business is demanding applications using the web andmany communication devices. So with the increase load of the data on theinternet we have to take care of the architecture issue. Let us discuss inbrief the research done so far in MVC.

 

1.1 NO MVC: In The initial phase of the web development the pages were used to bedesigned in the html. Html is the plain text only. This was the first markuplanguage which can work on the internet. And today stills it works as buildingblock for the all Internet based programming languages. The user has tointeract with the static pages. The information written on the pages had tochange manually. As the time grows the demand arises for a language that caninteract with the user and page can be changed as per the requirement of theuser.

 

1.2MVC Model 1: The first major change in the

architecturecomes with the introduction of the MVC Model 1 Architecture. This architecturewas completely based on the page centric approach. In this model a Java ServerPages to program to control the Presentation, Business Logic and flow of theprogram. In this model the concept of the Business Logic was introduced. Thebusiness logic was hard coded in the form of the Java Beans and scriptlets andexpressions. All this codes was used to write within the JSP page. Let usassume a case when we want to transfer the flow of the jsp application based onthe data we received from the input.

Figure1 Page Navigation in MVC -1 Architecture

 

1.3MVC Model 2 : The model 1 architecture was able to solve some of the problem ofthe web and internet programming but still there were a lot of things missingfrom it. It was centered on the navigation of the jsp pages so there was thescope of the further development in the architecture point of view. During thisprocess the next development was the Model 2 architecture. This problem wassolved using the Servlet and JSP together. The Servest handles the Initialrequest and partially process the data. It set up the beans then forward theresult to the one of the jsp page. The Servlet decide the one of the page to bedisplayed from the list of pages.

Figure2 MVC -2 architecture

 

Inthis Model 2 architecture the JSP Pages were used to Presentation purpose only.The Business logic has been removed from the page. This makes the pages easierto represent and light weight pages which were easy to display on the internetIn this model all Control and application logic were handled by the Servlet.The Servlet was written in the java programming language. So it was also easierto handle the programming part of the Servlet. In this scenario the Servestbecomes the power full for the complete application and It has emerged as thecenter point for the application. In the model 2 architecture the Servletbecomes the gatekeeper for the all common tasks. It provides the commonservices like authentication, authorization, error control and follow of theapplication. This architecture have solved the most of the problems. But stillthere were many new issues emerged while applying this architecture.

 

II. APPLYING ARCHITECTURE WITH MULTIPLE FRAMEWORKS

Weband Internet is ever growing area and the demands for the applications are growing.A single framework is not capable to handle the architecture of the application.To meet the currents requirement of the applications it’s necessary to design aarchitecture to implement the frameworks.

Strutsframework have been designed and developed for the front end control of the webapplications. It provides the various features for the applications thatinteract to the users. It also follows the MVC 2 design features. SpringFramework is the designed to handle the various tasks. The spring work for thedesktop and internet based applications also. It follows the principals of theMVC 2. The simultaneous use of the Struts and spring frameworks in the singleapplication with the applying the MVC Design

principalsso that we can Improve the performance of the applications. Struts Frameworkconsists of three major blocks, Described in brief as follows.

Figure3 Struts Model Architecture

 

Firstis The View Block which controls the presentation part of the complete model.This contains following JSP files which you write for your specific applicationSet of JSP custom tag libraries Resource files for Internationalization.

 

SecondBlock is representing the Controller. This is for navigation the completeapplication. This contains XML configuration files; it contains the tags forthe

ThirdBlock is the Model. This part do the work of the Business Logic, Fetching andstoring data to the database.This contains following Java Beans Enterprise JavaBeans Database. Following figure shows the working of the components in thestruts framework.

Figure1 Component in the Struts Architecture

 

MVCin Struts

Themajor three parts of the MVC are as follows in the spring framework. Servletcontroller (Controller Part) Java Server Pages or any other presentationtechnology (ViewPart)

ApplicationBusiness Logic: in the form of whatever suits the application (Model Part).

SpringComponents.

Inthe spring we also follows the principals of the MVC . It has been designedmore for the desktop and internet based applications. Spring consist of threecore collaborating components. 1. Controller: Handles navigation logic andinteracts with the Service tier for business logic 2. Model: The contractbetween the Controller and the View Contains the data needed to render the ViewPopulated by the Controller 3. View: Renders the response to the request Pullsdata from the model. Core components in the spring MVC are as follows.

 

1.DispatcherServlet:Spring’s Front Controller implementation.It is the first controller whichinteracts to the requests. We can also say it is an implementation of theServlet. It controls the complete flow of the application.

2.Controller: User created component for handling requests encapsulatesnavigation logic delegates to the service objects for business logic.

3.View: Responsible for rendering output. Different views can be selected for thedifferent types of output bases on the results and the viewing device,communication devices.

4.ModelAndView: ModelAndView is the core part of the spring framework. Itimplements the business logic of the application. It is controlled by thecontroller. It stores the business logic and the view associated with it.Whenever it is executed it will the data with the name of the view.

5.ViewResolver: How the output is to be displayed depends on the result receivedfrom ModelAndView. It is used to map logical view names to actual viewimplementations. This part identifies and implement what is the output mediaand how to display it.

6.HandlerMapping: Strategy interface used by

DispatcherServletfor mapping incoming requests to individual Controllers. It identifies therequest and calls the respective handler to provide the services. The followingfigure shows how the model will work. In this the dispatcher Servlet is theentry point for the application. The Struts parts do it’s work and send therequest to the dispatcher Servlet. The Servlet decides the handler. Then itwill call to the controller. Controller will execute the ModelAndView.

Figure5: Sequence flow of application in the spring framework.

 

III. PROPOSED METHODOLOGY

Thisapproach is based a combination of applying the two framework struts and springfor the application development. The sequence diagram for the combinedapplication is explained as above, which is the main driving force for theapplication. This approach assumes that basic knowledge of web applications isessential. We have tested the above concepts and find out it successfully.Major benefits of the above architecture are as follows.

 

1.It will provide a very clean division between actions, action forms,controllers, handlers, JavaBeans models,and views.

2.Spring's MVC is very flexible. Unlike Struts, this forces your Action and Formobjects into concrete inheritance. We are using advantage of both.

3.Spring MVC is entirely based on interfaces. Every part of the Spring MVCframework is configurable.

4.It provides controllers, making it easy to handling of many requests from UserInterface.

5.We can use JSP or Any other Technology to display the view, results to the useron the any of the output device.

6.Spring Controllers are configured via Inversion of Controls. This makes themeasy to test and integrated with other objects managed by spring.

7.Spring MVC web tiers are typically easier to test as compared to Struts webtiers, due to the avoidance of forced concrete inheritance and explicitdependence of controllers on the dispatcher Servlet.

8.The web tier becomes a thin layer on top of a business object layer. Thisencourages good practice.

9.Struts framework was designed for the web interface purpose only. The springframework was developed for the desktop and internet applications. When bothframeworks used as combined it will provide the flexibility of implementation.

 

IV. CONCLUSION

Multipleframework architecture works better as compare to any single frameworkarchitecture. With the effective of the multiple frameworks for the developmentof the large scale applications we can improve the performance of the LargeDatabase application in terms handling number of requests, processing abilityand maximum use of the machinery. It will also open the new scope and newbusiness opportunities’ for the companies and the programmers. It’s recommendedto use the multiple frameworks for the Better performance. Due to large size ofjava code I am unable to provide it here.

 

V FUTURE RESERCH

Opentechnologies are the best to attract the academic and research scholar to work.J2EE is the vast field now a day, its open technologies also. Architecture isnever fixed its goes on changing with the change in the technology. There aremany frameworks available to work with J2EE technologies,Single frame is neversufficient to provide the complete solution with all essential features of theapplication. There is a lot of scope to work further with many other frameworkstoimplement and enhance the MVC architecture.

 

REFERENCES

[1]Shu-qiang Huang, Huan-ming Zhang, ” Research on Improved MVC Design PatternBased on Struts and XSL” , in Information Science and Engineering ISISE 08International Symposium on, 2008, vol. 1 PP. 451 – 455

[2]Juanjuan Yan; Bo Chen; Xiu-e Gao, "Le Wang; Research of StructureIntegration Based on Struts and Hibernate" , in 2009 WRI World Congress onComputer Science and Information Engineering,2009, vol. 7,PP. 530-534

[3]Wojciechowski, J.; Sakowicz, B.; Dura, K.; Napieralski, A.,"MVC model,struts framework and file upload issues in web applications based on J2EEplatform", in Proceedings of the International Conference on ModernProblems of Radio Engineering, Telecommunications and Computer Science 2004,2004,,PP 342-345

[4]Erxiang Chen; Minghui Liu, "Research and Design on Library ManagementSystem Based on Struts and Hibernate Framework",in WASE International Conferenceon Information Engineering ICIE 09, 2009, Vol. 2,PP. 310-313

[5]Yonglei Tao; "Component- vs. application-level MVC architecture", inFrontiers in Education 2002 FIE 2002. 32nd Annual,2002, Vol 1,PP. T2G-7 -T2G-10

[6]Meiyu Fang, "Design and Implement of a Web Examination System Using Strutsand EJB" ,Seventh International Conference on in Web-based Learning 2008,pp.25-28

[7]Wang Ning; Li Liming; Wang Yanzhang; Wang Yi-bing; Wang Jing,"Research onthe Web Information System Development Platform Based on MVC DesignPattern",in IEEE/WIC/ACM International Conference on Web Intelligence andIntelligent Agent Technology, 2008 , Vol 3,pp. 203-206

 

 

 

使用XML,Spring,和struts以MVC为设计模式的分布式应用程序框架

作者:普利文古普塔,印度 来源:2010年1月| DOAJ

抽象的模型-视图-控制器(MVC)是一种基本的设计模式的用户界面逻辑与业务逻辑分离。这些天以来应用程序是非常大的大小和MVC设计模式可以弱耦合的不同应用程序层的应用程序。本文提出一种基于MVC web应用程序框架在J2EE平台,并扩展了XML框架更为灵活,扩展性和易于维护。这是一个多层级系统包括表示层、业务层、数据持久层和数据库层。这个单独的代码,提高应用程序的可维护性和可重用性。在本文中,我们使用springstruts MVC框架实现。我们的研究表明,应用多个框架来设计应用程序使用MVC概念使应用程序更容易与一个单一的框架。

 

I.介绍

这几天网络是非常复杂的问题。自欲望的公司和组织正在增加的复杂性和网络编程的性能至关重要。复杂性与不同类型的通信设备越来越多。业务要求应用程序使用web和许多通讯设备。所以增加负载的数据在互联网上我们必须照顾体系结构的问题。让我们简要讨论MVC的研究到目前为止。

 

1.1没有MVC:在初始阶段的web开发的页面被用来设计htmlHtml是纯文本。这是第一个标记语言可在互联网上工作。今天照片它是所有互联网基础编程语言构建块。用户可以与静态页面。信息写在页面手动不得不改变。随着时间的增长的需求出现了一种语言,可以与用户交互和页面可以改变按用户的要求。

 

1.2 MVC模型1:

第一次重大的变化架构带来的引入MVC模型1架构。这个架构是完全基于以页面为中心的方法。在这个模型中一个Java服务器页面程序控制演示,程序的业务逻辑和流程。在该模型中引入了业务逻辑的概念。业务逻辑被硬编码在Java beanscriptlet、表达式的形式。所有这些代码是用来编写JSP页面内。让我们假设一个案例当我们想将jsp应用程序的基于数据流我们收到从输入。

1 页面导航MVC-1框架

 

1.3 MVC模型2:

模型1架构能够解决一些问题的网络和网络编程,但仍有很多东西丢失。它是集中在jsp页面的导航有进一步发展的范围在体系结构的观点。在这个过程中未来发展是Model 2架构。这个问题解决了一起使用ServletJSP。服务处理初始请求和部分处理数据。它设置bean然后结果转发到一个jsp页面。Servlet决定页面的一个从列表中显示的页面。

2 MVC架构

 

在这个模型中2架构的JSP页面仅用于演示目的。业务逻辑已经从页面删除。这使页面更容易表示和重量轻页面显示什么很容易在互联网上在这个模型中所有的控制和应用程序逻辑都由Servlet处理。Servlet是用java编程语言编写的。所以它也容易处理的编程Servlet的一部分。在这种情况下的服务成为权力全面完整的应用程序,它已成为应用程序的中心点。在model 2架构Servlet成为所有常见任务的看门人。它提供了公共服务,如身份验证、授权、错误控制和应用程序的遵循。此体系结构解决了大部分的问题。但仍有许多新的问题出现在应用这个架构。

 

II.应用架构与多个框架

网络和互联网越来越多领域和应用程序的需求正在增长。一个框架是不能处理应用程序的体系结构。满足电流要求的应用程序有必要设计一个体系结构实现框架。Struts框架设计和开发web应用程序的前端控制。它提供了各种功能的用户交互的应用程序。它也遵循MVC 2设计特点。Spring框架是设计来处理各种任务。Spring的工作桌面和基于互联网的应用程序。它遵循的原则MVC 2。同时使用Strutsspring框架在单个应用程序与应用MVC设计主体,这样我们可以提高应用程序的性能。Struts框架包括三个主要模块,简要描述如下。

3 StrutsModel架构

 

第一个是块控制表示完整的模型的一部分。这包含以下JSP文件编写JSP自定义标记库为您的特定应用程序的国际化资源文件。

第二块是代表控制器。这是导航的完整应用程序。这包含XML配置文件,它包含的标签

第三块模型。这部分工作的业务逻辑,抓取和存储数据到数据库中。它包含以下Java bean Enterprise Java bean数据库。下面的图显示了struts框架中的组件的工作。

1 Struts架构中的组件

 

Struts 中的MVC

Spring框架中,MVC的主要三个部分在spring框架如下。控制器Servlet控制器(部分)Java服务器页面或其他表示技术(ViewPart)应用程序的业务逻辑:无论适合应用程序的形式(模型)的一部分。

Spring我们也遵循MVC的原则。它被设计为桌面和基于互联网的应用程序。Spring包含三个核心组件合作。1。控制器:处理导航逻辑和交互与服务为业务逻辑层2。模型:控制器和视图之间的合同包含所需的数据渲染视图由控制器3。观点:呈现的请求的响应从模型中获取数据。在spring MVC核心组件如下。

1DispatcherServlet:Spring的前端控制器实现。它是第一个控制器进行交互的请求。我们也可以说它是一个Servlet的实现。它控制应用程序的完整流程。

2.控制器:用户创建的组件来处理请求封装导航逻辑代表服务对象的业务逻辑。

3.视图:负责渲染输出。不同的观点可以选择不同类型的输出结果和查看设备的基础上,通信设备。

4.ModelAndView:ModelAndViewspring框架的核心部分。它实现了应用程序的业务逻辑。它是由控制器控制。它存储业务逻辑和与之关联的视图。每当它执行将数据与视图的名称。

5ViewResolver:输出显示收到ModelAndView取决于结果。它是用来实现逻辑视图名称映射到实际的视图。这部分标识和实现输出媒体是什么以及如何显示它。

6HandlerMapping:策略所使用的接口。

DispatcherServlet传入的请求映射到单个控制器。它标识请求,并调用相应的处理程序提供的服务。下面的图显示了模型将工作。在这个dispatcher Servlet应用程序的入口点。Struts部分做的工作和dispatcher Servlet发送请求。Servlet决定处理程序。那么它将调用控制器。控制器将执行ModelAndView

 

5:序列流应用程序的spring框架。

 

III.提出的方法

这种方法的组合应用为基础的两个框架strutsspring应用程序开发。序列图的组合应用程序解释如上所述,这是应用程序的主要驱动力。这种方法假定web应用程序的基本知识是必要的。我们已经测试了上述概念,找出它成功。上述体系结构的主要优点如下。

1.它将提供一个非常干净的部门之间的行动,行动的形式,控制器,处理器,javabean模型和视图。

2SpringMVC非常灵活。不像Struts,这迫使你的行动和表单对象具体的继承。我们使用的优势。

3Spring MVC是完全基于接口。Spring MVC框架的每一部分是可配置的。

4.它提供了控制器,使其易于从用户界面处理的请求。

5.我们可以使用JSP或任何其他技术来显示视图,结果给用户的任何输出设备。

6Spring配置控制器通过控制反转。这使得它们易于测试和与其他对象由spring集成。

7 Spring MVC web层通常更容易测试Struts web层相比,由于避免强迫混凝土继承和显式依赖dispatcher Servlet控制器。

8web层变成了薄层上的一个业务对象层。这鼓励良好的实践。

9Struts框架设计仅供web界面的目的。spring框架开发的桌面和网络应用程序。当两个框架作为结合它将提供实现的灵活性。

 

IV.总结

多个框架架构相比,任何单一的框架体系结构更有效。有效的多个框架发展的大规模应用程序我们可以提高大型数据库应用程序的性能方面处理的请求数量,处理能力和最大使用机械。它还将开放新的范围和新的商业机会的公司和程序员。建议使用多个框架更好的性能。由于大尺寸的java代码我无法提供它。

 

V.未来研究

开放技术是最好的吸引学术和研究学者的工作。J2EE是现在的广阔领域,每天开放技术。架构是不固定的改变与技术的变化。有许多可用的框架使用J2EE技术,单帧从来不是足以提供完整的解决方案与所有应用程序的基本特征。有很多与其他框架的工作范围进一步组织实施,加强MVC架构。

 

参考文献

[1]Shu-qiang Huang, Huan-ming Zhang, ” Research on Improved MVC Design PatternBased on Struts and XSL” , in Information Science and Engineering ISISE 08International Symposium on, 2008, vol. 1 PP. 451 – 455

[2]Juanjuan Yan; Bo Chen; Xiu-e Gao, "Le Wang; Research of StructureIntegration Based on Struts and Hibernate" , in 2009 WRI World Congress onComputer Science and Information Engineering,2009, vol. 7,PP. 530-534

[3]Wojciechowski, J.; Sakowicz, B.; Dura, K.; Napieralski, A.,"MVC model,struts framework and file upload issues in web applications based on J2EEplatform", in Proceedings of the International Conference on ModernProblems of Radio Engineering, Telecommunications and Computer Science 2004,2004,,PP 342-345

[4]Erxiang Chen; Minghui Liu, "Research and Design on Library ManagementSystem Based on Struts and Hibernate Framework",in WASE International Conferenceon Information Engineering ICIE 09, 2009, Vol. 2,PP. 310-313

[5]Yonglei Tao; "Component- vs. application-level MVC architecture", inFrontiers in Education 2002 FIE 2002. 32nd Annual,2002, Vol 1,PP.T2G-7 - T2G-10

[6]Meiyu Fang, "Design and Implement of a Web Examination System Using Strutsand EJB" ,Seventh International Conference on in Web-based Learning 2008,pp.25-28

[7]Wang Ning; Li Liming; Wang Yanzhang; Wang Yi-bing; Wang Jing,"Research onthe Web Information System Development Platform Based on MVC DesignPattern",in IEEE/WIC/ACM International Conference on Web Intelligence andIntelligent Agent Technology, 2008 , Vol 3,pp. 203-206

 

 

 

                                                                                                                                                                                                                日期:2016年2月20日

                                            

 

0 0
原创粉丝点击