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) Semester 1, J2EE and Web Services
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
CliServ. J2EE/ 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
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
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 –e.g. JRun from Macromedia (Allaire) v The Sun implementation: –
CliServ. J2EE/ 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
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
CliServ. J2EE/ 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
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
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
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
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
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
CliServ. J2EE/ 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: download.html –also obtain the tutorial for v.1.4 from the page continued
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
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: – RefImp.html#J2EE –102 Mb for everything
CliServ. J2EE/1417 Sun's J2EE SDK as a Diagram
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
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)
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
CliServ. J2EE/1421 The compilation of the examples in the J2EE tutorial use Ant, a Java-based make utility, found at: – Ant v (and before) are available here – OpenSource.html#Ant Ant
CliServ. J2EE/ More Information on J2EE v J2EE main site: – –it has links to pages dedicated to parts of J2EE (e.g. EJB, JSP, servlets, XML) v Aj. Somchai's J2EE books section: – ForMember/Books.html#J2EE
CliServ. J2EE/ Struts v An open source framework –intended to be a simpler replacement for J2EE –many components of J2EE can be used – v Utilises the Model-View-Controller (MVC) design style for applications. model controller view notifies updates continued
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: –
CliServ. J2EE/ Spring v Another open source framework –intended to be a simpler replacement for J2EE –many components of J2EE can be used – v Utilises the Inversion of Control (IoC)design pattern –the framework does more (manages more), the programmer codes less continued
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
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.
CliServ. J2EE/ 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
CliServ. J2EE/ Web Service Architecture
CliServ. J2EE/ 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
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)
CliServ. J2EE/ 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. –
CliServ. J2EE/1433 v The most popular Java implementation of XML-RPC is Apache XML-RPC – –part of the larger Apache XML project
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
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
CliServ. J2EE/1436 XML-RPC Response HTTP/ OK Date: Wed, 11 May :08:09 GMT Server: Apache/ (Unix) Content-Length: 157 Connection: close Content-Type: text/xml 196
CliServ. J2EE/1437 Sample Client Code // create client link to server XmlRpcClient client = new XmlRpcClient( " // 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
CliServ. J2EE/1438 Sample Server Code public class SquareServer { public SquareServer() {} public Integer square(int x) { return new Integer( x*x ); } : continued
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
CliServ. J2EE/ Web Services Resources v The Java Web Services Developer Pack (Java WSDP), version 1.5 – or – RefImp.html#WebServices continued
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