Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

my plans for RMI interface

 
Guillaume Jeudy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'd like to know how other SCJD'ers have tackled the RMI interface issue. It does seem to me that even though you want to depend on RMI specific code as little as possible in non-networked mode you are still stuck in at least adding the RemoteException in the local interface signature.

Here's what I plan to do:



Have others find a better way of working around this problem?

I noticed Andrew's local interface have IOExceptions and the remote interface have RemoteException which extends IOException so the code compiles. I don't really like this approach, I'm doing a 3-tiered app and only expose the service interface through RMI. I'd hate to have the service layer throw IOExceptions which may hint at the underlying service implementation (which is using a flat db file)... However I may end up with this solution so that the non-networked code is totally clean of RMI dependencies.

Cheers,
-Guillaume
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guillaume,

I applied the same approach as you.

If you really want to get rid of the RMI dependencies for your non-networked mode, you could create another service (used for your local implementation):



In my opinion this is more desirable than the IOException thing from Andrew's book. But it is certainly not needed to pass

Kind regards,
Roel
 
Guillaume Jeudy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roer,

By the way thanks for all the useful info you posted on this forum to date. The information has been invaluable to me since I started working on this assignment.

If I were to implement a separate local interface like you suggested wouldn't that force me to code to 2 differents interfaces on the client side? The remote one and the local one ? If thats the case I will avoid that and implement my initial plan.

Or maybe you have FooService declare the methods with throws Exception, FooServiceLocal redeclare the methods with throws FooServiceExcepton, FooServiceRemote redeclare the methods with throws RemoteException ? That sounds like an anti-pattern to me, a method with a throws Exception declaration is a big warning sign to me.

Regards,
-Guillaume
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guillaume,

If you add both code segments together you'll get:

You will have 2 service implementations (as you can see): one for local and one for network. And in your client you can program just against the FooService without any problem, because both the local and remote interface extend FooService. Code example:

But like I said I did it just like in your first post and the code in my client is the same as this example code. By creating the extra local interface you have removed the RemoteException from every method's signature. I don't think creating that extra interface for this reason only has any added value (that's why I didn't create it )

Kind regards,
Roel
 
Fernando Franzini
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding in what Roel wrote. You dont need reeimplement Local and Remote services. As I did.....I implemented ServiceLocalImp class that I used to local acess and encapsulated it inside ServiceLocalImp that delegate to local object.
Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic