This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Server UI 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 "Server UI" Watch "Server UI" New topic
Author

Server UI

Ixus See
Ranch Hand

Joined: Jul 17, 2011
Posts: 160
What did you guys implement for your server UI?

I provide a UI with

database location, magic cookie and port No.

the user can click start and it will validate all the fields and start the RMI server.

is pretty simple actually.

Should I provide the IP address of the server after clicking starting RMI server?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5300
    
  13

I provided database location, port number, start and stop buttons. Nothing more, nothing less.


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

Joined: Sep 10, 2010
Posts: 101

Three labels
1. SERVER RUNNING...
2. LISTENING ON PORT: XXXXX
3. DATABASE LOCATION: \XXXXX\XXXXX\XXXXX\xxxxx.db

Then I added a QUIT button below it.
Simple and pretty.


OCPJP 6, OCMJD 6
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5300
    
  13

Oladeji Oluwasayo wrote:Three labels
1. SERVER RUNNING...
2. LISTENING ON PORT: XXXXX
3. DATABASE LOCATION: \XXXXX\XXXXX\XXXXX\xxxxx.db

If you are showing just 3 labels containing the port and database file location, how can I (as a user) change the location of the database file? Seems a weird Server UI to me...
Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

Mine starts with a dialogue box allowing the user to choose a file and network port. After confirming these settings it just shows the network port and a file/exit option. I tried to have a start and stop but had problems with stopping and starting the rmi server. I took the easier option and got rid of them


SCJA, OCPJP, OCMJD
Ixus See
Ranch Hand

Joined: Jul 17, 2011
Posts: 160
Can I assume on exit you just do system.exit(0) ?

will the RMI server stop? Will I have problem restarting the RMI server there after?

Will that affect anything?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5300
    
  13

These are things you can easily find out yourself.
Oladeji Oluwasayo
Ranch Hand

Joined: Sep 10, 2010
Posts: 101

Roel De Nijs wrote:
Oladeji Oluwasayo wrote:Three labels
1. SERVER RUNNING...
2. LISTENING ON PORT: XXXXX
3. DATABASE LOCATION: \XXXXX\XXXXX\XXXXX\xxxxx.db

If you are showing just 3 labels containing the port and database file location, how can I (as a user) change the location of the database file? Seems a weird Server UI to me...


Oh Roel, I provided a configuration dialog (a configuration dialog reused by the client and stand-alone modes too) prior to displaying the main window for the server. It has a field for entering the database location, a "browse" button, a field for specifying the server port, labels for the text fields, start and cancel buttons. After clicking start, the dialog disappears and the window i described earlier is displayed.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5300
    
  13

That's also a commonly used approach. But now it makes more sense than just a window with 3 labels
Ixus See
Ranch Hand

Joined: Jul 17, 2011
Posts: 160
I notice the RMI codes are less than 10 lines(both server and client) add together...

registry
rebind
lookup

basically is these 3 api calls, did i miss out anything important?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5300
    
  13

Ixus See wrote:basically is these 3 api calls, did i miss out anything important?

Does it work?
  • Yes, then you didn't miss anything important.
  • No, then you did miss something.
  • Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    Roel De Nijs wrote:
    Ixus See wrote:basically is these 3 api calls, did i miss out anything important?

    Does it work?
  • Yes, then you didn't miss anything important.
  • No, then you did miss something.


  • it works.. but just a bit worried when things requires little effort =X

    I guess i am pessimistic :P

    Thank you once again

    I have some problem with naming convention

    I name the class accessing Data.java as RoomDAOImpl (implements roomdao

    and the class to locate/create roomDao as service factory

    basically I use it to register in RMI.. I got a feeling they should be call RoomService and Service Locator
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5300
        
      13

    Ixus See wrote:I got a feeling they should be call RoomService and Service Locator

    I think the class accessing the Data class should indeed be renamed to RoomService, because your Data class is actually the RoomDaoImpl.
    Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    Roel De Nijs wrote:
    Ixus See wrote:I got a feeling they should be call RoomService and Service Locator

    I think the class accessing the Data class should indeed be renamed to RoomService, because your Data class is actually the RoomDaoImpl.


    That was my initial idea.. but somehow I feel data should be like your database methods which you call to access data...

    and there is another layer call DAO.. maybe is just me, I strongly opposite calling DATA.java as a dao because to me is a lousy database sequel layer(can't remember the word for it) , which one day I am going to replace with SQL database and then I will use my RoomDAO to access it~

    anyway I already refactor it~

    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5300
        
      13

    In a DAO interface you'll have some CRUD-methods, probably also one for searching records. The only methods you won't have in the DAO would be lock, unlock and isLocked. But to me your Data class is accessing the data, so it's a DAO and it's accessing the data from the file system. So Data is an implementation for accessing the data from the file system. Another implementation of the DAO could be a RoomDAO which access the data from a RDBMS.
    Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    Ixus See wrote:I notice the RMI codes are less than 10 lines(both server and client) add together...

    registry
    rebind
    lookup

    basically is these 3 api calls, did i miss out anything important?


    hmm anyone use RMI here? What did you implement beside just registry -rebind for server and look up for client...

    how do you guys validate RMI port?

    is really too little work for 40 marks
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5300
        
      13

    You also have your server implementation of course that's part of the Server section
    Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    Roel De Nijs wrote:You also have your server implementation of course that's part of the Server section


    heehee of cos I have that..

    anyway is there a range of ports no. for RMI?



    why does the interface DB and data.java mention under the section of server?

    I use room service as the remote object, not data.

    am I doing something wrongly?
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5300
        
      13

    Ixus See wrote:why does the interface DB and data.java mention under the section of server?

    Maybe because it always runs on the server (unless in standalone mode of course)

    Ixus See wrote:am I doing something wrongly?

    Have a look here.
    Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    I'm still a bit blur...

    lets say I have IRoomService and RoomService(implements RoomService)

    and in my room service, I have find, get, update and delete..(the locking/unlocking is done in the update and delete).


    1) I can assume that the locking is done on the server side? since my remote client only calls the remote object? will I be penalize for that? I read someone lost 36 marks because of that.

    2) I also do the filtering of result in the find method, I am thinking of moving it to the model that calls the roomservice. but that would incur cost since each find method needs to go through network again rather than performing the operation on server side.
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5300
        
      13

    Ixus See wrote:1) I can assume that the locking is done on the server side? since my remote client only calls the remote object? will I be penalize for that? I read someone lost 36 marks because of that.

    Sounds weird to me. Maybe his design/code had some flaws/bugs. I 've done exactly the same and was not penalized at all.

    Ixus See wrote:2) I also do the filtering of result in the find method, I am thinking of moving it to the model that calls the roomservice. but that would incur cost since each find method needs to go through network again rather than performing the operation on server side.

    What's your motivation for moving filtering results to the model instead of doing it in the service method itself?
    Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    Roel De Nijs wrote:What's your motivation for moving filtering results to the model instead of doing it in the service method itself?


    because I feel the filtering is a business logic and the service should focus on doing its job(communicating with data.java). but anyway I think i will put it on the server, because it will reduce over head cost of performing the operation and if there is a change in business logic, the client doesn't need to change and all I need is to update the service/server
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5300
        
      13

    Ixus See wrote:the service should focus on doing its job(communicating with data.java)

    So you are developing a fat/thick client and the service does not expose business methods (like bookRoom), but similar methods like in the Data class (find, read, update, lock, unlock,...)
    Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    Roel De Nijs wrote:
    Ixus See wrote:the service should focus on doing its job(communicating with data.java)

    So you are developing a fat/thick client and the service does not expose business methods (like bookRoom), but similar methods like in the Data class (find, read, update, lock, unlock,...)


    well it seems that i shifted to a thin client.

    and my services expose only bookRoom and deleteRoom and find room.

    why bookroom? it is because after obtaining the lock. the service have to check if the room has been book(CustomerID.isEmpty) before updating it.

    find room will package the result into a vector of rooms which matches the UI search requirement.

    deleteRoom juz do deletion ;) *not a requirement* I just want to prove that the JTable only shows valid records without the examiner looking at the codes.

    Helping your marker helps you to score some points too
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5300
        
      13

    Ixus See wrote:well it seems that i shifted to a thin client.

    So you answered the question about the appropriate location to add the logic to filter records yourself.
    Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    Roel De Nijs wrote:
    Ixus See wrote:well it seems that i shifted to a thin client.

    So you answered the question about the appropriate location to add the logic to filter records yourself.


    I did but I want 2nd opinions and maybe things i miss out. I always believe a 3rd person view is the clearest ;)

    Thats why my encourage my colleagues, if you can't solve a problem in 1 hour please SEEK FOR HELP, because a 3rd person view will help a lot and you won't be wasting man hours. Maybe I strongly believe that a lot of problems my colleagues face are already solved in design patterns and no point re-inventing the wheel. I also encourage more communication and healthy debates, which is what I hope to see.

    Don't you feel a lot of software engineers are very "closed"? They don't take much especially regarding their design as holy book that cannot be disputed. Anyway is just my way of encouraging more sharing, caring and learning in the work place.

    How about you, Roel De Nijis? how do you encourage your colleagues to share and talk about their work and problems?

    Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    heehee of cos I have that..

    anyway is there a range of ports no. for RMI?
    Chris Zaremba
    Ranch Hand

    Joined: Nov 22, 2010
    Posts: 54

    See RMI Port Number
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5300
        
      13

    Ixus See wrote:anyway is there a range of ports no. for RMI?

    ShowSomeEffort
    Ixus See
    Ranch Hand

    Joined: Jul 17, 2011
    Posts: 160
    Chris Zaremba wrote:See RMI Port Number


    yes obviously I know the default number is 1099, but that doesn't mean the user will only choose 1099 or maybe his port is block.. I allow the user to set a different number.

    Now the problem is to validate if it is a valid port no.

    I check if it is digit. . but what about the range of valid numbers?
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5300
        
      13

    Ixus See wrote:what about the range of valid numbers?

    I was able to find the answer using the search engine of this forum. So I would suggest giving that a try. Don't be afraid: it won't hurt you
     
    GeeCON Prague 2014
     
    subject: Server UI