[ieee 2010 international conference on innovative computing and communication and 2010 asia-pacific...

4
Updated model information Controller Presentation Receive Information Update model inform submit View Model External System The Scheme to Extending the Web Application Frame with XML Peng-wei Zhang Electrical and Information Engineering College Shaanxi University of Science and Technology Xi’an 710021, P.R.China Email:[email protected] Jing-xia Chen Electrical and Information Engineering College Shaanxi University of Science and Technology Xi’an 710021, P.R.China Email:[email protected] Abstract—To satisfy the enterprise’s current requirement for web application and solve the existing problems in development of it, the paper presents a web application framework based on MVC mode in J2EE platform, and extends it with XML so that the framework is more flexible, expansible and maintainable. This extended framework has been proved feasible and valid by the instance of the Product Collaborative Design Management System. Keywords-J2EE;MVC;XML;Webapplication;Cooperative Design I. INTRODUCTION Nowadays j2ee has become the main technology platform for developing distributed web applications with multi-layers architecture. The integrated frame in the middle layer of j2ee architecture cannot only save the cost of development, but also make the system more available more reliable and more extendable[1]. The designing mode based on MVC structure can well separate the controlling logic from representing logic, and minimize the repetition of code while improve the interoperability of system. But in present, many web-based applications only support the single client, while in practice the client may be many kinds of different fixtures such as PDAWAP browsersome desktop browser and so on which require different data to be represented in different form. Additionally, the general web technologies such as JSP/Servlet and ASP mix some controlling logic code into the web page more or less which make the code less readableless maintainable and less extendable[2]. To the above problems, in the paper a web application frame based on MVC mode is set up firstly with the technologies of JSP/Servlet/EJB on J2EE platform, and the frame extending scheme based on XML is then presented, and the prototype system of collaborative product design process management in virtual enterprise is lastly developed which validates the feasibility and efficiency of the system researching scheme. II. THE BRIEF INTRODUCTION OF J2EE ARCHITECTURE J2EE architecture provides the core technologies for building web-based application frame, which simplifies the complex problems related to the development deployment and management of multi-layered enterprises. J2EE architecture provides the full support for EJBJava Servlet API JSP and XML technologies[3]. The enterprise application model based on J2EE is of multi layers architecture including client Server business logic layer and enterprise information system, which differentiates from the simple Client/Server architecture. The client layer can be represented in HTML Java Applet or Java Applications, the function of server layer can be implemented with JSPServlet and java beans, the business logic is implemented with EJB, and the enterprise information system provides the support for database ERP and PDM systems[4]. III. THE WEB APPLICATION FRAME BASED ON MVC A. The Principle of MVC mode The MVC designing mode is composed of Model View and Controller, just as fig.1 showed. The part of model includes many kinds of object models extracted from the reality world, which encapsulates their attributes and operations and reflects the application logic of these objects. The part of view mainly provides the interfaces between application systems and users, which take charge to present the application function to users and display the state of data models. The part of controller is used to control the interactive operation between view part and model part including controlling user’s access flow and dispatching users’ request to corresponding models and then responding the change of models to view pages. B. The Implementation of MVC-based web application frame In this section, a MVC-based web application frame is discussed and set up with the technologies of JSPServlet and EJB in J2EE platform. In J2EE architecture, JSP can be used to realize the function of view part of MVC mode through running and creating HTML pages and then transmitting them to browser, and the whole system is accessed through interfaces coded in JSP. Servlet can be used to implement the function of controller, and as Servlet is independent of protocol and operation system, it provides the web service by request/response mode and extends the service easily. While EJB and Java Bean respond to realize model function of MVC by processing the detailed data operation. Above all, the emphases of constructing the MVC-based web application frame is the implementation of model and controller. Fig.1 Model-View-Controller mode 2010 International Conference on Innovative Computing and Communication and 2010 Asia-Pacific Conference on Information Technology and Ocean Engineering 978-0-7695-3942-3/10 $26.00 © 2010 IEEE DOI 10.1109/CICC-ITOE.2010.46 149

Upload: jing-xia

Post on 11-Mar-2017

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: [IEEE 2010 International Conference on Innovative Computing and Communication and 2010 Asia-Pacific Conference on Information Technology and Ocean Engineering - Macao, China (2010.01.30-2010.01.31)]

Updated model information Controller

Presentation

Receive Information

Update model inform

submit

View

Model

External System

The Scheme to Extending the Web Application Frame with XML

Peng-wei Zhang Electrical and Information Engineering College Shaanxi University of Science and Technology

Xi’an 710021, P.R.China Email:[email protected]

Jing-xia Chen Electrical and Information Engineering College Shaanxi University of Science and Technology

Xi’an 710021, P.R.China Email:[email protected]

Abstract—To satisfy the enterprise’s current requirement for web application and solve the existing problems in development of it, the paper presents a web application framework based on MVC mode in J2EE platform, and extends it with XML so that the framework is more flexible, expansible and maintainable. This extended framework has been proved feasible and valid by the instance of the Product Collaborative Design Management System.

Keywords-J2EE;MVC;XML;Webapplication;Cooperative Design

I. INTRODUCTION Nowadays j2ee has become the main technology

platform for developing distributed web applications with multi-layers architecture. The integrated frame in the middle layer of j2ee architecture cannot only save the cost of development, but also make the system more available、more reliable and more extendable[1]. The designing mode based on MVC structure can well separate the controlling logic from representing logic, and minimize the repetition of code while improve the interoperability of system. But in present, many web-based applications only support the single client, while in practice the client may be many kinds of different fixtures such as PDA、WAP browser、some desktop browser and so on which require different data to be represented in different form. Additionally, the general web technologies such as JSP/Servlet and ASP mix some controlling logic code into the web page more or less which make the code less readable、less maintainable and less extendable[2].

To the above problems, in the paper a web application frame based on MVC mode is set up firstly with the technologies of JSP/Servlet/EJB on J2EE platform, and the frame extending scheme based on XML is then presented, and the prototype system of collaborative product design process management in virtual enterprise is lastly developed which validates the feasibility and efficiency of the system researching scheme.

II. THE BRIEF INTRODUCTION OF J2EE ARCHITECTURE J2EE architecture provides the core technologies for

building web-based application frame, which simplifies the complex problems related to the development 、deployment and management of multi-layered enterprises. J2EE architecture provides the full support for EJB、Java Servlet API 、 JSP and XML technologies[3]. The enterprise application model based on J2EE is of multi layers architecture including client 、 Server 、 business logic layer and enterprise information system, which

differentiates from the simple Client/Server architecture. The client layer can be represented in HTML、 Java Applet or Java Applications, the function of server layer can be implemented with JSP、Servlet and java beans, the business logic is implemented with EJB, and the enterprise information system provides the support for database、ERP and PDM systems[4].

III. THE WEB APPLICATION FRAME BASED ON MVC

A. The Principle of MVC mode The MVC designing mode is composed of Model、

View and Controller, just as fig.1 showed. The part of model includes many kinds of object models extracted from the reality world, which encapsulates their attributes and operations and reflects the application logic of these objects. The part of view mainly provides the interfaces between application systems and users, which take charge to present the application function to users and display the state of data models. The part of controller is used to control the interactive operation between view part and model part including controlling user’s access flow and dispatching users’ request to corresponding models and then responding the change of models to view pages.

B. The Implementation of MVC-based web application frame

In this section, a MVC-based web application frame is discussed and set up with the technologies of JSP、Servlet and EJB in J2EE platform.

In J2EE architecture, JSP can be used to realize the function of view part of MVC mode through running and creating HTML pages and then transmitting them to browser, and the whole system is accessed through interfaces coded in JSP. Servlet can be used to implement the function of controller, and as Servlet is independent of protocol and operation system, it provides the web service by request/response mode and extends the service easily. While EJB and Java Bean respond to realize model function of MVC by processing the detailed data operation. Above all, the emphases of constructing the MVC-based web application frame is the implementation of model and controller.

Fig.1 Model-View-Controller mode

2010 International Conference on Innovative Computing and Communication and 2010 Asia-Pacific Conference on Information Technology and Ocean Engineering

978-0-7695-3942-3/10 $26.00 © 2010 IEEE

DOI 10.1109/CICC-ITOE.2010.46

149

Page 2: [IEEE 2010 International Conference on Innovative Computing and Communication and 2010 Asia-Pacific Conference on Information Technology and Ocean Engineering - Macao, China (2010.01.30-2010.01.31)]

Application Server Web Server

Controller Servlet

View JSP Client

Web Bro

business Bean

Session

Entity Bean

model

Database

Database

Fig.2 MVC-based web application frame

1) The Implementation of Model The model part usually is implemented by some

enterprise Java Beans (EJB) and database access objects (DAO), and EJBs mainly provide the remote process controlling method and DAOs are used to access the data source. As there are varieties of databases, the database accessing operations are encapsulated into DAOs so that EJBs need not to access database directly and the system is more maintainable and reusable.

The session beans and entity beans of model part define detailed attributes and operations of object. According to users’ requirement and software designing principle, to the data set and some insensitive data operation, session beans are often used to access database. While to the single data and some sensitive data operation, it is necessary to apply entity beans with session beans to access the database. In order to make the controller work more easily, some interfaces and process are also defined for operation beans

2) The Implementation of Controller The Controller is the more stable and reusable part of the MVC application frame, and it must be able to control the interactive operation between view part and model part. The foreground controlling mode is used to realize the function of controllers[4]. All users’ request is transmitted to a main object which process the request respectively and then decide the next view page to display. The request transmitted to the main controller is mapped into a file named with RequestMappings.xml, and the file format is as following:

<request-mappings> <url-mapping url= ”request1” useRequestHandler=”true”

requiresSecurityCheck=”true” nextScreen=”nextpage1.jsp”> // define the next page to display

<request-handler-class> request1Handler.class </ request-handler-class > //define the function implementation class

</url-mapping> <!--other requests and their corresponding mappings -->

</request-mappings> The controller is composed of MainServlet 、RequestController and ScreenController. MainServlet receives users’ operation request and process the request through RequestController. Then the processed result is saved into Session. At the same time, MainServlet transmits the control right to ScreenController. The main function of ScreenController is to process the response from MainServlet through displaying the processed result in JSP pages to users’ browser. In the initial process,

ScreenController gets the next page from the page mapping XML file, then according to the processed result organizes the subsequent pages in HTML format and displays them at browsers.

3) The discuss about the advantages and disadvantages of the MVC-based web framework

As this frame separates the model 、 view and controller from each other at the maximal extent, the coupling between the representing logic and the processing logic is looser, the parallel working efficiency is improved greatly, the software component is made more reusable, and the whole system base on the frame becomes more maintainable and extendable. Although this MVC-based web application frame presented in the paper has solved some problems in the course of web application development, there are still some shortcomings at the representation logic caused by JSP[5]:

a) It doesn’t support diversiform client equipment. Because JSP usually represents data in HTML pages, as the result the client can just browser data in HTML format instead of in any other format such as PDA or mobile telephone browser.

b) It doesn’t support the data exchange at inhomogeneous platforms. As JSP syntax doesn’t accord with standard format and inherent tags, the data described in JSP format can’t be parsed well so that JSP isn’t an efficient information representation tool and restricts the data exchange at inhomogeneous platforms

IV. THE SCHEME TO EXTENDING THE WEB APPLICATION FRAME WITH XML

To the shortcomings discussed above, we present a scheme to extend this frame with the technologies of XML、XSLT and Xbean[6]. The standard format of XML and the powerful conversion function of XSLT can help extending the limited function of the view part in this frame.

A. XML、XSL and XBean XML(eXtensible Markup Language)is becoming

the standard for data exchange in variety of web applications. The essence of XML is to make the data content independent of its representation format so that XML can describe and transmit the information in lightweight loading. At the same time, the open data types defined in DTD of XML Schema can be parsed correctly so that the information based on XML meta-format can be exchanged freely at the inhomogeneous platforms.

XSL is a kind of extendable stylesheet language which provides an efficient way to correctly express XML document transformation mechanism[7]. XSL can transform XML information into another data format such as HTML page、PDF document or a piece of sound file through combining XML schema with displaying template, which is called XSLT (eXtensible Stylesheet Language Transformations).

There are many tools can be used to create and process XML document, and the packet of Xerces and JDOM are most in common use. The packet of Xerces includes an

150

Page 3: [IEEE 2010 International Conference on Innovative Computing and Communication and 2010 Asia-Pacific Conference on Information Technology and Ocean Engineering - Macao, China (2010.01.30-2010.01.31)]

View JSP files

XSL

Controller

Model

Request mapping files

Web Browser/

client

XLST

Controller Servlet

XML

creator

Business bean

session bean

Database

entity bean

integrated XML validating parser and mainly executes DOM and SAX standards of W3C XML, and its code is constructed for XBean that is able to create XML document in an immediate way[8]. XBean is a kind of XML processing model that can be set-in timely. As fig.3 showing, XBean can be linked in a chain, in which every XBean is assigned to accomplish an logic step of XML document process and then transmit the processed document to the next XBean as an event object..

Fig.3 XBean connecting chain

B. The extending scheme for MVC-based web application framework From the above discussion, we draw the conclusion

that data in XML format can be represented in any other required form by combining XML with XSL. On the basis of that, an extending scheme for the MVC-based web application frame is drawn as following: Firstly the XML creator is set up in XBean program to transform the data information gathered from user’s request interfaces or JSP feedback pages into XML document[9]. Then it is necessary to program the extendable stylesheet list according to the special requirement of terminal equipment. Finally the prepared XML document can be transformed into the corresponding data format as terminal client equipment requires. The extended MVC-based web application frame is showed as fig.4:

Fig.4 the extended MVC-based web application frame 1) XML creator

The XML creator in the extended frame is implemented through extending the basic XBean classes by creating a DOM document in the processDocument() process in which the data is processed as the former business logic in JSP and then is appended in this DOM tree. Then the method of documentReady in the class of DOMListener is called to encapsulate the DOM document tree into an XML event object, so that the DOM monitoring object Serializer can output the DOM tree into the assigned XML document in form of file stream. The part code to create the XML document in the class of XBean is as following:

Public class xmlCreateBean extends XBean{ Document doc; Public void processDocument () throws

XbeansException{ // overload the method toprocess

the XML document doc= new DocumentImpl () ; // initialize a DOM document

Element root= (Element) doc. createElement(rootName); // create the root node of the DOM tree

doc. appendChild (root); // append the root node appendDataNodes (); // self-defined process to

append the root node DOMListener. documentReady(new DOMEvent(

this, doc)); }// encapsulate the DOM tree into an event object

…….. }

In XML creator, an XML document can be implemented as an instance as the following code showing:

xmlCreateBean xmlCB= (xmlCreateBean) Beans.instantiate(null, “webapp.xbean. xmlCreateBean”);

SerializerBean serializer=( SerializerBean) Beans. instantiate(null, “webapp.xbean. SerializerBean”);

xmlCB.setDOMListener (serializer); serializer. setOutputStream( new

FileOutputStream(“example.xml” )); xmlCB. processDocument( );

2) XSLT transformer At the same time, XSLT must be implemented to

transform the created XML document into the corresponding data format as the terminal client equipment required. List.1 shows an XSL instance. The transformer usually requires to input three parameters: the prepared XML document 、 XSL file and output file stream. The core processes to realize XSL function is as following:

XSLTProcessor processor= XSLTProcessorFactory. getProcessor ( );

Processor. Process (new XSLTInputSource (xmlInputStream),

new XSLTInputSource (xmlInputStream), new XSLTResultTarget (outputStream) );

List.1 the instance of XSL. < ? xml version=”1.0” encoding=”UTF-8” ? > <XSL: stylesheet xmlns: xsl=”http://www.w3.org/ 1999/XSL/Transform” version=”1.0” > <xsl: output method=”html”/ > <xsl: template match=”/” > <HTML><HEAD> <TITLE><xsl: value-of select=”//JetPump” / ></TITLE> </ HEAD> <BODY> <p>< xsl: value-of select=”//Name” / ></ p> <p>< xsl: value-of select=”//Type” / ></ p> …………. </ BODY></ HTML> </ xsl: template> </ xsl: stylesheet>

V. THE INSTANCE OF THE EXTENDED MVC-BASED WEB APPLICATION FRAMEWORK

On the basis of the extended web application framework, a distributed collaborative product design management system for virtual enterprises is developed,

XML document

Data sources XBean XBean

151

Page 4: [IEEE 2010 International Conference on Innovative Computing and Communication and 2010 Asia-Pacific Conference on Information Technology and Ocean Engineering - Macao, China (2010.01.30-2010.01.31)]

and the whole system includes the modules of project establishment、 assignment management、drawing and document management and collaborative tools management[10]. During the process of the system development, the page orientation is arranged firstly according to the detailed design work flow, and the operative logic modules are divided, and then every development group begin to program respectively. The EJB designers answer for programming these functional logic modules. The JavaBean designers are assigned to program the local user interfaces and some operation classes for user roles assignment and system security control. The servlet designers are designated to implement the main controlling module which can dispatch and process users’ request and control relative functional modules work harmoniously. The JSP designers are designated to program the logic code for some interactive pages at server .The XML designers are designated to transform the processed information into XML document and then display them with the mapping of XSL and XSLT according to the detailed client requirement.

The practical instance has proved that based on the above extended framework the web application system with clear structure、better extensibility and flexibility can be developed efficiently. At the same time, the framework also facilitates the collaborative work among distributed designers, accelerates the product design process, and shortens the product design period

VI. CONCLUSION In the paper, a MVC-based web application framework

is set up with technologies of JSP/Servlet/ EJB on J2EE platform, and the implementation detail of the model and controller in this framework are discussed. At the same time, to the shortcomings of view deficiency at client end caused by the limitation of JSP, the scheme to extend the framework with XML is presented, and the key technologies and method to create、transform and display XML document are expatiated. Finally this extended frameworkwork has been proved feasible and valid by the instance of the Product Collaborative Design Management System for Virtual Enterprises.

REFERENCES [1] Yan Cao, Hua Chen, and Lina Yang, ”Distributed Cooperative

Design System Development Based on XML and J2EE Platform”, Proceedings of the 2009 International Symposium on Information Engineering and Electronic Commerce,IEEE Computer Society May. 2009, pp:622-625, doi: 10.1109/IEEC.2009.137.

[2] Zheming Dai, Qing Gu, and Jingping Wang. “Agile Development Platform Based on J2EE Architecture”. Computer Engineering, vol.23, Jun. 2008, pp:51-53

[3] Chongchong Zhao and Xin Wang. “Optimization Technology of Domain-special Data Transmission Based on XML”. Computer Science, vol. 36, Aug. 2009, pp:185-188

[4] Rongxing Lu and Zhou Yu. “Research and Implementation of MVC design mode in J2EE platform”, Computer Application and Research, vol. 3, Mar. 2003, pp:144

[5] Rong Zheng and Shilong Ma. “XML-based Heterogeneous Data Integration System in Grid Environment”. Computer Engineering, vol. 34, Jan. 2009, pp:52-54

[6] Jixue Liu, Millist Vincent. “Querying relational databases through XSLT”, Data & Knowledge Engineering, vol.48, Jan. 2004

[7] Christian Kirkegaard, Anders Mller, and Michael I. Schwartzbach. “Static Analysis of XML Transformations in Java”, IEEE Transactions on Software Engineering , IEEE Press, vol. 3, Mar. 2004

[8] PStijn Dekeyser, Jan Hidders, and PJan Paredaens, “A Transaction Model for XML Databases”,World Wide Web,vol.7, Mar. 2004, pp:29-57

[9] Ivan Kurtev, Klaas van den Berg. “Model driven architecture based XML processing”, Proceedings of the 2003 ACM symposium on Document engineering , ACM Press, Nov.2003, pp: 246 - 248

[10] Paula Leinonen, “Automating XML document structure transformations”, Proceedings of the 2003 ACM symposium on Document engineering, ACM Press, Nov. 2003, P:26-28

152