77范文网 - 专业文章范例文档资料分享平台

基于javaEE物业管理系统毕业设计 - 图文(5)

来源:网络收集 时间:2020-05-23 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

太原理工大学毕业设计(论文)用纸

technology are as follows:

Two JavaServer Pages custom tags library for expressing UI components within a JSP page and for wiring components to server-side objects.The user interface created with JSF technology (represented by myUI on the Fig. 1) runs on the server and renders back to the client (in this case the browser).Because web-based applications, must often appease multiple clients (such as desktop browsers, cell phones, and PDAs),JSF has a powerful architecture for displaying components in different ways. As for the browsers, for which JSF is mostly used, the default rendering technology is HTML 4.0, though the others like WML or SVG are also possible.One of the greatest advantages of JSF technology is that it offers a clean separation between behavior and presentation layers.

III. SPRING FRAMEWORK

Spring is a lightweight, inversion of control container, created to address the complexity of enterprise application development.Spring makes possible to use plain JavaBeans to achieve things that were previously only possible with EJBs [10,11].Any Java application can benefit from Spring in terms of simplicity, test-ability, and loose coupling. The Spring Framework contains a lot of features, which are well-organized in seven modules.

When taken as a whole, these modules give everything that is needed to develop enterprise applications, although there is no must to build the application fully on the Spring framework. One can pick and choose only those modules that suit best to the application and ignore the rest. This strategy was chosen for the Hotel Reservation System Since one of the core value propositions of the framework is that of enabling choice by not forcing one to apply any particular architecture, technology or methodology, Spring also provides convenient mechanisms for integration with number of third -party frameworks (also with JSF and iBatis).

IV. APACHE IBATIS DATAMAPPER

Apache iBatis JDBC – based Data Mapper provides simple and flexible way to transport data between relational database and Java, .Net or Ruby application. Contrary to popular Hibernate library, iBatis does not directly tie classes to tables or fields to columns, but instead, it couples objects with results of stored procedures or SQL statements using simple XML

42

太原理工大学毕业设计(论文)用纸

descriptor letting the developer to reach only for required data. The iBatis framework can map nearly any database to any object model and is very tolerant of legacy designs, or even bad designs.Simplicity is the main advantage of the iBatis over other frameworks.

The Hotel Reservation System was primarily built upon JSF technology for the user interface along with auxiliary libraries –Spring and iBatis. The application architecture is presented in Fig. 3.The composition of the system is modular. Each layer is separated with and appropriate interface layer. Such solution makes the architecture not only more error -resistant but also more flexible for changes. The presentation layer consists of the graphical user interface written in the JSF technology andunderlying backing beans objects. It communicates with the Service layer through the service interfaces.Service layer is the central business part of the system where, on the basis of the user input data, proper decisions are made. It also translates input data into explicit form understood for the Data access layer, with which communication takes place by means of Data access interface layer.The Data access layer cooperates with Data Mapper layer and is responsible for data exchange with database.The Data Mapper layer talks via JDBC to database to ask required data. This is a layer where iBatis Data Mapper plays the main role.

V. JSF - SPRING INTEGRATION

In a nutshell, JSF – Spring integration makes Spring managed beans visible as variables to JSF, just as if the Spring beans are configured as JSF managed beans.Before diving into the integration specifics of JavaServer Faces,the general integration step for any web framework must be set forth.All that need to be done, is to declare ContextLoaderListener in the standard JEE servlet web.xml deployment descriptor. This listener initializes the Spring's WebApplicationContext that contains all of the business beans in the application. (Fig. 4).The second step in the integration between Spring and JSF is specific just for JSF. The key class used in this process isDelegatingVariableResolver. To configure this variable the faces-context.xml file must be edited. After opening tag tag must be added and within it the pointing to the Spring's DelegatingVariable Resolver must be put. The example faces -config.xml file is presented in. The DelegatingVariableResolver delegates value lookups to the default resolver of the

43

太原理工大学毕业设计(论文)用纸

underlying JSF implementation, and then going to the Spring's business context WebApplicationContext. This allows to easily inject dependencies into one's JSF-managed beans.

Example of faces-config.xml file from Hotel RVI. JSF AND GETMETHOD.The JSF only recommended method for sending input data from an online form to an application server is the POST method,though sometimes there is a strong need for use the GET method instead. In the Hotel Reservati on System the GET method is used during the registration process for bringing about user account activation.The common way to implement the GET method is to create a special filter which can manipulate the header or contents (or both) of a request or response.To put GET method into operation, in case of JavaServer Faces,the following algorithm must be fulfilled in the body of thefilter:

1. Get parameters from the request.

2. Create appropriate backing bean object accordingly to the view that will be used further.

3. Store the backing bean object in the current session. 4. Set changed JSF context as current. 5. Create view and store it in the JSF context. 6. Execute backing beans methods.

The Hotel Reservation System was also based on the Spring library, hence some changes to the raw algorithm were necessary.The foremost method for any filter is doFilter() where the proper filtration happens . public void doFilter(ServletRequest request,

ServletResponse response,

FilterChain chain)throws IOException, ServletException {

FacesContext facesContext = getFacesContext(request, response); if (facesContext != null){ request.getRequestDispatcher(

44

太原理工大学毕业设计(论文)用纸

facesContext.getViewRoot().getViewId()). forward(request, response); }else{

chain.doFilter(request, response); } }

The doFilter method from GET filter implementation As it may be seen on Fig. 6, an additional function implementing the presented algorithm was used to keep the source code clear and easy-to-read.Create appropriate backing bean object.Almost all backing beans from Hotel Reservation System have at least one property of Spring managed -bean origin. Because of that, it is necessary to set this property after backing bean object creation.

WebApplicationContext wac =WebApplicationContextUtils. getRequiredWebApplicationContext (servletContext);

RegisterService registerService = (RegisterService)

wac.getBean(\

ConfirmBean confirmBean = new ConfirmBean(); confirmBean.

setRegisterService(registerService);

Creating backing bean object and setting spring –origin property.Getting Spring managed -bean object requires operating on Spring's WebApplicationContext object that is initialised during the server start-up.Set changed JSFes context as current.When storing backing bean object in the session the whole Faces context becomes changed, therefore it must be set as current in order all modifications take place .

FacesContextFactory contextFactory =(FacesContextFactory) FactoryFinder.getFactory(

FactoryFinder.FACES_CONTEXT_FACTORY);

LifecycleFactory lifecycleFactory =(LifecycleFactory)FactoryFinder.

45

太原理工大学毕业设计(论文)用纸

getFactory(FactoryFinder. LIFECYCLE_FACTORY); Lifecycle lifecycle =lifecycleFactory. getLifecycle(LifecycleFactory. DEFAULT_LIFECYCLE); facesContext = contextFactory.

getFacesContext (servletContext, req,res, lifecycle); ProtectedFacesContext.

setFacesContextAsCurrentInstance (facesContext);

Setting JSF context as current Before the actual setting context into current, it is indispensable to grab Lifecycle object. Lifecycle manages the processing of the entire lifecycle of a particular JSF request. It is responsible for executing all of the phases that have been defined by the JSF specification, in the specified order, unless otherwise directed by activities that occurred during the execution of each phase. An instance of Lifecycle is created by calling the getLifecycle() method of LifecycleFactory, for a specified lifecycle identifier. Because this instance is shared across multiple simultaneous requests, it must be implemented in a thread -safe manner. Using the current Lifecycle object along with ServletContext,HttpServletReqest and HttpServletResponse objects the FacesContext can be updated and becomes up to date.

Create view and store it in the JSF context.After making Faces context actual, the new view is supposed to be created and added to this context, nevertheless it is n ot possible to do it with usage of 'new' operator, instead it has to be done in an indirect manner.

UIViewRoot view = facesContext. getApplication(). getViewHandler(). createView(facesContext, \facesContext.setViewRoot(view);

46

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库基于javaEE物业管理系统毕业设计 - 图文(5)在线全文阅读。

基于javaEE物业管理系统毕业设计 - 图文(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/jiaoyu/1069115.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: