Sheet 1XML Technology in E-Commerce 2001Lecture 4 XML Technology in E-Commerce Lecture 4 Case Study: XmlMessenger.

Slides:



Advertisements
Similar presentations
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
Advertisements

 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Multi-Model Digital Video Library Professor: Michael Lyu Member: Jacky Ma Joan Chung Multi-Model Digital Video Library LYU9904 Multi-Model Digital Video.
DT228/3 Web Development WWW and Client server model.
JAXB Java Architecture for XML Binding Andy Fanton Khalid AlBayat.
Network Programming Chapter 11 Lecture 6. Networks.
Voice Instant Messenger Andrew Miller CS 491B Fall 2006 Professor Sun.
Writing Enterprise Applications with J2EE (Sixth lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
Internet…issues Managing the Internet
Wireless LAN Topology Visualiser Project Supervisor: Dr Arkady Zaslavsky Project Team Members: Jignesh Rambhia Robert Mark Bram Tejas Magia.
© Lethbridge/Laganière 2001 Chap. 3: Basing Development on Reusable Technology 1 Let’s get started. Let’s start by selecting an architecture from among.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Overview of Database Languages and Architectures.
Networking with Java CSc 335 Object-Oriented Programming and Design Spring 2009.
Web Services CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
CEG3185 Tutorial 4 Prepared by Zhenxia Zhang Revised by Jiying Zhao (2015w)
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
TIBCO Designer TIBCO BusinessWorks is a scalable, extensible, and easy to use integration platform that allows you to develop, deploy, and run integration.
CVSQL 2 The Design. System Overview System Components CVSQL Server –Three network interfaces –Modular data source provider framework –Decoupled SQL parsing.
1 Introduction to Web Development. Web Basics The Web consists of computers on the Internet connected to each other in a specific way Used in all levels.
An Introduction to the Java ME Project Jens A Andersson.
INTRODUCTION TO WEB DATABASE PROGRAMMING
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
CS 352-Socket Programming & Threads Dept. of Computer Science Rutgers University (Thanks,this slides taken from er06/
Cli/Serv.: JXTA/151 Client/Server Distributed Systems v Objective –explain JXTA, a support environment for P2P services and applications ,
Databases and the Internet. Lecture Objectives Databases and the Internet Characteristics and Benefits of Internet Server-Side vs. Client-Side Special.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
T Network Application Frameworks and XML Web Services and WSDL Sasu Tarkoma Based on slides by Pekka Nikander.
1 Document Object Model (DOM) MV4920 – XML 24 September 2001 Simon R. Goerger MAJ, US Army
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Instant Messaging for the Workplace A pure collaborative communication tool that does not distract users from their normal activities.
CSCI 6962: Server-side Design and Programming Web Services.
James Holladay, Mario Sweeney, Vu Tran. Web Services Presentation Web Services Theory James Holladay Tools – Visual Studio Vu Tran Tools – Net Beans Mario.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Outline Overview Video Format Conversion Connection with An authentication Streaming media Transferring media.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
Ex3 Preview, Swing tutorial Ex1 review Amit Shabtay.
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
Sheet 1XML Technology in E-Commerce 2001Lecture 3 XML Technology in E-Commerce Lecture 3 DOM and SAX.
MobileMAN Internal meetingHelsinki, June 8 th 2004 NETikos activity in MobileMAN project Veronica Vanni NETikos S.p.A.
1 Cisco Unified Application Environment Developers Conference 2008© 2008 Cisco Systems, Inc. All rights reserved.Cisco Public Introduction to Etch Scott.
1 Welcome to CSC 301 Web Programming Charles Frank.
A Case Study: UIM The Universal Instant Messenger Babak Esfandiari Carleton University SYSC 5800 Winter 2003.
© Lethbridge/Laganière 2005 Chap. 3: Basing Development on Reusable Technology The Client-Server Architecture A distributed system is a system in.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
CSC 480 Software Engineering Socket. What is Socket? A socket is one end-point of a two-way communication link between two programs running on the network.
© 2009 Research In Motion Limited Advanced Java Application Development for the BlackBerry Smartphone Trainer name Date.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction JAXP. Objectives  XML Parser  Parsing and Parsers  JAXP interfaces  Workshops 2.
A Demonstration of Collaborative Web Services and Peer-to-Peer Grids Minjun Wang Department of Electrical Engineering and Computer Science Syracuse University,
Stream Spider Distributed Music Streaming Service with Sliced Music Files from Different Originating Hosts Justin Steffy and Michael D. Elder.
Project Scenario for OpX. High-level Overview In the Test GUI Controller, opXController, for the opX command there is conceptually a call to an appropriate.
13 Copyright © 2004, Oracle. All rights reserved. Adding Validation and Error Handling.
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
External Messaging Services. Page 2 External Messaging: Extends the power of Presence and Instant Messaging outside corporate Network Provided only to.
Prepared by Dr. Jiying Zhao University of Ottawa Canada.
Distributed Systems CS Project 1: File Storage and Access Kit (FileStack) Recitation 1, Aug 29, 2013 Dania Abed Rabbou and Mohammad Hammoud.
Li Tak Sing COMPS311F. Case study: a multithreaded chat server The source contains 3 files: ChatServer //the chat server ChatThread //the thread on the.
10-1 JXTA Messages Learning Objectives ● This module will help you... – Develop applications and services which exchange messages either through.
1 Validation SAX-DOM. Objectives 2  Schema Validation Framework  XML Validation After Transformation  Workshops.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
USING ANDROID WITH THE INTERNET. Slide 2 Lecture Summary Getting network permissions Working with the HTTP protocol Sending HTTP requests Getting results.
Socket Programming Ameera Almasoud
Object-Orientated Analysis, Design and Programming
T Network Application Frameworks and XML Web Services and WSDL Sasu Tarkoma Based on slides by Pekka Nikander.
Block 15 Developing the Calculator application
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Presentation transcript:

Sheet 1XML Technology in E-Commerce 2001Lecture 4 XML Technology in E-Commerce Lecture 4 Case Study: XmlMessenger

Sheet 2XML Technology in E-Commerce 2001Lecture 4 Instant Messaging; Case Study: XMLMessenger –Communication between client and server; –Application classes; –Sending and receiving XML through network; –User login; –Sending and receiving messages; Summary; Lecture Outline

Sheet 3XML Technology in E-Commerce 2001Lecture 4 Overview XML Technologies and Applications XML Docs Logical Structure Physical Structure DTD XML Schema Meta-Modeling XML Parser Well-formedness Validity SAXDOM Applications E-Commerce

Sheet 4XML Technology in E-Commerce 2001Lecture 4 One of the most popular communication services; 175 million users are expected by 2002; Deployment on new client types is expected: mobiles, PDAs, TVs; Vendors: –AOL; –Yahoo; –Infoseek; –ICQ; Instant Messaging An E-Commerce Application

Sheet 5XML Technology in E-Commerce 2001Lecture 4 Case Study XMLMessenger Simple Client/Server E-Commerce application; Demonstrates some of XML capabilities utilized by the current eCommerce systems: –Platform and language independent data representation; –Standardized data exchange between involved parties; –Communication protocol implementation;

Sheet 6XML Technology in E-Commerce 2001Lecture 4 XML Messenger User 1 User 2 User 3 User 4 Messenger Server Message to User 3 Message to User 1

Sheet 7XML Technology in E-Commerce 2001Lecture 4 XML Messenger Login User 1 User 2 User 3 LoginName In UseCurrent Users New User User 1 User 2 User 3 User 2 User 3 User 1

Sheet 8XML Technology in E-Commerce 2001Lecture 4 XML Messenger Messages User 1 User 2 User 3 Message to User 2 <message to=“User 2” from=“User 1”> Hello! <message to=“User 2” from=“User 1”> Hello! Messenger Server

Sheet 9XML Technology in E-Commerce 2001Lecture 4 XML Messenger Logout User 1 User 2 User 3 Logout Logout User 1 User 1 Logout User 1 User 1 Messenger Server

Sheet 10XML Technology in E-Commerce 2001Lecture 4 XML Messenger Class Diagram

Sheet 11XML Technology in E-Commerce 2001Lecture 4 Class Responsibilities MessengerServer: –Listens for new client connections; –Maintains an in-memory XML document with online users; –Manages a set of threads (one thread per client); UserThread: –Communicates with a particular client; MessengerClient: –Communicates with the corresponding thread on the server; –Manages client-side GUI;

Sheet 12XML Technology in E-Commerce 2001Lecture 4 Class Responsibilities ClientStatus: –Displays a list of online users; –Manages conversations with other users; Conversation: –Displays the messages exchanged with a particular user; –Provides interface for entering a new message;

Sheet 13XML Technology in E-Commerce 2001Lecture 4 Demo - Deitel 10, page 263; Tools: –Java 1.2.2; –Java API for XML Processing (JAXP) 1.0.1; Classes: jaxp.jar and parser.jar; Demo files: –MessengerServer.java –UserThread.java –MessengerClient.java –ClientStatus.java; –Conversation.java XML Messenger Demo

Sheet 14XML Technology in E-Commerce 2001Lecture 4 Implementation Sending XML through network OutputStream output; Document message; try { ((XmlDocument)message).write(output); } catch (IOException e){ e.printStackTrace(); } This fragment is used in: MessengerClient, method send; UserThread, method send;

Sheet 15XML Technology in E-Commerce 2001Lecture 4 Implementation Receiving XML from network InputStream input; int bufferSize = 0; bufferSize = input.available(); if (bufferSize > 0) { byte buf[] = new byte[bufferSize]; input.read(buf); InputSource source = new InputSource( new ByteArrayInputStream(buf)); Document message = builder.parse(source); if (message != null) messageReceived(message);} This fragment is used in UserThread.run and MessengerClient.runMessengerClient.

Sheet 16XML Technology in E-Commerce 2001Lecture 4 Implementation User Login

Sheet 17XML Technology in E-Commerce 2001Lecture 4 Implementation User Login

Sheet 18XML Technology in E-Commerce 2001Lecture 4 Login message creation (MessengerClient.java): factory=DocumentBuilderFactory.newInstance(); builder=factory.newDocumentBuilder(); ……… public void loginUser(){ Document submitName = builder.newDocument(); Element root = submitName.createElement("user"); submitName.appendChild(root); root.appendChild( submitName.createTextNode(name.getText())); send(submitName); } User Login

Sheet 19XML Technology in E-Commerce 2001Lecture 4 Getting output and input streams (MessengerClient.java): public void runMessengerClient(){ ….……………………….. output = clientSocket.getOutputStream(); input = clientSocket.getInputStream();} Sending an XML message through the network (method send ) : try { ((XmlDocument)message).write(output); } catch (IOException e) { e.printStackTrace();} User Login

Sheet 20XML Technology in E-Commerce 2001Lecture 4 Reading the XML message from the network stream (UserThread.java) public void run(){ …………………………………………….. int bufferSize = 0; bufferSize = input.available(); if ( bufferSize > 0 ) { byte buf[] = new byte[bufferSize]; input.read(buf); InputSource source = new InputSource( new ByteArrayInputStream(buf)); Document message = builder.parse(source); if ( message != null ) messageReceived(message); Class InputSource in package org.xml.sax User Login

Sheet 21XML Technology in E-Commerce 2001Lecture 4 Analyzing the message (UserThread.java): public void messageReceived(Document message){ Element root = message.getDocumentElement(); if (root.getTagName().equals("user")) { String enteredName= root.getFirstChild().getNodeValue(); if (server.findUserIndex(enteredName)!= -1) nameInUse(); else { send(server.getUsers()); username = enteredName; server.addUser(this); } …………………………………………………………………. User Login

Sheet 22XML Technology in E-Commerce 2001Lecture 4 Initialization of the document with user names (MessengerServer.java): private Document initUsers() { Document init = builder.newDocument(); init.appendChild(init.createElement("users")); return init; } User Login

Sheet 23XML Technology in E-Commerce 2001Lecture 4 Adding new user (MessengerServer.java): public void addUser(UserThread newUserThread){ String userName = newUserThread.getUsername(); updateGUI( "Received new user: " + userName ); // notify all users of user's login updateUsers( userName, "login" ); // add new user element to Document users Element usersRoot = users.getDocumentElement(); Element newUser = users.createElement( "user" ); newUser.appendChild( users.createTextNode( userName ) ); usersRoot.appendChild( newUser ); updateGUI( "Added user: " + userName ); // add to Vector onlineUsers onlineUsers.addElement( newUserThread );} User Login

Sheet 24XML Technology in E-Commerce 2001Lecture 4 Notification for new user login (MessengerServer.java): public void updateUsers(String userName, String type){ Document doc = builder.newDocument(); Element root = doc.createElement( "update" ); Element userElt = doc.createElement( "user" ); doc.appendChild( root ); root.setAttribute( "type", type ); root.appendChild( userElt ); userElt.appendChild(doc.createTextNode(userName)); // send to all users for (int i = 0; i < onlineUsers.size(); i++){ UserThread receiver = (UserThread)onlineUsers.elementAt( i ); receiver.send( doc );} User Login

Sheet 25XML Technology in E-Commerce 2001Lecture 4 Message Sending

Sheet 26XML Technology in E-Commerce 2001Lecture 4 Message Sending

Sheet 27XML Technology in E-Commerce 2001Lecture 4 Construction of a message in the conversation window (Conversation.java): public void submitMessage(){ …………………… Document sendMessage; …………………… sendMessage = builder.newDocument(); Element root = sendMessage.createElement("message"); root.setAttribute( "to", target ); root.setAttribute( "from", clientStatus.getUser() ); root.appendChild( sendMessage.createTextNode( messageToSend )); sendMessage.appendChild( root ); client.send( sendMessage ); ……………………………… Message Sending

Sheet 28XML Technology in E-Commerce 2001Lecture 4 Message handling in MessengerServer: public void sendMessage(Document message){ Element root = message.getDocumentElement(); String from = root.getAttribute("from"); String to = root.getAttribute("to"); int index = findUserIndex(to); ……………………………………… UserThread receiver = (UserThread) onlineUsers.elementAt(index); receiver.send(message); ……………………………………… } Message Sending

Sheet 29XML Technology in E-Commerce 2001Lecture 4 Message handling on the recipient side (MessengerClient.java): public void messageReceived(Document message){ Element root = message.getDocumentElement(); ……………………… if(root.getTagName().equals("message")){ String from = root.getAttribute( "from" ); String messageText = root.getFirstChild().getNodeValue(); …………………… int index = findConversationIndex( from ); …………………… Conversation receiver = (Conversation) conversations.elementAt(index); receiver.updateGUI(from+": "+messageText); Message Sending

Sheet 30XML Technology in E-Commerce 2001Lecture 4 Demonstration of XML technology for a simple E- Commerce application; Implementation of a communication protocol with XML messages; Handling of in-memory XML documents through DOM calls; Sending and receiving XML through network connection; Read: Deitel 10; Assignment: Modify the login message to include information about login time. Update the user interface accordingly; DeitelEx 10.4 For more detailed explanation and some hints see the course site. Summary