• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

RMI factory pattern - Where will the Database file be?

 
Greenhorn
Posts: 25
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm trying to apply the Factory Pattern to the RMI but is seams that by doing it the getClient() brings a RMIServerImpl to the client. Which seams to be making the database file to be also managed by the client.

What am i doing wrong?
Can this design pattern be implemented in this case, where a file in the server is to be handled?

My design was based on:
http://www.itec.uni-klu.ac.at/~harald/ds2001/rmi/factory/factory2.html
 
Ranch Hand
Posts: 85
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The RMI creates a skeleton and a stub. RMIImpl would be on the server the client would just have a shadow of it. So factory pattern works alright.
 
Joel Mata
Greenhorn
Posts: 25
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rehan Zahoor wrote:The RMI creates a skeleton and a stub. RMIImpl would be on the server the client would just have a shadow of it. So factory pattern works alright.


I undestand, but then
in this context the database is not shared among other clients, is this acceptable?
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Joel Mata wrote:is this acceptable?


Of course! That's what RMI is all about.

And if you think about it? If the database is shared among the clients, what would happen with the database file? This file only exists server side...
 
Joel Mata
Greenhorn
Posts: 25
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Roel De Nijs wrote:

Joel Mata wrote:is this acceptable?


Of course! That's what RMI is all about.

And if you think about it? If the database is shared among the clients, what would happen with the database file? This file only exists server side...



Hi Roel, could you explain yourself again?
I understand RMI but with the RMI factory design pattern the remote call brings all server implementation and then it opens the file on the client. The idea of having multiple clients where each one has his own database file seams odd to me.

I was more expecting having the client calling methods locally but being run on the server, that is that all clients would share the same database file.
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can a file be opened on the client if this fily is physically residing on the server
 
Joel Mata
Greenhorn
Posts: 25
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Roel De Nijs wrote:How can a file be opened on the client if this fily is physically residing on the server



yes, thats my problem :S. The factory is returning the RMIServerImpl which then creates a DB on the client. If i disconnect the server the client keeps working.

What data could i provide to help you guys to track what am i doing wrong?
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a RMI factory I would expect something like:


On the server you'll (re)bind an instance of your factory to the registry:


And on the client you'll do something like to retrieve a client to call the methods on:


If you have a similar setup, I think you implemented the RMI Factory Pattern correctly.

Disclaimer: I created these code snippets without an IDE, so there might be a few typos.
 
Joel Mata
Greenhorn
Posts: 25
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Roel De Nijs wrote:With a RMI factory I would expect something like:



HI Roel. The problem was that my RMIServerImpl was not extending UnicastRemoteObject, instead was implementing Serializable.
Solved! Thanks.
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to hear I was able to help!
    Bookmark Topic Watch Topic
  • New Topic