MWT Lecture NOtes Unit 5

Download Report

Transcript MWT Lecture NOtes Unit 5

MIDDLE WARE TECHNOLOGIES
B.TECH III YR II SEMESTER
UNIT 5 PPT SLIDES
TEXT BOOKS:
1.Client/Server programming with Java and
CORBA Robert Orfali and Dan Harkey, John
Wiley & Sons,SPD 2nd Edition
2. Java programming with CORBA 3rd Edition,
G.Brose, A Vogel and K.Duddy, Wileydreamtech, India John wiley and sons
INDEX
S.NO.
TOPIC
PPTSLIDES
UNIT 5 PPT SLIDES
LECTURE NO.
1. Two types of Client/Server invocations
2.The static CORBA
3. CORBA program
4. ORB lets with Applets .
5. Dynamic CORBA
6. The portable count
7. dynamic count
8. multi count
L32 L1.1 TO L1.5
L33 L2.1 TOL 2.5
L34 L3. 1 TO L2.5
L35 L4. 1 TO L3.5
L36 L5. 1 TO L4.5
L3
L6. 1 TO L5.5
L38 L7. 1 TO L6.5
L39 L8. 1 TO L7.5
L40 L9.1 TO L9.4
UNIT5 SYLLABUS
• Core CORBA / Java: Two types of
Client/Server invocations-static, dynamic.
The static CORBA, first CORBA program,
ORB lets with Applets, Dynamic CORBA—
The portable count, the dynamic count
multi count.
Lecture 1 slide 1
What is CORBA
• 1.CORBA is a specification for the distributed
object bus architecture defined by OMG
• 2.It is a product of a consortium called the OMG
• 3.OMG includes 800 compinies representing the
entire spectrum of computer industry.
Lecture 1 slide 1
CORBA services
•
•
•
•
•
•
•
•
Lifecycle services
Persistence service
Naming services
Event services
Concurrency services
Transactional services
Relationship services
Externalization
Lecture 1 slide 2
CORBA services
•
•
•
•
•
•
•
Query services
Licensing service
Properties services
Time service
Security service
Trader service
Collection service
Lecture 1 slide 3
Web services
• 1.SOAP(simple object access protocol)
• 2.WSDL(web service description
language)
• 3.UDDI(universal description ,discovery
integration)
Lecture 1 slide 4
What is SOAP
•
•
•
•
•
•
•
SOAP is a communication protocol
SOAP is based on XML
SOAP is a simple and extensible
SOAP will be developed as a W3C standard
SOAP allowed you to get around firewalls
SOAP is a format for sending messages
The basic web services platform is XML plus
HTTP
Lecture 1 slide 5
What is WSDL
•
•
•
•
•
WSDL is written in XML
WSDL is an XML document
WSDL is used to describe web services
WSDL is also used to locate Web services
WSDL is not yet a W3C standard
Lecture 2 slide 1
Benefits of SOA
• Better reuse
• Well defined interfaces
• Easier to maintain
• Better flexibility
Lecture 2 slide 2
DCOM
• DCOM is an extension to COM
• DCOM uses a protocol called the object
remote procedure call (ORPC)
• CORBA uses internet-inter ORB protocol
• DCOM using MIDL
Lecture 2 slide 3
middleware's
• RMI
• RPC
• CORBA
• SOA
• WEB SERVICES
Lecture 2 slide 4
Four main elements of CORBA
• Object request broker
• CORBA services
• CORBA facilities
• Application objects
Lecture 2 slide 5
CORBA facilities
• Are collections of IDL-defined frameworks
That provide services of direct use to
application
Categories
-Horizontal
-Vertical
Lecture 3 slide 1
Core CORBA/java
• Advantages (of static Vs dynamic)
• It is easier to program – remote method name, parameters.
• It provides more robust type checking – complete time
checks.
• It performs well – a single API.
• It is self documenting
• Dynamic: m.i.is more flexible; allows to add new
classes at runtime, useful for tools.
• Steps of CORBA static m.i:
• Create your IDL defs.
• build the interface defs. to the interface
repository.
Lecture 3 slide 2
Core CORBA/java
• pre compile – generates
– client states
– server skeleton
– language specific example class, (CORBA 3.0
calls it a servant class)
• Add the servant impl.code.
• Compile the code. (ref. language compiler)
• Register the run-time objects with the Impl.
Repository.
Lecture 3 slide 3
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Module counter
{
Interface count
{attribute long sum;
Long increment ( );
};
};
Mapping CORBA IDL to Java
Prompt > idl2java count.idl – no – comments – no-tie –no-tie-specifies not to
generate extra delegation class. Still, it generates a Java package counter,
which consist of 5 java classes & 1 Java interface.
Counter.-Count Impl base – server side skeleton
Counter.-st-count : client side stub
Counter.Count Helper – provides useful helper for count clients.
Counter.Count Holder: public instance member of type
Package Counter;
Lecture 3 slide 4
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Counter.Count
Public interface count extends org.orng.CORBA.object.
{
Public int sum ( );
Public void sum (int – vol);
Public int increment ( );
}
Counter.-Example-Count-Example class for count obj.impl.VisiBroken’s
Output:
Package counter;
Public class-example-count extends counter-count ImplBase
{
Public – example – count (java.lang.string name)
{
Super (name;)
}
Lecture 3 slide 5
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Public-example-count ( )
{
Super ( );
}
Public int increment ( )
{
//implement operation . . . . .
}
public void sum (int sum)
{
//implement attribute writer . . .
}
Public int sum ( )
{
Lecture 4 slide 1
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
// implement attribute reader . . . .
}
}
Server side of Count:
// count Impl.Java : The count Implementation Class Count
Impl Base extends Counter-Count Impl Base
{
Private int sum;
Count Impl (string name)
{
Super (name);
S.O.P. (“count object created”);
Sum = 0;
}
Lecture 4 slide 2
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Public int sum ( )
{
Return sum;
}
Public void sum (int val)
{
Sum = val;
}
Public int increment ( )
{
Sum ++
Return sum
}
}
Lecture 4 slide 3
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Main server program:
Class count server
{
Static public void main (string [ ] ays)
{ try
{ org.umg.CORBA.ORB orb = org.umg.CORBA.ORB. init (ays,null);
org.umg.CORBA.BOA boa = cob.BOA – init ( );
count Impl count = new count Impl (“my count”);
roa.obj-is-ready (count);
boa.impl-is-ready ( );
{
Catch (org.umg.CORBA.Systm Exception e)
{
System.error.print ln(e);
}
}
}
Lecture 4 sllide 4
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Client side of Count:
Class Count Client
{
Public static void main (string [ ] ays)
{
Try
{
S.O.P (“initializing the ORB”);
org.umg.CORBA.ORB orb = org.umg.CORBA.ORB init (ays, null);
S.o.p (“building to count object”);
Counter.count counter = counter.count helper.build (orb,”my count”);
S.o.p. (“setting sum to o”);
Counter.sum ((int)o);
//calc.st.time.
Long start Time = sytem.current Time millis ( );
//Increment 1000 times
s.o.p (“incremtning”);
Lecture 4 slide 5
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
for (int i=0, i<1000; i++)
{
Counter.increment ( );
}
//calc.strp.time; print statistics
Long step Time = system.current Time millis ( );
s.o.p. (“Avg ping = “+((stop Time-start Time)/1000t)+msecs”);
s.o.p (“sum=”+counter.sum ());
}
Catch (org.umg.CORBA.system Exception e)
{
System.err.printh (“system Exception”);
System.err.printh(e);
}
}
Lecture 5 slide 1
Core CORBA/java
• }
• O/p
• 1. Local static
Remote static (10mbit/s
Ethernet)
•
3.9 msecs
3.6 msecs
• 2. Symantic visual caf JIT
sum JDK
•
Local
3.9 msec
6.7 msec
•
Remote
3.6 msec
5.6 msec
•
Lecture 5 slide 2
Core CORBA/java
•
•
•
•
•
Orblets with Applets
Applets let you create component – sized apps
that serves can ship to clients via ordinary
HTML pages.
Applets become an instant front-end to the
remote services, you provide; so applets are
“just-in-time” shippable clients.
Applet life cycle: init, start, paint, action,
handler Event, stop, destroy
The HTML Applet Tag: CODE, WIDTH,
HEIGHT, CODEBASE,ALGIN,PARAM
Lecture 5 slide 3
Core CORBA/java
• CORBA-enabled Applet:
– To create applet version of the COUNT client,
enabled it inside an HTML page, download using web
browser, invoke methods on the count server.
– The count IDL – Use count server, as is – so IDL
remains unchanged. Our applet can use both the
• Counter.-st-count and Counter.counter
Helper,as
– Server capture of the Java Count Applet
• Count client Applet
Lecture 5 slide 4
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
The client applet code:
//count client Applet.java Applet client, visiBroker for Java.
Import Java.awt.*;
Public class Count client Applet extends java.applet.Applet.
{
Private Text Fields, count field, ping Time Field;
Private button run Count;
Private Counter.Count.counter;
Public.void init ( );
{
//create a 2 by 2 grid of widgets
Set Layout (new Grid Layout (2,2,10,10));
//Add the from widgets, initialize where
add (new Label (“count”));
add (count Field = new Text Field ( ));
Lecture 5 slide 5
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
count field.set Text (“1000”);
add (run count = new Button (“run”));
add (ping time field = new Text Field ( ));
ping Time field.set Editable (false);
try
{
//Init.the ORB.
Show Status (“Initializing the ORB”);
Org.omg.CORBA.ORB orb = org.umg.CORBA.ORB.init (this,null);
//Build to the count object
Show Status (“Binding to count object”);
Counter = Counter.CountHelper.build(orb,”mycount”);
}
Catch (org.umg.CORBA.System.Exception)
{
Show status (“applet Exception “+e);}
Lecture 6 slide 1
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
}
Public broken action (Event ev, object avg)
{
If (ev.target = = run count)
{
Try
{
// set sum to initial value of 0
Show status (setting sum to 0”);
Counter.sum((int)o);
//get data from ad set value of applet fields.
Show status (“Incrementing”);
Int stop count = Integer.parse Int (count field.get Text( ));
Ping Time Field .set Text (“ “);
//calculate start time.
Long start Time = system.current Time millis( );
Lecture 6 slide 2
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
//increment stop count time
For (int i = 0; i< stop Count; i ++)
Counter.increment ( );
//calculate stop time; show statistics
Long stop time = System.current Time millis( );
Ping Time Field.set Text (“avg ping = “+float.to String (float) (stop time-start
time)/stop -count)+”msecs);
Show status (“sum=”+counter.CORBA sum() );
}
catch (org.umg.CORBA.System Exception e)
{
show status (“system exception “+e);
}
return time;
}
return false;
}
}
Lecture 6 slide 3
Core CORBA/java
•
•
•
•
•
•
•
•
Completion
Prompt . Java c– d\. . . . count client applet.Java
Create a web page
Count .html
<h1> count client Applet </h1>
<hr>
<center>
<applet code = count client applet.class width =
300 height = 60 CODE BASE = classes>
Lecture 6 slide 4
Core CORBA/java
•
•
•
•
•
•
•
•
•
•
•
•
•
•
<paramname = org.umg.CORBA.ORB Class
Value = com.visigenic.vbroken.orb.DRB>
</applet
</count>
<hr>
Results:
Local Vs Remote : Java applet/CORBA count server.
Local static count
Remote static count
JIT compiled
17.6msecs
Interpreted
30.2 msecs
Applets Vs Apps
Java applet
Java app
JIT compiled
16.1 msec
Interpreter
23.3 msec
Lecture 6 slide 5
16.1 msecs
23.3 msecs
3.6 msec
5.6 msec
Dynamic CORBA
•
•
•
•
•
•
•
•
The Portable Count
Make count portable by replacing the visigenic –
specific bind with the CORBA naing semic.
Rylau BOA-specific code in count with PoA semantics.
CORBA Naming Semic:
Generic structures to compose compound names – so
it can work with global naming conventions such as
URLs, domain names, DCE, JNDI, LDAP, NDS, Unix
files, NTfiles etc.
CORBA N.S.in the Tel.white.pages for objects, it lets
you find objects by name.
Name binding – name to obj.ref.
Name context – newspace
Lecture 7 slide 1
Dynamic CORBA
• ex:
• Each named component is a structure with two
attributes –
– identifier – object name string
– kind – string to put a descriptive attribute – ex.file
type.
•
•
•
•
•
IDL Def. try a CORBA name:
//IDL
Type of sequence ,Name component>name;
Struct name component
{Istring id; Istring kind;};
Lecture 7 slide 2
Dynamic CORBA
•
•
•
•
•
•
•
•
•
•
•
•
•
•
The object naming service interfaces:
Naming context – resolve, list, destroy, new-context, unbind, bind, rebind,
bind-context, rebind-context, bind-new-context.
Binding Instructor: next-one, next-n, destroy
C/S Naming Scenarious:
A Server invokes link to associate a logical name with an obj.ref.
The N.S.adds this obj.ref from binding to its namespace database.
client app. Invokes resolve to obtain an obj.ref. to this name.
The client uses the obj.ref. to invoke methods on the target object.
Scenarios 1: Creating the NS.
resolve – initial – references (ORB)
bind-new-context (Root context) – Results context
bind-new-context (Results context) – client made context
bind (client med context) – cascum.
bind (client med context) – PlayeBonce
Lecture 7 slide 3
Dynamic CORBA
• org.umg.CORBA.object obj ref = orb.resolve – initial – refernces
(“name service”);
• org.umg.Cosnaming,naming context root context =
org.umg.cosnaming.naming context helper.maxrow (obj ref);
• Scenario 2: Finding objects:
• resolve-initial –reference (ORB)
• create the name
• resolve (Root context)
• root.value – obj ref
• Invoke methods
• Portable count:
• Count portable client class
• The current IDL
• The current portable Impl class
• The current portable server class
Lecture 7 slide 4
Dynamic CORBA
•
•
The Dynamic Count
In static m.i., a pre compiled stub is required for each interface the client
used.
It is true even in the case of applets, through the stub’s byte codes are
downloaded at run-time.
Dynamic Invocation Interface (DII) is a stub-less binding approach.
The client can invoke any operation on any object without repairing
precompiled stubs i.e., the client discovers interfaces – related infn. at
invocation time, it requires no compile – time knowledge.
To discover remote objects, the mechanisms available are
•
•
•
•
–
–
–
‘string field’ object reference is provided to the client; which is converted into a
live object reference an the connection is made.
Clients can look up objects by using the CORBA naming service.
Clients can discover objects by using the CORBA’s yellow pages – The Trader
service.
Lecture 7 slide 5
Dynamic CORBA
•
•
•
•
•
•
•
•
•
•
•
•
The CORBA dyn. invocation process:
Obtain the Interface name
get – interface ( )
returns a ref. to interface ref. object
Obtain method Description
Look up – name ( )
Describe ( )
To obtain the method’s full IDL def.
Create Argument list:
Create – list ( )
Add-item ( ) . . . add item ( ). . add-item ( )
Create the request
Lecture 8 slide 1
Dynamic CORBA
• Create-request (object reference, method,
arguments list)
• Invoke the Remote method
• Using RPC
Invoke ( )
• send/receive
send-deformed ( )
• deferred
get-response ( )
• Data of ram one waysend-one way ( )
• Dyn. Invocation Interfaces – four Interfaces:
• CORBA : : object – pseudo object interface that
defines opens that every CORBA object must
support.
Lecture 8 slide 2
Dynamic CORBA
•
•
•
•
•
•
•
•
•
•
Methods: get-intefaces; create-request; - request.
CORBA::Report ;- pseudo object interface that defines the operation on a
remote object.
Method ; add-ary, invoke, send-oneway, send-defered, get response,
pill.response, delete, add-item, add-value, get-count, remove, free, freememory.
CORBA::ORB: Gen. purpose ORB methods – create-list, create - operationlist, send – multiple-request-one-way, send-multiple-requests-defered, pillnext-response, get -next-response
CORBA ::NVList: To help constant parameters – NV List object – maintains
a list of self describing data items called Namedvalues.
IDL- Street-Namedvalue
{
Identifier name; // my name any argument;//argument long len;//length/count
of my value flys-modes//in,int, or inout
Dynamic Invocation Scenarios:
So it Yourself :
Lecture 8 slide 3
Dynamic CORBA
• Client
–
–
–
–
–
–
–
–
–
–
Object
Operationdef.
get.interface ( )
look up name
describe
create – list
add – item
create – request
Invoke
delete
free
a variation of first method
Lecture 8 slide 4
Interfaces def.
ORB
Dynamic CORBA
• The ORB-Can-Help scenario:
• Client
Object
Interfaces def.
Operationdef.
ORB
• In place of steps 3,4, and 5 above issue
• 1 & 2 same as above
• 3. create – operation list
• 4. add-value
• 5. Create-request
• 6. invoke
• 7. delete
• 8. free
• Dyn. Invocation – the yet – another-way scenario:
Lecture 8 slide 5
Dynamic CORBA
– in stead of adding your arguments to an NVList, you add them to the
request object.
• The Dynamic Count:
• Count server class, as is; so the IDL remains unchanged.
• No stubs for a dynamic client, however a mixed client is created that does
both static and dynamic invocations. Count cliendDii.Java
• Test Results:
• Local Dyn. Count ping
Remote Dyn.Count ping
• Invokenly
3.9msec
3.6msec
• Prepared invoke
61.4 msec
57.8 msec
• Note: Choices of method invocation:
– Static precompiled stubs
– Dynamic invocations using DII.
– Downloadabale stubs – Java – download both client & stubs, (applet).
Lecture 9 slide 1
Dynamic CORBA
• When to use what
• Usage Pattern
Recommendation
• 1. Client – Server frequent;
use static
precompiled stubs
•
Server obj.doesn’t chage
• 2. Client – server ingrequent
use DII
• 3. client – server object runtime
use DII
• 4. Client runs with in browser; use downloadable applet
and static
•
if discovers new object
stubs. Applet
becomes the client for this object.
Lecture 9 slide 2
Dynamic CORBA
Multi – Count
• Multi client – multiple clients, call backs,;
reversely C&S roles.
• VisiBroken for Java CORBA ORB is both a
C&S
• Multi Threaded client – client using Java’s
threads
• Coordinator – a new server – uses callbacks to
remotetly control clients.
• Applet as a front-end to the coordinator –
called multi console.
Lecture 9 slide 3
Dynamic CORBA
• The Multi count CORBA interfaces:
– Client control interface – client call back
• Methods – start, stop
– Coordinator interface - server
• Methods – start, stop, register
– count interface - server
• method – increment
• A Multi count callback Scenario
Lecture 9 slide 4