aspose file tools*
The moose likes Distributed Java and the fly likes How to make clients receive updates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "How to make clients receive updates" Watch "How to make clients receive updates" New topic
Author

How to make clients receive updates

Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
Hi,


How to make clients receive updates automatically. The clients will be Swing desktop clients and the application will be a rmi application on the server accessible via net. there is no issue of firewall :0

Thanks,

Maki Jav


Help gets you when you need it!
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
I think that something like Observer/observed ie Observer pattern pattern will be used?

Thank you,

Maki Jav
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
There are lots of ways for a client application to register with a server to receive messages. Java Message Service, JavaSpaces, even email. In Java one of the easiest approaches would be to use a HTTPserver and have the clients periodically query it for new data.

How big is a data update?
Can updates be plain text? XML? Some other file format?
Whats the maximum acceptable delay between an update being made available and all clients having the data?

Bill
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
Thank you William Brogden for responding me. I am interested in RMI solution. The data will not be big.

I have made a observer/Observable paradigm classes. The idea is that I have a observable object which will keep on running on the server and I have various Observer instances. Any change in the Observable is notified to the Observers over rmi. I have compiled these classes using JDK1.4.


RemoteObservable.java
RemoteObservableImpl.java
RemoteObserver.java
RemoteObserverImpl.java

And after that I compiled them using:
rmic -d . RemoteObservable RemoteObservableImpl RemoteObserver RemoteObserverImpl

The package is adil.

Q. 1) Why am I getting RemoteObservableImpl_Skel.class and RemoteObserverImpl_Skel.class in addtion to RemoteObservableImpl_Stub.class and RemoteObserverImpl_Stub.class? I heard that newer compilers do not create skelton classes.

After starting rmiregistry I run RemoteObservableImpl using the following

java -Djava.security.policy=./java.policy adil.RemoteObservableImpl

Now the test in which I am getting problem.

The tester class is

class Tester.java



I am using this command:
java -classpath adil;. Tester


java.lang.ClassCastException: adil.RemoteObservableImpl_Stub
at Tester.main(Tester.java:25)

Q. 2) I am getting the above exception. Why am I getting a stub instead of RemoteObservableImpl Object from rmiregistry? And how to deal with it? How to use it?


Thank you,

Maki Jav

ps: William Brogden i have your book too.
[ December 30, 2007: Message edited by: Maki Jav ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Alas, I can not help with those questions:

1. It has been a long time since I used RMI
2. I no longer have a JDK 1.4 anywhere, all my systems have Java 1.6 as the normal Java.

Maybe it is time for you to update to 1.6 also.

Bill
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
I am successful in implementing Observer/Observable pattern atlast. it was a long standing desire!

I used three clients to test it from three different folders. The first client reflected it when
the second client logged on; the fist and second clients reflected it when the third client
logged on. The first client showed 3 messages, the second shwoed 2 and the last showed 1 message.


First client window
RemoteObservableImpl_Stub[RemoteStub [ref: [endpoint:[127.0.0.1:1045](remote),ob
jID:[e53108:117309386e9:-8000, 0]]]]
HELLO 1
RemoteObservableImpl_Stub[RemoteStub [ref: [endpoint:[127.0.0.1:1045](remote),ob
jID:[e53108:117309386e9:-8000, 0]]]]
HELLO 2
RemoteObservableImpl_Stub[RemoteStub [ref: [endpoint:[127.0.0.1:1045](remote),ob
jID:[e53108:117309386e9:-8000, 0]]]]
HELLO 3



Second client window
RemoteObservableImpl_Stub[RemoteStub [ref: [endpoint:[127.0.0.1:1045](remote),ob
jID:[e53108:117309386e9:-8000, 0]]]]
HELLO 2
RemoteObservableImpl_Stub[RemoteStub [ref: [endpoint:[127.0.0.1:1045](remote),ob
jID:[e53108:117309386e9:-8000, 0]]]]
HELLO 3



Third client window
RemoteObservableImpl_Stub[RemoteStub [ref: [endpoint:[127.0.0.1:1045](remote),ob
jID:[e53108:117309386e9:-8000, 0]]]]
HELLO 3

I was getting java.net.Connection Exception earlier in RemoteObservableImpl but then I turned
off the computer and now I am not getting any such exception.

So now the bare bones application is ready on which any command promt, Swing-based or other applications
can be built.

I now want to have help from you guys in improving this code. Maybe I am making some mistake/logical
error somewhere in my classes.

Tester code is above.

It needs correction:

Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
Hi,

I have been able to run rmiregistry and bind remote object locally and access that object via a Servlet from my account at myjavaserver.com
 
 
subject: How to make clients receive updates