Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why have an interface DvdDatabaseRemote

 
Cory Max
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All, I'm following the monkhouse/cam book and looking at their RMI implementation example. Why would we declare

then implement that single interface in our DvdDatabaseImpl class

Instead of just


Im sure there is a good reason, just don't know what it is.

Thanks,

Yeuker
 
Roel De Nijs
Sheriff
Posts: 10387
132
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cory,

Did you try for yourself if your suggestions would compile and run successfully? I did when I was developing my assignment, and I posted my results in this topic.

Kind regards,
Roel
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I think they just wanted the code to be more readable...
 
Roel De Nijs
Sheriff
Posts: 10387
132
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberto Perillo wrote:Well, I think they just wanted the code to be more readable...

I don't think it has anything to do with readability. But with being able to run your code

Have a look at following code:

Running the server and then the client, results in "Hello Roel" being printed to the console.

When I change the server's code to:

Running the server and then the client, results in a runtime exception:
Exception in thread "main" java.lang.ClassCastException: $Proxy0 cannot be cast to HelloService
at HelloServiceClient.main(HelloServiceClient.java:10)


Kind regards,
Roel
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh! At a first glance, I thought this was going to work normally. Living and learning
 
Cory Max
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the replies. Very helpful.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic