Transcript Java and Distributed Computing Lecture 3 UMass Lowell Computer Science 91.460
UMass Lowell Computer Science 91.460
Java and Distributed Computing
Prof. Karen Daniels
Fall, 2000
Lecture 3
HW#1 Jini Overview C++ Diagnostic Results
Mon. 9/11/00
new http://www.cs.uml.edu/~kdaniels/courses/java2000.html
Question from Last Lecture...
What is socket-based communication?
In a Java context, Deitel answers this on p. 936 in introduction to Servlets. Java has networking support for: “socket-based communications that enable applications to view networking as streams of data - a program can read from a socket or write to a socket as simply as reading or writing to a file.” “packet-based communications that enable individual packets of information to be transmitted - commonly used to transmit audio and video over the Internet.” Chapter 21 of Deitel treats Java networking
Homework #1
Homework #1
Assigned Due Content
Wed, 9/6 Fri, 9/8 Fri, 9/8 Fri, 9/15 Read Ch 1 (Deitel) Mon, 9/11 Read Ch 1, 2 (Edwards) Read Ch 2, 3 (Deitel) Fri, 9/15 Assignment #1, Part 1 short-answer questions Mon, 9/18 Assignment #1, Part 2 “Hello World” programming (application and applet)
Homework is due at the start of lecture on the due date.
Introduction to Java Applications
Java application is executed using the Java interpreter (but not inside browser like an applet) Application begins execution in main() main() is
static
method inside class Welcome1.java
// Save this in file Welcome1.java
public class Welcome1{ public static void main( String args[] ) { System.out.println( "Java is fun!" ); } }
javac
Welcome1.java Welcome1.class
java
Welcome1
Similar application code is on p.36 of Deitel, Chapter 2
HW#1 HelloWorld Application
Refer to p. 36 of Deitel, Chapter 2 for their Welcome1.java application Modify: System.out.println( ) statement Change name of class and file
Compiling and Running on a PC
Introduction to Java Applets
Java applet is executed inside a WWW browser (or appletviewer) using a Java interpreter that is inside the browser.
// Save this file in Welcome1Applet.java
import java.applet.*; import java.awt.*; Welcome1Applet.java
javac
Welcome1Applet.java
public class Welcome1Applet extends Applet{ public void paint(Graphics g) { g.drawString( "Java is fun!”, 25, 50 ); } } Welcome1Applet.class
Welcome1Applet.html
Save this file in Welcome1Applet.html
appletviewer
Welcome1Applet.html
HW#1 HelloWorld Applet
Refer to p. 86 and p. 90 of Deitel, Chapter 3 for their WelcomeApplet.java applet Modify: .java file: g.drawString( ) statement Change name of class and file Extend Applet instead of JApplet unless you want to use Swing here. If extending Applet, import java.applet.*; .html file: Change name of class and file
Compiling and Running on a PC
Appletviewer on a PC
Browser on a PC
Computing Environment
Java 2 platform: Java 2 SDK v. 1.2.1
http://www.javasoft.com/products/jdk/1.2
Jini v. 1.1
http://www.javasoft.com/products/jini UML CS UNIX environment Optional: PC environment (code must also run on UNIX) Java integrated development environment 2 are on disk with Deitel textbook (NetBeans caveat)
Make sure you have a UML CS UNIX account
Jini Overview
What is Jini?
J
ini
I
s
N
ot
I
nitials
portions of this slide contributed by Ayal Spitz
Sun’s Jini Vision
Initial Sun marketing focused on hardware Appliances in a home or office connecting to a network Jini’s goal is to make it possible for all of these appliances to seamlessly detect and communicate with one another Technology can also support software services jCable box Video Tuner jTV Video Display jVCR Digital Storage jComputer portions of this slide contributed by Ayal Spitz jStereo
What is Jini?
Java-based connection framework developed by Sun Microsystems Philosophy: plug ‘n play network blur distinction between hardware and software “self-healing” Elements: discovery, lookup, leasing, remote events, transactions, JavaSpaces
Background on Jini Technology
Lookup Service Service Item Proxy Attribute Attribute Attribute Attribute Client Service Item Proxy Attribute Attribute Attribute Attribute proxy manages service interaction Service Provider Service Item Proxy Attribute Attribute Attribute Attribute
5 Key Concepts
Discovery: find communities on a network and join them Lookup: use Lookup Service(s) to find services and use them Leasing: resource is “loaned” to some consumer for fixed time period Remote Events: allow services to notify others of their state changes Transactions: protocol to support multiple services moving to “safe” state
Some Jini Definitions
Service: an entity on the network (e.g. hardware device or software module) that can be used by other Jini participants Community: a group of Jini services that are “aware” of each other (typically workgroup size) Group: used by Jini APIs to specify and represent a community But, due to network separation, different communities may have same group name Federation: a collection of communities that are “aware” of each other
Discovery Example: Multiple Community
Service Provider 3 Service 3 Item Service Provider 1 Service 1 Item Client A Service 1 Item Service 4 Item Lookup Service Service 2 Item Service 3 Item Lookup Service Service 1 Item Service 2 Item Service 3 Item Client C Service 3 Item Client D Service 1 Item Client E Lookup Service Service 4 Item Client B Service 2 Item Service 3 Item Service Provider 2 Service 2 Item Service 3 Item Service 4 Item Service Provider 4 Service 4 Item
Requirements for Service, Client
To be a Jini Service: Either you or a delegate must be able to: Connect to a TCP/IP network ( ) Participate in discovery to find a Lookup Service Register with a Lookup Service to provide proxy Keep leases current To be a Jini Client: Participate in discovery to find a Lookup Service Communicate with a Lookup Service to receive service proxy
Extra “machinery” needed:
- http server(s) for each machine to offer up downloadable code - RMI activation daemon
c:
Hello World in a Jini Setting...
HelloWorldServiceInterface.java
HelloWorldService.java
HelloWorldClient.java
corejini chapter5 client corejini chapter5 service corejini chapter5 HelloWorldServiceInterface.class
HelloWorldClient$Listener.class
HelloWorldClient.class
HelloWorldServiceInterface.class
HelloWorldServiceProxy.class
HelloWorldService$Listener.class
HelloWorldService.class
service-dl corejini chapter5 policy policy.all
HelloWorldServiceProxy.class
Who Else is in the Game?
(other providers of coordination frameworks/connection technologies/service architectures for distributed computing) HAVi Sony, Sharp, Toshiba, Philips, RCA, Matsushita, Hitachi, Grundig Microsoft & HP ChaiAppliance Plug and Play eSpeak Universal Plug and Play Network protocol level XML device description Salutation Framework
Further Information – Jini
Sun web sites
http://www.javasoft.com/jini
http://www.jini.org
Development – Books “Core Jini” by W. Keith Edwards “The Jini Specification” by Arnold, O’Sullivan, Scheifler, Waldo, and Wollrath Gartner Advisory: Java Jini: A ‘Killer-App Enabler’ for Network Computing? http://gartner.jmu.edu/research/ras/83000/83044/83044.html
portions of this slide contributed by Ayal Spitz
C++ Diagnostic
C++ Diagnostic
Assess C++ background Will not contribute to the course grade Answers on the way out of class Name is optional Provide code snippets, not entire programs Leave unknowns blank
We’ll summarize results of the diagnostic in lecture.