SCA Java binding.rss (TUSCANY) created by Dan Becker
   http://cwiki.apache.org/confluence/display/TUSCANY/SCA+Java+binding.rss

Content:
---------------------------------------------------------------------

{section:border=false}
{column:width=15%}
{include: SCA Java Subproject Menu}
{include: Java SCA Menu New}
{column}
{column:width=85%}

h3. <binding.rss> Introduction

The Tuscany Java SCA runtime supports Really Simple Syndication (RSS) using the 
<binding.rss> extension. Tuscany can communicate with services that provide or 
consume items described in the RSS 1.0 or 2.0 syndication format. The RSS 
protcol is an additional conceptual layer that operates on top of the Hyper 
Text Transfer Protocol, so it is useful to understand that underlying protocol 
as well. Reference materials on these specifications is available here.

* [Hyper Text Transfer Protocol|http://tools.ietf.org/html/rfc2616].
* [RSS 1.0 Specification|http://web.resource.org/rss/1.0/].
* [RSS 2.0 Specification|http://cyber.law.harvard.edu/rss/rss.html].

(on) Some of the function described here is included in the Tuscany 1.3.2 and 
1.4 releases. The complete timeline of available and future plans is given in 
the [Tuscany Web 2.0 Roadmap|http://tuscany.apache.org/sca-java-roadmap.html]. 
Note also that the RSS binding support is similar to the [Tuscany Atom Binding 
Support|http://tuscany.apache.org/sca-java-bindingatom.html] in both syntax and 
function.


h3. Using the Tuscany RSS binding

The primary use of the RSS binding is to provide support for collections that 
can be shared in a distributed fashion. Examples of shared collections includes 
shopping carts, telephone directories, insurance forms, and blog sites. These 
collections of items can be added, retrieved, updated, and deleted using the 4 
basic actions of the HTTP protocol:
* POST (create or add)
* GET (retreive or query)
* PUT (update)
* DELETE (destroy or remove

The simplest way to use the Atom binding is to declare a collection as a 
service and provide an HTTP address where one can access the service. This 
service is declared in an SCA composite file which describes the SCA domain.
{code}
        <service name="customer" promote="CustomerCollection">
                <tuscany:binding.rss uri = "http://localhost:8084/customer"/>
        </service>
{code}

The service can be implemented in Java or any of the the Tuscany implementation 
types. For example, here is a way to create an implmentation for the above 
CustomerCollection service as the Java implementation.
{code}
    <component name="CustomerCollection">
        <implementation.java 
class="org.apache.tuscany.sca.binding.feed.CustomerCollectionImpl"/>
    </component>
{code}

A collection that uses the RSS binding usually implements the Collection 
interface given in the package org.apache.tuscany.sca.binding.atom.collection. 
This interface declares the basic access methods mentioned above (post, get, 
put, and delete), and the data types on the methods are expressed as RSS  
SyndFeed and SyndEntry objects. This shows the basic methods of the RSS 
Collection interface in Tuscany:
{code}
public interface Collection {

    SyndFeed getFeed();
    SyndFeed query(String queryString);
{code}

It is up to the developer or implementer of the shopping cart, telephone 
directory, or blog site to provide the code that implements the Collection 
interface. The developer or implementor also provides the code that translates 
from the business objects (shopping cart items, directory entries, insurance 
forms, blog articles) to the Atom model objects Feed and Entry.

One of the features of using this binding is that your business objects 
(shopping cart items, directory entries, insurance forms, and blog articles) 
can now be easily published and shared by the many RSS supporting tools such as 
feed readers, web browsers, and syndication aggregation. In other words, people 
can access your collection most anywhere on any device.

h3. Example

Continuing with the CustomerCollection example shown above, let's see how to 
implement one of the common access methods. In this case, let's look at the get 
method in a client and how one would display the items of a collection. When 
you declared your RSS binding in your SCA composite, you also provided a uri 
for your collection. Using a web browser or other device, a user performs an 
HTTP get request to this uri. The HTTP response for your get request contains a 
body which has the RSS SyndFeed seruialized as a SyndFeed. You may access this 
SyndFeed using Java, and display or present to a user the contents of the RSS 
feed.
{code}
        SyndFeed feed = resourceCollection.getFeed();
        for (Object o : feed.getEntries()) {
            SyndEntry e = (SyndEntry)o;
            System.out.println("id = " + e.getUri() + " entry = " + 
e.getTitle());
        }
{code}

Much of the code consists of converting from a RSS SyndFeed or SyndEntry to a 
business data model and storing to a collection.

Tuscany uses Java Project ROME to provide a model for RSS data. Please see 
[Project ROME |https://rome.dev.java.net/] for the Java methods to access RSS 
SyndFeeds and SyndEntries, and how to easily convert these Java objects to and 
from XML.

h3. Other Features of the Tuscany RSS Binding

In contrast to the Tuscany Atom binding, the Tuscany RSS binding does not 
provide:

* Data caching based on ETag and LastModified header fields.
* JavaScript Object Notation (JSON) alternative to XML feeds and entry data.
* Service document for site introspection.
* Full featured JavaScript client for easy client side programming.

See the [Tuscany Atom Binding 
Support|http://tuscany.apache.org/sca-java-bindingatom.html] for a description 
of these features and how users may get more benefits from the Atom binding.

{column}
{section}

---------------------------------------------------------------------
CONFLUENCE INFORMATION
This message is automatically generated by Confluence

Unsubscribe or edit your notifications preferences
   http://cwiki.apache.org/confluence/users/viewnotifications.action

If you think it was sent incorrectly contact one of the administrators
   http://cwiki.apache.org/confluence/administrators.action

If you want more information on Confluence, or have a bug to report see
   http://www.atlassian.com/software/confluence


Reply via email to