• Post Reply Bookmark Topic Watch Topic
  • New Topic

[NX] Adapter problem  RSS feed

 
George Fung
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all
My project is about contrator. I will use RMI. I found that some ppl suggest we should use connection factory and adapter design. I have some questiosn about them:
1. How to relate connection factory with RMI?
2. I have read some articles in javaworld on adapter. Here's my implementation. Please comment.
In adapter class:
If it's network mode, it will lookup registry and find out remote reference. Then, it will call the service
It it's "non-network" or alone mode, it will access the Data class file to acess Db directly. THere is no "remote" coding invloved. Is it okay?
So, there are 2 java instance (one is server, one is client) if we use network. If user choose "non-network" mode, there is only one java instance to access Db.
Plz give me comment.
Rgds,
George
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12101
246
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George,
Many people (especially those doing the old Fly By Night Services assignment) have written RMI applications where a new instance of the remote object is created for each connected client. Each client would call a factory method to get the new instance.
You may not need to do this for your assignment - it is up to you.
Your adapter class looks OK to me.
Regards, Andrew
 
George Fung
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In create instance of remote object, do it mean that we lookup the registry and get the reference?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12101
246
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George,
No, each client got a reference to an instance of the remote object that was unique to that client. If I had five clients connected to my server, then on the server I would have had five instances of remote class that was servicing the client.
Regards, Andrew
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!