{"id":848,"date":"2010-04-08T11:33:51","date_gmt":"2010-04-08T10:33:51","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=848"},"modified":"2010-04-08T11:33:51","modified_gmt":"2010-04-08T10:33:51","slug":"rmi-interface","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2010\/04\/08\/rmi-interface\/","title":{"rendered":"RMI &#8211; interface"},"content":{"rendered":"<p>Sometimes you will want to call a remote server e.g. like in a library, and see if a book has been taken out or not.  Well in Java you can use something that is called a <a href=\"http:\/\/java.sun.com\/javase\/technologies\/core\/basic\/rmi\/index.jsp\">Remote Method Invocation<\/a> ( it is very similar to web services ) this allows for a server to respond to clients without sending any more data across than what is required.<\/p>\n<p>In this part of the tutorial I am building up the interface which the Client can use because the server will be implementing the functions below, but the Client only needs to know what functions have been implemented.<\/p>\n<pre lang=\"java\">\r\nimport java.rmi.*;\r\nimport java.util.*;\r\n\r\n\/\/ this is used by the RMIClient.java to communicate with the remote server\r\n\/\/ the Book.java uses this to implement a Book\r\n\r\n\/\/ a remote interface java.rmi.Remote \r\npublic interface Borrowable extends Remote {\r\n\t\/\/ all interface functions must throw RemoteException\r\n\t\/\/ is the booked checked out\r\n\tpublic boolean isCheckedOut() throws RemoteException;\r\n\t\/\/ return the library card number\r\n\tpublic String checkedOutCardNumber() throws RemoteException;\r\n\t\/\/ check out the book\r\n\tpublic boolean checkOut(String cardNumber, Date d) throws RemoteException;\r\n\t\/\/ check back in the book\r\n\tpublic boolean checkIn(String cardNumber, Date d) throws RemoteException;\r\n}\r\n<\/pre>\n<p>so if you save that as the Borrowable.java file.<\/p>\n<p>Next I am going to do the Book.java file, which is what the server will use as the library book as such.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you will want to call a remote server e.g. like in a library, and see if a book has been taken out or not. Well in Java you can use something that is called a Remote Method Invocation ( it is very similar to web services ) this allows for a server to respond &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2010\/04\/08\/rmi-interface\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">RMI &#8211; interface<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-848","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=848"}],"version-history":[{"count":1,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/848\/revisions"}],"predecessor-version":[{"id":849,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/848\/revisions\/849"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}