aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Standalone Client & Socket client SCJD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Standalone Client & Socket client SCJD" Watch "Standalone Client & Socket client SCJD" New topic
Author

Standalone Client & Socket client SCJD

John Oconnor
Ranch Hand

Joined: Jan 12, 2011
Posts: 66

Hi for all!

I am working in the SCJD, URLyBirds, and i have choice the socket solution for comunication.
My server work fine, I can stand up many clients via sockets, and manage the registry system lock.
I have used for registry lock a HashTable, where know the registry number lock at moment and your self cookie lock.

Now, my problem is when I try run a client local, standalone client, the local client can`t see the table where are the locks for remote clients, (sockets solutions)


Q1: when sun (oracle now ) say for local client : " the networking must be bypassed entirely." so i cant create a new client via socket where the ip =localhost?
as Jboss made? (the socket solution is a mini-server finally, so i could connect locally via localhost if server ip is equals to client ip or not is apropiate solution?)

Q2: RMI is best solution for this problem? any help?

Thanks, and I sorry my level of English but my first lenguage is the Spanish , and I not use Google traductor, any times is dangerous


SCJP 5 - OCMJD 6 - OCPJME1MAD(SCMAD)
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5408
    
  13

Hi John,

1/ You are not supposed to run a standalone client together with a network server. So if you run your standalone client you'll need to bypass the network code, and that's it. You are guaranteed that no other program will be using the database file, so the network server can NOT be running (your instructions clearly state: "You may assume that at any moment, at most one program is accessing the database file;")

2/ RMI or sockets: that's completely up to you. Make your choice and document this decision in choices.txt

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
John Oconnor
Ranch Hand

Joined: Jan 12, 2011
Posts: 66

Ok Roel, I undertand the diference between remote and socket, my Question 1 is only bad idea.

Well, i have for remote solution the next structure (in general view):

gui - controller - remote conector - socket client - socket server - databasefileaccess - database file

and for local :

gui - controller - local conector - database file access - database file

I have a Hashtable in my database file access who work is only know who are lock any register (room in database).
When run my clien in remote mode , is fine, because i am manage every client via my server , because I use the some database file acces (final and static class)
But, when run the local client, this manage another instance for database file access (also final and static, obvious jeje), some how I will do for manage the some instance for local and remote, is this posible?, or I need a new manner for manage this problem?

Tnks!
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5408
    
  13

Hi John,

I have just one Data class which is used in network and standalone mode. I don't think you want to develop a complete new Data class just for the standalone mode. Because it will have a lot of code duplication (and that's a bad idea, as you know)

Kind regards,
Roel
John Oconnor
Ranch Hand

Joined: Jan 12, 2011
Posts: 66

Roel, my database file access is the some class , for local and remote!!. I will be very dumb if create 2 diferents database file access.
The next is the correct view of my solution to urlYBird proyect

--------------------../-- local conector ------ \
------------------- /------------------------------\
gui -controller-< .-------------------------------.>---db file access-dbfile
------------------.\ -----------------------------/
--------------------.\ remote conector-socket /

Ok now?, sorry but my previus reply not is very clear.

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5408
    
  13

Much better
 
Don't get me started about those stupid light bulbs.
 
subject: Standalone Client & Socket client SCJD