Java – Designing an API on top with Java RMI and Rest APIs

apidesignjavarest

I'm working on the backend of a java web application. We have a document repository (Fedora Commons specifically) where we house xml files. I want to abstract the API of the repository internally so that we aren't tightly coupled to one product. I'd also like to give the flexibility of connecting to to a repository via Java RMI or REST APIs. I was hoping to get advice or resources on how to implement something like this.

My thought it that I'd have some abstract repository class that had methods like getRecord, updateRecord, and deleteRecord. In the constructor I would pass the URI for the repository and the API method and port. This would allow some flexibility in the future so that if the REST api became more practical, but allow the flexibility or using RMI which could (should?) have better performance.

Am I over thinking this or am I on the right path?

Best Answer

Take this advice for what it is worth, but I strongly urge you to reconsider the use of REST API instead of Java RMI.

Without having solid metrics to compare, I would highly suspect that performance between Java RMI and REST would be similar.

  • Java RMI is an older technology which is not as widely adopted.

  • More Java developers likely have experience with REST and web services versus RMI.

  • Clients of your server are tied to Java technology (think expansion to mobile clients for instance)

  • Security concerns

These are just a handful of the issues with it. Beyond that, having to debug poorly written legacy RMI applications was a horrifying ordeal for me that has mentally and emotionally scarred me for life. That may make me a little prejudiced.

Related Topic