File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI factory pattern - Where will the Database file be?

 
Joel Mata
Greenhorn
Posts: 25
Java Oracle Spring
  • 0
  • 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
 
Rehan Zahoor
Ranch Hand
Posts: 80
Android Java Netbeans IDE
  • 0
  • 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
Java Oracle Spring
  • 0
  • 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?
 
Roel De Nijs
Sheriff
Posts: 9167
76
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • 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
Java Oracle Spring
  • 0
  • 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: 9167
76
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • 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
Java Oracle Spring
  • 0
  • 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: 9167
76
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 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
Java Oracle Spring
  • 0
  • 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: 9167
76
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to hear I was able to help!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic