CS 603 Jini

15
CS 603 Jini April 10, 2002

description

CS 603 Jini. April 10, 2002. What is Jini? Java Middleware. Tools to construct federation Multiple devices, each with Java Virtual Machine Multiple services Uses (doesn’t replace) Java RMI Adds infrastructure to support distribution Registration Lookup Security. Service. - PowerPoint PPT Presentation

Transcript of CS 603 Jini

Page 1: CS 603 Jini

CS 603Jini

April 10, 2002

Page 2: CS 603 Jini

What is Jini?Java Middleware

• Tools to construct federation– Multiple devices, each with Java Virtual Machine– Multiple services

• Uses (doesn’t replace) Java RMI• Adds infrastructure to support distribution

– Registration– Lookup– Security

Page 3: CS 603 Jini

Service

• Basic “unit” of JINI system– Members provide services– Federate to share access to services

• Services combined to accomplish tasks

• Communicate using service protocol– Initial set defined– Add more on the fly

Page 4: CS 603 Jini

Infrastructure:Key Components

• RMI– Basic communication model

• Distributed Security System– Integrated with RMI– Extends JVM security model

• Discovery/join protocol– How to register and advertise services

• Lookup services– Returns object implementing service (really a local

proxy)

Page 5: CS 603 Jini

Programming Model

• Lookup

• Leasing– Extends Java reference with notion of time

• Events– Extends JavaBeans event model– Adds third-party transfer, delivery and

timeliness guarantees, possibility of delay

• Transaction Interfaces

Page 6: CS 603 Jini

Jini Component Categories

• Infrastructure – Base features• Programming Model – How you use them• Services – What you build

Java / Jini Comparison

Page 7: CS 603 Jini

Lookup Service

• Describes functionality• Describes interface• Lookup is a service

– Can be referenced in another lookup service– Also register lookup with non-Jini naming

• Registering– Discovery protocol: Find a lookup service– Join protocol: Register with the lookup

service

Page 8: CS 603 Jini

Registration

Page 9: CS 603 Jini

Sample Serverpublic class SendHelloServer implements

DiscoveryListener {protected LeaseRenewalManager leaseManager

= new LeaseRenewalManager();public static void main(String argv[]) {

new SendHelloServer();// keep server running to allow time for locator// discovery and keep re-registering the leaseThread.currentThread().sleep(Lease.FOREVER);

}public SendHello() {

LookupDiscovery discover = null;// Prepare for discovery - empty here// Discover a lookup service// This uses the asynchronous multicast protocol,// which calls back into the discovered() methoddiscover = new

LookupDiscovery( LookupDiscovery.ALL_GROUPS);

discover.addDiscoveryListener(this);}

public void discovered(DiscoveryEvent evt) {ServiceRegistrar registrar = evt.getRegistrars()[0];// At this point we have discovered a lookup service// Create information about a serviceServiceItem item = new ServiceItem(null, new

SendHelloImpl(), null);// Export a serviceServiceRegistration reg = registrar.register(item,

Lease.FOREVER);// Renew leasingleaseManager.renewUntil(reg.getLease(), Lease.FOREVER,

this);

}} // SendHelloServer

Page 10: CS 603 Jini

Invocation

Page 11: CS 603 Jini

Sample Client

public class Hello {public static void main(String

argv[ ]) { new Hello(); } public Hello() {

LookupLocator lookup = null;ServiceRegistrar registrar = null;FileClassifier classifier = null;// Prepare for discoverylookup = new LookupLocator(

"jini://www.simple_stuff.com");// Discover a lookup service// This uses the synchronous

unicast protocolregistrar = lookup.getRegistrar();

// Prepare a template for lookup search

Class[ ] classes = new Class[ ] {SendHello.class};

ServiceTemplate template = new ServiceTemplate(null, classes, null);

// Lookup a servicesender = (SendHello)

registrar.lookup(template);// Call the serviceSystem.out.println(

sender.SendHello());

}} // Hello

Page 12: CS 603 Jini

Security

• Principal: Authenticated user making request

• Access control list: What principals can use a service

• JVM security mechanisms ensure services don’t compromise local machine

Page 13: CS 603 Jini

Leasing

• Lease: Right to access a service– Guarantees access for specified time period

• Negotiated as part of service protocol• Allows freeing resource by either end,

without explicit negotiation– Fault tolerance

• Exclusive vs. Non-exclusive– Exclusive: Non-shared resource– Non-exclusive: Allows sharing resource

Page 14: CS 603 Jini

Transactions

• Operations can be wrapped in transaction– What is done in transaction is up to operation– Notion of what “commit” or “abort” means isn’t

specifiedAbort may even change state of system!

• Jini provides two-phase commit protocol– Secure, fault tolerant commit / abort– No semantics enforced by Jini

Page 15: CS 603 Jini

Events

• Notification system

• Object must support/define events

• Other objects can register for notification

• Jini handles communication / reliability issues