-
Website
http://www.brodwall.com/johannes/blog/ -
Original page
http://www.brodwall.com/johannes/blog/2007/03/03/a-brief-adventure-with-universal-repositories-and-rest-web-services/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
eirikma
2 comments · 1 points
-
Affordable SEO Services
1 comment · 1 points
-
andreb
1 comment · 1 points
-
thommyb
1 comment · 1 points
-
Andy Palmer
1 comment · 1 points
-
-
Popular Threads
Sjekk ut WP-Syntax pluggen til WordPress. Vil gi deg en vakker output på kodeeksemplene dine.
When trying to run it, I had to add 10 external jars. Makes me wonder
if they're all really needed. Second, in the "trade" package there are
unresolved references to the ...rest.UrlMemoryRepository class.
Still, really cool stuff.
Yeah, as it turns out, Spring is a dependency hog, and the other dependencies stack up.
If you're not doing it already, you really should use Maven to build this (and other) project. It really helps with dependency mess.
Sorry about the UrlMemoryRepository. I am reworking the code, and it is in a bit of an intermediate state right now. If this is a blocker for you, I can prioritize fixing it. Let me know.
Another thing is that the repository interface looks a lot like the Map interface. Make me wonder about the differences, such as method names (should "retrieve" be called "get"?), the type parameters (wouldn't it be nicer with a key type parameter?), would it be possible to go so far as to have Repository implement Map?
Also I didn't quite like the "hack" with URLs being used interchangeably with Keys, or the "Long.valueOf(parts[1])" in RESTRepositoryServlet.getKey where Keys are suddenly assumed/restricted to be Longs.
Not "complaining", just trying to provide some humble feedback, hoping it might be of some interest.
I have indeed considered using the Map interface. My main issue is how to treat keys during inserts. The Map interface is not designed for key generation purposes. I've toyed with a few options, but found none that I like.
Using URLs as keys is actually one of the neat things about REST. This will become more obvious if I get around to publishing work on more complex models.
Regarding "get" versus "retrieve". I choose "retrieve" because of the CRUD patterns (but I cowardly left "insert" as "create" to avoid the overloaded meaning of "insert"). Also, I wanted to remove the association with getters. But "get" might be a better name after all.
When POSTing or PUTting, however, the situation is more complex. I don't think it matters if you are creating or updating, what to do with direct attributes are clear, but not with referenced objects. A referenced object might exist only on the client side, or it might be in the repository, but with different attributes. Do you have a clear vision of how to handle this?
I'm thinking about GET as analogous to lazy loading proxies with Hibernate (or other persistence framework). This means that a GET request could either return a link, or the embedded object. Using the same analogy, PUT and POST requests can be similar to cascading saves, I think. This means that the onus is on the client to ensure that the correct state is transferred.
Does that make sense?