Introduction System Technical Architecture

14 downloads 10801 Views 978KB Size Report
web based application development platform including database connectivity, ... MSP implements JSP and JSTL to define MATLAB Custom Tag Library, with ...
Department of Electrical Engineering, Yildiz Technical University, Besiktas, Istanbul 34349, Turkey.

Introduction

MATLAB is a high-level technical computing language. Its user-friendly syntax, rapid prototyping ability, wellwritten documentation and all-in-one platform features lead users to code applications on MATLAB. Moreover, users use included compilers to generate stand-alone applications. However, nowadays companies demand NTier applications, which mean that users want to drive MATLAB as a computation engine from other popular programming languages, i.e., Java, C#, C++. As a scenario, users have user interfaces via a web browser or a stand-alone file to run processes. These interfaces send retrieved user commands to the application server, where MATLAB runs. If there is any database or any other routines, these interfaces should call procedures on other servers like “Database Server” or “Business Logic Server”. MATLAB has documentation based on external interfaces [1] describing how to call MATLAB from C/C++/Fortran/Java & C#. Developer can easily access MATLAB through Component Object Model (COM) [2] and Dynamic Data Exchange (DDE) [3] support at Microsoft Windows based platforms. Also, there are built-in C Routines to call MATLAB from other languages. These routines are accessible for both Microsoft Windows and all POSIX based (Linux, UNIX like) operating systems. C and C++ languages are not well formed and not a rapid choice for developing N-Tier applications (for example, Remote Method Invocations and Web Services) like C# [4]. As long as it seems C# on .NET Framework is a suitable solution, C# can only implement C or C++ routines in unsafe blocks, which cause stack overflow [5]. It can be accepted as a satisfactory solution, Java Native Interface (JNI) [6] technology can wrap C routines in Java. In the other hand, MATLAB has a product called “MATLAB Compiler” to generate runtime [7] based DLLs, C# Assemblies or Java classes to use MATLAB code in C, C++, C# or Java. Main purpose is to reduce time in development and easy code management. Besides, MATLAB Compiler has limitations and restrictions [8]. The developer may face with challenges in this solution. There are some approaches that use C Routines of MATLAB to overcome this issue. One of them is a toolbox of MATLAB called MATLAB Web Server [9]. MATLAB Web Server use Common Gateway Interface (CGI) [10] to transfer data from web to MATLAB. Because CGI is a legacy technology, there are several lacks in this solution such as no database connectivity support, no web service architecture, no interaction with other languages like JavaScript [11] and hard coding. Towards, Ohio State University developed “A Java Based Web Interface to MATLAB” [12] solution, which uses C Routines in Java. Although it seems a good candidate with having Kerberos Authentification [13], audio/video playback on HTML and dynamic zoom for images, it has a hard syntax to code because of HTML Embedded Servlets, only supports POSIX based systems, also, it has no built in database support, has no interoperability and web service functionalities. Without having an N-Tier architecture approach and serving a rapid application development environment, it can not lever the demands. To overcome the above mentioned limitations, we present a solution using JNI [14] and supporting N-Tier architecture will be suitable for developer’s demand. In this paper, MATLAB Server Pages (MSP) is developed as a Java based, open source, platform independent application to satisfy developers’ expectations. MSP offers web based application development platform including database connectivity, Remote Method Invocation, Distributed Computing, and Web Services. Not only MATLAB users can use these products, web developers and application engineers can now prefer MATLAB for N-Tier architectures. In short, MATLAB Server Pages is technical web programming language that uses MATLAB in background via JNI.

System Technical Architecture:

MATLAB Server Pages (MSP) is an open source technical web programming language using MATLAB in background. MSP supports “3-Tier Architecture”; Web Tier, Business Tier and Database Tier. Also, MSP consists of “distributed computing” and “parallel processing” via remote procedure calls and web services. MSP uses JavaServer Pages [16] technology to define Custom Tag Libraries [17], called MATLAB Tag Library Definitions (TLDs) & MATLAB Remote Method Invocation (RMI) TLDs, to handle a rapid application development (RAD) environment for web developers. Underlying Java RMI support acts as a gateway for distributed computing and parallel processing. Thus, MSP can use a remote MATLAB just like on local computer. Expression Language Mechanism [18] of JSP Standard Tag Library [19] and MSP Custom Tag Libraries work together to realize database connectivity. MSP implements JavaServer Faces [20] for defining

business logics and business rules including advanced UI components. MSP includes Web Service Definition Language (WSDL) [21] files provide an opportunity for using MATLAB as a Web Service. MSP is Business Process Execution Language (BPEL) [22] and Web Services Interoperability (WS-I) [23] standards compatible.

Figure 1. Contribution of all tiers creates MSP Architecture. As given in Figure 1, MSP architecture can be summarized as follows. 

MATLAB Server Pages connects to MATLAB with Stefan Mueller’s Java Wrapper Class called JMatLink [14]. MSP Java classes drive JMatLink for JavaServer Pages by adding new methods for MATLAB features, JSP page output, imaging on browser, remoting and web services.







MSP implements JSP and JSTL to define MATLAB Custom Tag Library, with including support for expression language and scriptlets. This lets developers to call MATLAB with in JSP page by using HTML tags. MSP main classes are declared as remoting classes. It is possible to register MSP classes and bind them from remote classes. Marshalling serializes MSP classes’ methods and properties to remote site and unmarshalling deserializes them at remote site. MSP includes FTP client classes to pass and retrieve files to/from remote computer. This is designed for transferring images, MATLAB files and outputs not by serialization. Both sides run a web server. If needed, MSP FTP client puts necessary MATLAB files to server and evaluates command on remote server. Generated output, beside images and HTML pages, are transferred back to local computer. Images and HTML Pages are displayed on local computer using HTTP protocol. This provides escapeness for serialization problems. End users, developers, do not need to know these background processes. There are ready custom tags that handle these operations. This custom tag library is called MATLAB RMI Tag Library. Apache Software Foundation’s Axis project has some tools for Java 2 WSDL generations. MSP contains Axis libraries to generate Web Services for its MSP classes. There are two types of WSDLs in MSP. Nowadays, WS-I community tries to minimize web services interoperability problems. MSP has WSDLs for both Java and C# proxy class generators. All of these implementations create Web Tier. MSP Web Tier can be stand-alone from application server using MSP RMI features. By default, MSP comes with MySQL JDBC driver. JSP Standard Tag Library has SQL tag library, which can run SQL expressions on database server. Expression Language Mechanism handles MSP MATLAB Tag Library and JSTL SQL Library interactions. From MSP, developers can connect to a database server. They can retrieve data from MATLAB and store to database and vise versa. This is the Database Tier – EIS Tier of MSP. JavaServer Faces is a technology that has advanced user interface components for JSP and can define navigation rules for business processes by running beans in background. MSP uses Apache Software Foundation MyFaces implementation. The pages that use JSF have MLSPX extension in MSP. Default extension is MLSP for MSP. MLSPXs can call beans and do operations defined in them. Developers can add their beans to MSP. MATLAB Beans works like a Plug-in Logic. If developers use remoting in MATLAB Beans, they can separate business logic and business rules to another server. This puts “Business Tier” to forward.

MSP has several demos and examples on how to use MSP Engine. Client systems can be dynamic web pages, a part of distributed computing and web service operations. These usage examples can be called as a “Client Tier”. The communication between all the tiers (Web Tier, IES Tier, Business Tier and Client Tier) is exampled as shown in Figure 2.

Figure 2. Overview of MSP 3-Tier Architecture MATLAB is installed on Application Server Layer. There are MSP Main Classes on this PC to data exchange over RMI with Web Server. Main Classes have several methods to handle custom JSP Tags at Web Server. For example: tag on Web Server runs; public void engineOpen() { // Reads MSP settings from Bundle. ResourceBundle rb = ResourceBundle.getBundle("MSP"); // Code Dir is the base for MATLAB M-Files, Simulink Models and // Matlab Server Files. All runnable codes and models must be // there. Code_Dir = rb.getString("Code_directory"); // Image Dir is the base for MATLAB created images. Image_Dir = rb.getString("Image_directory");

}

// System out out for Java debugger. System.out.println("MATLAB Server Pages Engine"); javaLink = new JMatLink(); javaLink.engOpenSingleUse(); // Running MSP at Code Dir. javaLink.engEvalString("cd '" + Code_Dir + "'");

This class handles all RMI operations, database connectivity, distributed computing, and web services. Web Server Layer acts as a RMI Client to connect to Application Server. This Web Server has a Remote Method Invocation Interface to MSP Main Classes located at Application Server. This interface includes all methods in these classes. So application in this server can use all functionality of MSP as running on local. Programmers can deploy applications on this server with an easy syntax: Test.mlsp ----------

Hello World!



Web Server connects to Database Server Layer to exchange data using JSTL SQL Library and MSP Tag Libraries. Also end users, who involve Client Tier Layer, can connect to Web Server Layer via a web browser or using web service.

M. Uzunoglu received the B.Sc., M.Sc., and Ph.D. degrees from Yildiz Technical University, Besiktas, Istanbul, Turkey, in 1991, 1996, and 2000, respectively, all in electrical engineering. He was a post-doctoral research fellow in Electrical and Computer Engineering Department, University of South Alabama, Mobile, between February 2005 and August 2006. He is a Faculty Member at Yildiz Technical University and a Research Scholar in Electrical and Computer Engineering Department, University of South Alabama, Mobile. His current research interests include alternative energy sources, power system modeling, analysis and control, power quality, voltage stability, and state estimation. He is the author or coauthor of more than 55 published papers, including 11 articles in refereed journals, 12 papers in conference proceedings, and 4 books. He is currently a member of IEEE. [email protected] A. KIZIL received Electrical Engineering B.Sc. degree from Yildiz Technical University, Besiktas, Istanbul. Also, he received Master of Information Technologies M.Sc. degree from Sabanci University. He has 3 published papers, 3 books and is an author of local computer magazine called CHIP. Currently he is studying Energy Quality at Yildiz Technical University under Electrical Installations graduate program. He has completed courses on PMI methodology. He gives consultancy to IT companies on project management and technical programming subjects. [1] http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/apiext.pdf [2] http://en.wikipedia.org/wiki/Component_Object_Model [3] http://en.wikipedia.org/wiki/Dynamic_Data_Exchange [4] http://www.freevbcode.com/ShowCode.asp?ID=5302 [5] http://www.codersource.net/csharp_unsafe_code.html [6] http://en.wikipedia.org/wiki/Java_Native_Interface [7] http://www.mathworks.com/products/compiler/compiler_support.html [8] http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/compiler_product_page.html [9] http://www.mathworks.com/access/helpdesk/help/toolbox/webserver/webserver.shtml [10] http://www.w3.org/CGI/ [11] http://www.w3schools.com/js/ [12] http://www.ll.mit.edu/HPEC/agendas/proc03/pdfs/samsi.pdf#search=%22A%20Java%20Based%20Web%20Inte rface%20to%20MATLAB%22 [13] http://web.mit.edu/Kerberos/ [14] http://jmatlink.sf.net [16] http://java.sun.com/products/jsp/ [17] http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags.html [18] http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html [19] http://java.sun.com/products/jsp/jstl/ [20] http://java.sun.com/javaee/javaserverfaces/ [21] http://www.w3.org/TR/wsdl [22] http://developers.sun.com/prodtech/javatools/jsenterprise/nb_enterprise_pack/reference/techart/bpel.html [23] http://www.ws-i.org/