0% found this document useful (0 votes)
60 views

Introduction of Matlab

This document summarizes a report on MATLAB Server Pages (MSP), an open source technical web programming language that uses MATLAB in the background via Java Native Interface (JNI). MSP supports a 3-tier architecture with a web tier, business tier, and database tier. It connects to MATLAB using JMatLink and defines custom tag libraries to call MATLAB from JavaServer Pages. MSP implements various technologies like Java RMI, JDBC, JSF, and WSDL to provide features like distributed computing, database connectivity, web services, and a rapid application development environment.

Uploaded by

Kind Group
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Introduction of Matlab

This document summarizes a report on MATLAB Server Pages (MSP), an open source technical web programming language that uses MATLAB in the background via Java Native Interface (JNI). MSP supports a 3-tier architecture with a web tier, business tier, and database tier. It connects to MATLAB using JMatLink and defines custom tag libraries to call MATLAB from JavaServer Pages. MSP implements various technologies like Java RMI, JDBC, JSF, and WSDL to provide features like distributed computing, database connectivity, web services, and a rapid application development environment.

Uploaded by

Kind Group
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Bayan University

College of Science & Engineering


Department of Computer science

Computer Architecture
Report Topic : MATLAB
Report by :
Ahmed Saeed
Omed Saeed
Sarmad Fwad
Supervisor : st. Alaa
Academic year : 2018/2019 Stage
: third year
Introduction.
MATLAB is a high-level technical computing language. Its user-friendly
syntax, rapid prototyping ability, well written 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 N-Tier
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 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 usesC 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 (WSI) [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:
<matlab:Engine> 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 -----------
<html>
<head>
<%@ include file="/Scripts/header.inc" %>
<title> Hello World! </title> </head>
<body>
<matlab:Engine>
<matlab:Command cmd="rand(1,10)"/>
<matlab:WriteData name="ans"/>
</matlab:Engine>
</body>
</html>
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 servsice.

You might also like