Presentation is loading. Please wait.

Presentation is loading. Please wait.

240-322 CliServ. J2EE/141 Client/Server Distributed Systems v Objectives –introduce the J2EE specification, and the J2EE SDK –other approaches: Struts,

Similar presentations


Presentation on theme: "240-322 CliServ. J2EE/141 Client/Server Distributed Systems v Objectives –introduce the J2EE specification, and the J2EE SDK –other approaches: Struts,"— Presentation transcript:

1 240-322 CliServ. J2EE/141 Client/Server Distributed Systems v Objectives –introduce the J2EE specification, and the J2EE SDK –other approaches: Struts, Spring –Web Services (XML-RPC) 240-322 Semester 1, 2005-2006 14. J2EE and Web Services

2 240-322 CliServ. J2EE/142 Contents 1.What is J2EE? 2.J2EE Overview 3.Some Services Explained 4.Using Sun's J2EE SDK 5.More Information on J2EE 6.Struts 7.Spring 8.Web Services

3 240-322 CliServ. J2EE/143 1. What is J2EE? v J2EE is the Java 2 Enterprise Edition v J2EE helps with the construction of Web- based client/server applications –it supports simplified networking, concurrency, transactions, easy access to databases, etc. continued

4 240-322 CliServ. J2EE/144 v J2EE emphasies n-tier client/server design. v Application development uses objects, beans, and components. v J2EE is not language neutral –tightly connected to Java continued

5 240-322 CliServ. J2EE/145 v Sun initially released J2EE as a specification, which has been implemented by different vendors –e.g Tomcat from the Jakarta Project  http://jakarta.apache.org/tomcat/ –e.g. JRun from Macromedia (Allaire)  http://www.macromedia.com/software/jrun v The Sun implementation: –http://java.sun.com/j2ee/

6 240-322 CliServ. J2EE/146 2. J2EE Overview servlets JSPs Tag libraries Web container Session beans Entity beans EJB container server-side application presentation logic business logic app. CORBA applet/ appl. JDBC JavaMail RMI IIOP JNDI JMS client network deployment description

7 240-322 CliServ. J2EE/147 v A server-side application usually has two parts: –presentation logic in the Web container u to create HTML pages (and other formats) –business logic in the EJB container u to handle server-side processing

8 240-322 CliServ. J2EE/148 3. Some Service Explained v Servlets –a servlet is a Java object on the server side that can repond to an HTTP message (GET, POST, etc) by calling a method –the results of the method is sent back to the client as a Web page continued

9 240-322 CliServ. J2EE/149 v JSP (Java Server Pages) –JSPs dynamically generate Web pages by using servlets v EJB (Enterprise Java Beans) –Java objects with predefined methods for simplifying network and inter-object communication continued

10 240-322 CliServ. J2EE/1410 v Java IDL (Interface Definition Lang.) –a language which allows Java objects to interact with CORBA objects v RMI-IIOP –a bridge between Java’s RMI and the communication protocol used by CORBA over the Internet (IIOP) continued

11 240-322 CliServ. J2EE/1411 v JTA (Java Transaction API) –JTA lets a Java object control transactions (e.g. bank account updates) v JMS (Java Message Service) –JMS lets a Java object asynchronously send messages to other objects continued

12 240-322 CliServ. J2EE/1412 v JNDI (Java Naming & Directory Interface) –JNDI lets a Java object find other objects (over the network) by using their names continued

13 240-322 CliServ. J2EE/1413 v The deployment description is a text file containing various information on how to configure/initialise the server-side application –the information is written in XML format

14 240-322 CliServ. J2EE/1414 4. Using Sun's J2EE SDK v J2EE SDK is Sun's implementation of the J2EE specification. v J2EE SDK is Sun's implementation of the J2EE specification. v The latest version: –Java 2 SDK, Enterprise Edition, v.1.4: http://java.sun.com/j2ee/1.4/ download.html –also obtain the tutorial for v.1.4 from the page continued

15 240-322 CliServ. J2EE/1415 v This release is available for the following platforms: –Solaris, Windows 2000 Prof. Ed., Windows XP Prof. Ed., Linux Redhat v The API documentation is packaged with the download bundle. continued

16 240-322 CliServ. J2EE/1416 v To download J2EE SDK v.1.4, you have to register as a member of the Java Developer Connection –membership is free v Easier to get it from Aj. Somchai's site: –http://java.coe.psu.ac.th/ RefImp.html#J2EE –102 Mb for everything

17 240-322 CliServ. J2EE/1417 Sun's J2EE SDK as a Diagram

18 240-322 CliServ. J2EE/1418 Java Server Faces (JSF) v An API for building Web-based client-side user interfaces from components. –communication to the server side is built-in –the components are extensible v Simplifies the design and implementation of the presentation level of client/server applications. continued

19 240-322 CliServ. J2EE/1419 v Coding is based on listening for events. v JSF 1.2 will be integrated into the next release of J2EE (version 1.5, renamed to 5.0)

20 240-322 CliServ. J2EE/1420 JSTL v The JavaServer Pages Standard Tag Library –structural tasks, such as iteration and conditionals –tags for manipulating XML documents –internationalization tags –SQL tags –a framework for integrating existing custom tags with JSTL

21 240-322 CliServ. J2EE/1421  The compilation of the examples in the J2EE tutorial use Ant, a Java-based make utility, found at: – http://jakarta.apache.org/ant/  Ant v.1.6.2 (and before) are available here –http://java.coe.psu.ac.th/ OpenSource.html#Ant Ant

22 240-322 CliServ. J2EE/1422 5. More Information on J2EE v J2EE main site: –http://java.sun.com/j2ee/ –it has links to pages dedicated to parts of J2EE (e.g. EJB, JSP, servlets, XML) v Aj. Somchai's J2EE books section: –http://java.coe.psu.ac.th/ ForMember/Books.html#J2EE

23 240-322 CliServ. J2EE/1423 6. Struts v An open source framework –intended to be a simpler replacement for J2EE –many components of J2EE can be used –http://struts.apache.org/ v Utilises the Model-View-Controller (MVC) design style for applications. model controller view notifies updates continued

24 240-322 CliServ. J2EE/1424 v Model tools: –JDBC, EJB, Hibernate v View tools: –JSP, XML/XSLT, JSF v Controller tools: –servlets, tag libraries, specific to Struts v Available from: –http://struts.apache.org/

25 240-322 CliServ. J2EE/1425 7. Spring v Another open source framework –intended to be a simpler replacement for J2EE –many components of J2EE can be used –http://www.springframework.org/ v Utilises the Inversion of Control (IoC)design pattern –the framework does more (manages more), the programmer codes less continued

26 240-322 CliServ. J2EE/1426  The core of Spring's design is the org.springframework.beans package, designed for working with Java Beans –objects utilise standard get/set methods to simplify communication v A Spring bean factory enables objects to be retrieved by name, and manages relationships between objects. continued

27 240-322 CliServ. J2EE/1427 v Configuration details are specified using XML and method prototypes. v Unit testing is simpler. v Primary use is to replace or simplify EJB applications.

28 240-322 CliServ. J2EE/1428 8. Web Services v A collection of XML-based APIs for allowing Web-based (J2EE) applications to: –exchanging messages –describing their services/capabilities –publish their Web service description(s) –find other Web service descriptions

29 240-322 CliServ. J2EE/1429 8.1. Web Service Architecture

30 240-322 CliServ. J2EE/1430 8.2. Some Web Services APIs v Simple Object Access Protocol (SOAP) –XML-based messaging protocol v Web Services Description Language (WSDL) –XML language for describing Web services and their capabilities v Java API for XML Registries (JAXR) –language for building XML directories of information about Web services continued

31 240-322 CliServ. J2EE/1431 v Java API for XML-based RPC (JAX-RPC) –language for converting remote procedure call data into XML v Java API for XML Messaging (JAXM)

32 240-322 CliServ. J2EE/1432 8.3. Focus on XML-RPC v An implementation of RPC which uses HTTP and XML to support remote method calls –there are implementations for Java, C++, PHP, etc. –http://www.xmlrpc.com

33 240-322 CliServ. J2EE/1433 v The most popular Java implementation of XML-RPC is Apache XML-RPC –http://xml.apache.org/xmlrpc –part of the larger Apache XML project

34 240-322 CliServ. J2EE/1434 XML-RPC Approach XML-RPC server XML-RPC client : int x = sqS.square(14) : 1. send inputs as XML in a POST message 2. send result as a HTTP response page sqS handler at foobar.com

35 240-322 CliServ. J2EE/1435 Example XML-RPC Request POST /XMLRPC HTTP/1.0 Host: foobar.com Connection: Close Content-Type: text/xml Content-Length: 151 User-Agent: OSE/XML-RPC sqS.square 14

36 240-322 CliServ. J2EE/1436 XML-RPC Response HTTP/1.0 200 OK Date: Wed, 11 May 2005 22:08:09 GMT Server: Apache/1.3.26 (Unix) Content-Length: 157 Connection: close Content-Type: text/xml 196

37 240-322 CliServ. J2EE/1437 Sample Client Code // create client link to server XmlRpcClient client = new XmlRpcClient( "http://foobar.com/XMLRPC"); // create a parameters vector for the request Vector params = new Vector(); params.addElement( new Integer(14) ); // send the request and get the response Object resultObj = client.execute( "sqS.square", params); int result ((Integer) resultObj).intValue(); // result will be 196

38 240-322 CliServ. J2EE/1438 Sample Server Code public class SquareServer { public SquareServer() {} public Integer square(int x) { return new Integer( x*x ); } : continued

39 240-322 CliServ. J2EE/1439 public static void main(String[] args) { try { // invoke XML-RPC server WebServer server = new WebServer(); // add handler for the service server.addHandler("sqS", new SquareServer()); } catch (Exception ex) {} } } // end of SquareServer class

40 240-322 CliServ. J2EE/1440 8.4. Web Services Resources v The Java Web Services Developer Pack (Java WSDP), version 1.5 –http://java.sun.com/webservices/ or –http://java.coe.psu.ac.th/ RefImp.html#WebServices continued

41 240-322 CliServ. J2EE/1441 v In the CoE library: –Java Web Services for Experienced Programmers Deitel et al, Prentice Hall, 2003 –very detailed, but a little bit out of date


Download ppt "240-322 CliServ. J2EE/141 Client/Server Distributed Systems v Objectives –introduce the J2EE specification, and the J2EE SDK –other approaches: Struts,"

Similar presentations


Ads by Google