abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Constabaris <a...@clownsinmycoffee.net>
Subject Controlling serialization w/extensions
Date Tue, 27 Feb 2007 16:40:00 GMT
I'm currently trying to track down the cause of some bad output from my 
Provider's getFeed() method (building against trunk).   I'm not sure 
whether it's a bug yet.  I've written an ExtensionFactory because my 
entries contain some Dublin Core elements, but the namespace handling on 
output isn't working correctly -- in some environments.  When I run my 
provider in a servlet container, only the first atom:entry element in 
the output contains declarations for the DC namespace; subsequent 
atom:entry elements lack the declarations.  Tests mimicking the servlet 
environment as closely as possible don't exhibit the same problem.

This symptom suggests that there's a bug in the serializer somewhere 
("I've already output a declaration for those, so I don't need to do it 
again"), but the successful unit tests don't fit with that diagnosis.  
I've tried this against Axiom 1.2.1 and 1.2.2, since they addressed some 
namespace issues there.  I haven't seen anything (yet) that tells me 
whether the container (Glassfish) is a factor here.  Both environments 
use the same JDK (1.6.0) and a default Abdera instance.

The hack I've adopted, for the time being, is to add extension elements 
using all the namespaces that will appear in the entries to the feed 
element;  since I don't need those  elements to appear, what I'd like to 
do is just add the namespace declarations (and save a few bits on the 
wire while I'm at it).  So there's a concrete RFE, at least.

Stripping down to (what I believe are) the bare essentials, this is the 

MyProvider extends AbstractProvider {
  public ResponseContext getFeed(RequestContext req) {
        Factory factory = 
        factory.registerExtension( new DCExtensionFactory() ); // Dublin 
Core elements
        Feed feed = factory.newFeed();
        MyEntryFactory ef = new MyEntryFactory(factory);
        feed.setTitle("My Feed With Extensions");
        for( MyObject object : myObjects ) {
            feed.addEntry( ef.getEntry(object) );
        return new BaseResponseContext(feed);

public class MyEntryFactory {
   public MyEntryFactory(Factory factory) {
     this.factory = factory;

   public Entry getEntry(MyObject object) {
      Entry entry = factory.newEntry();  // I've also tried passing in 
the parent feed here and using factory.newEntry(feed)

    // DCTextElement -> ElementWrapper
    DCTextElement publisher = 
    return entry;



View raw message