abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neil Taylor <...@aber.ac.uk>
Subject Re: Adding an extension
Date Tue, 02 Sep 2008 14:38:31 GMT
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?



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.

View raw message