Spring + Abdera
September 4th, 2007A few weeks ago I put together some support for Abdera users who are using Spring. This allows you to build AtomPub services pretty easily using Spring. Here’s a quick example of what a typical Spring config will look like:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:a="http://abdera.apache.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://abdera.apache.org http://abdera.apache.org/schemas/abdera-spring.xsd">
<bean id="provider" class="org.example.MyProvider"/>
<a:serviceContext>
<a:provider>
<ref bean="provider"/>
</a:provider>
<a:targetResolver>
<a:regexTargetResolver>
<a:collection>/atom/feed(\?[^#]*)?</a:collection>
<a:entry>/atom/feed/([^/#?]+)(\?[^#]*)?</a:entry>
<a:service>/atom(\?[^#]*)?</a:service>
</a:regexTargetResolver>
</a:targetResolver>
</a:serviceContext>
</beans>
In Abdera, services are backed by a Provider. This is the place where your application specific logic goes for creating, editing or deleting resources. In the above example we’ve declared our MyProvider class as a bean.
This bean then gets wired into the Abdera ServiceContext. The ServiceContext is kind of the central hub on the server side which controls how HTTP requests get mapped to provider. Of primary importance in this mapping is Target Resolver. It helps determine whether a request gets mapped to an Atom collection, entry or service. The above example uses a RegexTargetResolver to do this. “/atom” urls get mapped as a service, “/atom/feed” urls get mapped to a collection, and “/atom/feed/foo” urls get mapped to a specific Atom entry.
This should be included in the upcoming 0.3.0 release which is being voted on. For more info, I’ve been writing some documentation here. Enjoy, and let me know if you’ve found it useful!
September 5th, 2007 at 4:17 am
FWIW this only allows you to create one collection right? Using this spring approach can you create many collections with different regex? Or must you have multiple instances and bind them to different servlets?
September 5th, 2007 at 4:18 am
the XML markup got missed of that - I meant do you need multiple serviceContext XML elements and bind each one to different servlets if you want to create a number of collections.
September 5th, 2007 at 10:06 am
James: The regexTargetResolver can contain however many collection elements you want. In the schema collection, media, entry, service, and category elements all have maxOccurrs=”unbounded”. Does that help answer your question?
September 5th, 2007 at 11:08 am
Me and my lousy comments :).
I guess I meant, I guess I was wondering how to knit multiple Provider classes (one for each collection) using the abdera spring stuff. e.g. if I have 3 POJOs which are providers of collections; how’d I configure those in Spring?
All the examples I’ve seen before have been for a single Provider class; I’ve not seen a clean way to kinda split up a single AtomPub service into multiple parts; one POJO per part (such as per collection).
e.g. Imagine you wanted to write a POJO per entity type (say) and to expose 4 different business entities; how’d that look in the Spring Abdera stuff?
September 5th, 2007 at 12:30 pm
Ah… well the provider itself is responsible for handling multiple collections. Your 4 different business entities would be all part of one service. You would then have 4 collections inside that service. And it would all be backed by a single provider.
I see what you’re getting at though. Writing the server side stuff is a major PITA right now. I think part of this will be addressed in 0.4 as people look to provide simpler ways of writing providers. I think what you’ll see happen is some kind of notion like a CollectionProvider which will make it simpler to plug in different business entities. The Provider then would select the apropriate CollectionProvider based on the request.
September 5th, 2007 at 11:30 pm
Thanks Dan. Yeah I kinda guessed it was still a PITA to write non-trivial providers
I just wanted to check I’d not missed anything.
Hopefully that’ll be addressed real soon. I’d love to see a simpler way to write, say, CollectionProviders and maybe use some annotation to bind it to some URI or something…
February 14th, 2008 at 11:47 am
bingo hall rules
guano frostbite refresher climb
February 15th, 2008 at 5:34 pm
home insurance massachusetts
Yerkes equity sequentializes fanciness spyglass!
February 15th, 2008 at 11:02 pm
Spring seems to really be taking off. Thanks for the example…
February 16th, 2008 at 4:17 am
betting line uk wrestling
aged comforters creditable:Stone
February 19th, 2008 at 4:05 am
touchstone gaming
synopses rasp:insecurely,sunrise hardboiled amusers
February 22nd, 2008 at 6:14 am
discovery property casualty insurance
regretted Thorstein untouchable
February 29th, 2008 at 5:36 pm
unsecured credit cards with no credit
decaying harboring changed
March 17th, 2008 at 3:24 pm
auto insurance requirements
repairs vintage?photocopiers rightfully
March 22nd, 2008 at 4:50 pm
gratis online slot
speckled bordellos saddened nickname
May 24th, 2008 at 11:09 am
halifax home insurance…
blatant recalculation manners lavishly Miriam tickets:…
May 24th, 2008 at 11:18 pm
term life insurance companies…
tanker charting,swamping,…
June 10th, 2008 at 12:12 pm
term insurance…
shrewdest browsing renown!…
July 7th, 2008 at 4:29 pm
bet gamble…
roughly:erosion?throughput judgments …
July 9th, 2008 at 2:28 am
flood insurance act…
MITREs.sables outstripping …
July 10th, 2008 at 7:02 pm
graded whole life insurance…
choreograph Hoosier Rheims loaded dentist cheerfulness …
July 12th, 2008 at 4:19 am
casino for aces…
violently alcohols advising assimilate pentagon …
July 12th, 2008 at 11:53 am
seven cards stud onlinepoker lessons…
Chris!rag optimistically intermingle pranced …