cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: [JAX-RS] CXF - Atom support - samples?
Date Tue, 24 Apr 2012 16:17:33 GMT
Hi
On 24/04/12 15:30, Muller, Anthony wrote:
> Hello,
>
> I'm trying to evaluate what it can be done using CXF + Atom but it is quite difficult
to find information about this topic...
>
> Do you have sample somewhere?

We have some documentation here:
http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-Atom

>
> I'm starting to write a atom provider... Is it the good way to proceed?

Oh, sorry, see you already starting to extend AtomPojoProvider...
This strategy works well if the actual application code does not 'want' 
to get Apache Abdera (or other 3rd party Atom library) classes such as 
Feed or Entry visible. Thta can be handy when say open XML or JSON or 
Atom-enveloped payload needs to be returned, we'd just do 
@Produces({"application/atom+xml", "application/xml"}) or similar.

Dealing directly with Abdera Feed & Entry is more flexible and I guess 
even simpler as you have the direct access to Feed & Entry. The only 
downside is that you bind the code to Abdera, so switching to Rome or 
similar would be more difficult. May be not a big issue...

We do no have any specific demos but have some code on the trunk & 
tests. By default it's really all about registering Atom providers and 
working with Feed & Entry. Here is the one:

http://svn.apache.org/repos/asf/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java

or this one (for Atom-based logging):
http://svn.apache.org/repos/asf/cxf/branches/2.3.x-fixes/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AtomPullServer.java


The Abdera Feed & Entry are used there

>
> Moreover, it is some documentation about OData support in CXF?

There's no specific OAuth support in CXF but I believe Stephan Klevenz 
integrated CXF with the Google OData project.
I guess having a custom provider is also reasonable. I wonder may be we 
should update CXF Search extensions to support the OData URI syntax in 
addition to the FIQL one, need to think about it...

Cheers, Sergey


>
> Regards,
> Anthony
>
>
>
> public class MyODataProvider extends AtomPojoProvider {
>
>         public MyODataProvider() {
>               final Map<String, AbstractAtomElementBuilder<?>>  builders
= new HashMap<String, AbstractAtomElementBuilder<?>>();
>               builders.put(Documents.class.getName(), new DocumentsFeedBuilder());
>               builders.put(Document.class.getName(), new DocumentEntryBuilder());
>
>               setAtomBuilders(builders);
>         }
> }
>
>
> class DocumentsFeedBuilder extends AbstractFeedBuilder<Documents>  {
>
>         @Override
>         public String getIcon(Documents pojo) {
>               return "DocumentsFeedBuilder.getIcon(pojo)";
>         }
>
>         @Override
>         public String getLogo(Documents pojo) {
>               return "DocumentsFeedBuilder.getLogo(pojo)";
>         }
>
>         @Override
>         public String getTitle(Documents pojo) {
>               return "DocumentsFeedBuilder.getTitle(pojo)";
>         }
>
>         @Override
>         public String getAuthor(Documents pojo) {
>               return "DocumentsFeedBuilder.getAuthor(pojo)";
>         }
>
>         @Override
>         public String getId(Documents pojo) {
>               return "DocumentsFeedBuilder.getId(pojo)";
>         }
>
>         @Override
>         public String getBaseUri(Documents pojo) {
>               return "DocumentsFeedBuilder.getBaseUri(pojo)";
>         }
>
>         @Override
>         public String getUpdated(Documents pojo) {
>               return "2012-04-18T17:54:42.155+02:00";
>         }
>
>         @Override
>         public List<String>  getCategories(Documents pojo) {
>               return Collections.emptyList();
>         }
>
>         @Override
>         public Map<String, String>  getLinks(Documents pojo) {
>               return Collections.emptyMap();
>         }
>
> }
>
> class DocumentEntryBuilder extends AbstractEntryBuilder<Document>  {
>
>      @Override
>         public String getPublished(Document pojo) {
>               if(pojo.getUpdated() != null) {
>                      return pojo.getUpdated().toGregorianCalendar().toString(); // "2012-04-18T17:54:42.155+02:00"
>               }
>               return null;
>      }
>
>      @Override
>         public String getSummary(Document pojo) {
>         return "DocumentEntryBuilder.getSummary(pojo)";
>      }
>
>         @Override
>         public String getTitle(Document pojo) {
>               return pojo.getName();
>         }
>
>         @Override
>         public String getAuthor(Document pojo) {
>               return "DocumentEntryBuilder.getAuthor(pojo)";
>         }
>
>         @Override
>         public String getId(Document pojo) {
>               return String.valueOf(pojo.getId());
>         }
>
>         @Override
>         public String getBaseUri(Document pojo) {
>               return "DocumentEntryBuilder.getBaseUri(pojo)";
>         }
>
>         @Override
>         public String getUpdated(Document pojo) {
>               if(pojo.getUpdated() != null) {
>                      return pojo.getUpdated().toGregorianCalendar().toString(); // "2012-04-18T17:54:42.155+02:00"
>               }
>               return null;
>         }
>
>         @Override
>         public List<String>  getCategories(Document pojo) {
>               return Collections.emptyList();
>         }
>
>         @Override
>         public Map<String, String>  getLinks(Document pojo) {
>               return Collections.emptyMap();
>         }
> }
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Mime
View raw message