abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Calavera" <david.calav...@gmail.com>
Subject Re: Adding an extension
Date Wed, 03 Sep 2008 07:18:25 GMT
Hi Neil,

in my opinion, there aren't pros and cons about extensions, it depends on
your requirements. I mean, I usually follow the standard as much as I can
and I try to use standard extensions but if you need to show more specific
data you need a custom extension. Of course, standard clients don't
understand your markup but it's there in case of anyone want to use it.

Let me give you an example, I built an api on atomPub for the company where
I work, 11870.com, we show services reviews as title and content on entries
and we use opensearch extension in order to show result numbers, etc, but we
wanted to show other specific data, like addresses, telephone numbers, or an
internal id, there is where an own extension is needed. Now, we're planning
to release a new version of that api and we're going to add support for
multipart data using the AtomPub multipart creation extension, but we are
not trying to reinvent the wheel.

I'd say the two Abdera extension approaches are good, it depends on the
requirements of the extension and if you want to build it as an independent
module.

On Tue, Sep 2, 2008 at 4:38 PM, Neil Taylor <nst@aber.ac.uk> wrote:

> Hi David,
>
> Thank you, that has given me a push in the right direction. I see how I can
> create a bit of custom code to manipulate the fields easily - it works
> really well.
>
> I could just create a custom class that manages this approach. I wonder if
> there is any value in creating an extension to package any elements in one
> place. I suspect the answer is yes, but I don't have a list of reasons why.
> I wonder if it is mostly useful if we wanted to share an extension outside
> of the current project.  I am happy to hear any pros/cons about creating an
> extension.
>
> I have had a look at the examples and I see two approaches to an extension
> - they may be more. In the GeoRSS extension, it looks like there is a helper
> class (GeoHelper) that provides static methods to be used to process any
> extra elements. In the MediaRSS example, there is a factory class and
> associated classes. The factory is then referenced in the
> org.apache.abdera.factory.ExtensionFactory file that is bundled into the
> META-INF. Are there any recommendations about using one approach over the
> other?
>
> Regards,
>
> Neil
>
>
>
> David Calavera wrote:
>
>> Hi Neil,
>>
>> there is a page into the wiki where we list all our extensions, but it
>> doesn't include a section of how to create an extension:
>>
>> http://cwiki.apache.org/confluence/display/ABDERA/Extensions
>>
>> Actually, it's quite simple,
>>
>> if you want to add a simple element to an entry with a value:
>>
>>   Entry e = abdera.getFactory().newEntry();
>>   e.addSimpleExtension(QNAME, value);
>>
>> if you want to add nested elements to an entry:
>>
>>    ExtensibleElement extension = e.addExtension(QNAME);
>>    extension = extension.addExtension(QNAME);
>>    extension.addSimpleExtension(QNAME, value);
>>
>> and if you want to add an atom element into other element, for instance, a
>> nested collection into an entry:
>>
>>   Entry entry = abdera.getFactory().newEntry();
>>   Collection c = abdera.getFactory().newCollection(entry);
>>
>> I hope it will be useful, by the way take a look at the source of one of
>> the
>> prebuilt extensions, I think the geo extension is one of the most cleaner
>> that we have.
>>
>> Regards.
>>
>


-- 
David Calavera
http://www.thinkincode.net

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message