Ok Ok. If you like at my favourite books on the right, it does seem like a brand of books, started by Cathy Sierra, make up the majority of my book shelf.
Now I must start off by saying that I have not and will most not ever receive payment for this. It is actually because reading the Head First Java book brought me up to speed on Java in only four weeks, when others will still learning the basics (and still are) after three months.
The second, Servlets and JSPS, brought my 92% in a class test, and the third, HTML and CSS, gave me the skills to write a well structured, strict compliant, good looking website that meet usability guidelines (oh and the client liked it also).
The books quiet simply break the mould for technical manuals, though strictly speaking they are not manuals, but learning materials that life long teachers probably never manage to produce. So say what you will about my shameless plug for the Head First range, but they've brought me far and will do so for others who can't be bothered to wade through 500 pages of sleep inducing size 8 writing.
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Friday, 27 April 2007
Thursday, 26 April 2007
Remote Method Invocation has Landed!
I have finally nailed (ok not not nailed, but more pinned down with a sturdy pin) Remote Method Invocation(RMI)
RMI
Unfortunatelly, the RMI lecture came straight after a class test and was thus promptly slept through by most students. Going back over the lecture slides, which are not meant to be read but worked through in class, were not much help. After much confusion, trying to work it out, going back to the Head First
Java book I finally tried the java website, and hey presto, found exactly what was needed, a tutorial
by jGuru.
To summorise how neat and simple RMI is (for the simple stuff anyway!)
The remote object you want to be available to a different JVM must implement an interface.
That interface:
The remote object:
Now getting that remote object "out there", which will be done by a server object, is so fantastically easy, once you see it in practise.
The server object:
The client, or the listener which wants to use the remote object as if it were on its heap:
Of course this won't make much sense without looking at some actuall examples, but it
is so straightforward that, like a lecturer said, you could put this all on a post stamp!
RMI
Unfortunatelly, the RMI lecture came straight after a class test and was thus promptly slept through by most students. Going back over the lecture slides, which are not meant to be read but worked through in class, were not much help. After much confusion, trying to work it out, going back to the Head First
Java book I finally tried the java website, and hey presto, found exactly what was needed, a tutorial
by jGuru.
To summorise how neat and simple RMI is (for the simple stuff anyway!)
The remote object you want to be available to a different JVM must implement an interface.
That interface:
- is public
- implements Remote
- each method signature defined must throw a RemoteException
- and for programming ease import java.rmi.*;
The remote object:
- again be public
- implement the interface above and extend UnicastRemoteObject
- supply a no arg constructor which throws RemoteObject and calls super()
- implement all the methods defined in the interface it is implementing
Now getting that remote object "out there", which will be done by a server object, is so fantastically easy, once you see it in practise.
The server object:
- does not implement or extend anything
- places all the work in try/catch statements
- imports java.rmi.*;
- makes an instance of the remote object to be made available to the world
- declares it to the world by doing such: Naming.rebing("rmi://hostname:port/madeupname", RemoteObject Instance);
- has a main method for starting the server
The client, or the listener which wants to use the remote object as if it were on its heap:
- Gets a copy of the class for the object it will use as a stub/ if one is not on that system
- RemoteObject r = (RemoteObject)Naming.lookup("URL same as above/madeupname");
- you can then use r as if it were on your system!
Of course this won't make much sense without looking at some actuall examples, but it
is so straightforward that, like a lecturer said, you could put this all on a post stamp!
Subscribe to:
Posts (Atom)