aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes need comments on network/non-network mode 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 "need comments on network/non-network mode" Watch "need comments on network/non-network mode" New topic
Author

need comments on network/non-network mode

Ben Zung
Ranch Hand

Joined: Mar 25, 2004
Posts: 109
Hello, everyone.
I need comments on when not using the network mode. I have the remote interface ContractorService which provides services to client requests. It has Data as a membe object. The Data is shared by all clients requests, and it serves as the engine[read/write/create/delete] to the database, and it is created when the service implementation object is created.
The ClientUI, keep a reference of the ContractorInterface, upon start up check the mode, assume "server" at this point, and make the connection. It is working, and nicely so far.
then my concern rises when start to think about alone mode. I thought of
doing it by sticking with the ContractorService and create ContractorServiceImp object which will create a Data object accessing a local database file.
Some manipulation may be needed in Data object this way. But will this violate the requiements simply because that the ContractorService being a subinterface of Remote and, I have DatabaseSchema object which implements Serilizable, would this be considered to a violation too?
The program must be able to work in a non-networked mode. In this mode, the database and GUI must run in the same VM and must perform no networking, must not use loopback networking, and must not involve the serialization of any objects when communicating between the GUI and database elements.


To make my question clearer, here is what I meant:

This way, the rest of the ClientUI would not have to care about whether it is a network or local database being processed.

And right next to the above requirment is the following and look at this I would think that my approach above violate it. And I don't understand what it means by saying Architecturally, this mode must use the database and GUI from the networked form:
The operating mode is selected using the single command line argument that is permitted. Architecturally, this mode must use the database and GUI from the networked form, but must not use the network server code at all.

Thanks for you patience. It Ihave exposed too much, please advise me to get rid of some.
Bing
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Actually you are pretty right on the mark. The whole thing for the GUI is to use an interface instead of a concrete class, that way the GUI doesn't know that it is in Local or Remote mode, it doesn't care.
Now the only thing I would change for you, is to move the "IF" code from the GUI into a Factory class, and move the ContractorService reference to the Controller. I had the main class call the Factory getting the Data access and passing its reference and a reference to the GUI to the Controller. The GUI should only display the screen it should not have any business references or code.
Good Luck
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ben Zung
Ranch Hand

Joined: Mar 25, 2004
Posts: 109
Thanks Mark, for the comments/suggestions. Factory/Controller sounds like a far better practice.
Then what about the requiements? When initialize a ContractorService during alone mode, is ContractorService considered to be network server code? I am using some serilazed object(databaseschema), is this violate must not use loopback networking, and must not involve the serialization of any objects when communicating between the GUI and database elements.?
Thanks.
bing
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Well, I had my interface that both the local and remote implemented. This interface extended Remote, but threw the generic Exception. In the implementing classes, I made the Exceptions to be more specific. So the Remote could throw a RemoteException and it was legal.
So you ContractorService can extend Remote. Then you will have two classes that implement this interface. Maybe called ContractorServiceLocal, and ContractorServiceRemote.
I had DataInfo and FieldInfo both implement Serializable. Now a note, I had the older assignment, but this type of class is still fine to be Serializable, even though in local mode, it actually won't ever be Serialized or sent over RMI or a Socket.
Hope that helps.
Mark
Ben Zung
Ranch Hand

Joined: Mar 25, 2004
Posts: 109
Thanks Mark.
But somehow I am not that convinced.
Your interface implementation has both local and remote one, but the interface itself extends Remote. As further as I can understand, it is still using network server code -- referring to the Remote interface. Or network server code does not include Remote at all?
I am thinking if there is another way around. Meanwhile I am going to start a new topic asking for help to understand these requiements. Hope you dont mind.
Thanks.
Bing
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

You can create an interface that does not extend Reomte, and then create one more that does. But I think the one interface alone is enough to keep network and non-network mode out of the logic for the client.
Plus I got perfect in this area.
Starting a new thread is fine.
Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need comments on network/non-network mode