abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vasudeva Nori" <vasun...@gmail.com>
Subject Re: creating a writer
Date Fri, 09 May 2008 20:01:25 GMT
I would like to propose a couple of changes/additions to the mechanism of
writing custom writers (& parsers) in abdera.

Right now, Custom writers are to be declared in
META-INF/services/org.apache.abdera.writer.NamedWriter file
I was looking for a way to dynamically bind a "new writer" I have at
runtime, because in the system I am working with, there is no way to
statically enumerate the writers in a file.
Turns out it is not difficult at all. AbderaConfiguration has
addNamedWriters(NamedWriter) method that can be used to do this.

so, here is my proposal: why not make this method part of the Configuration
interface.
Is there a strong reason to not do this?

right now, code to add NamedWriter at runtime looks like this
    JSONWriter jsonWriter = new JSONWriter();
    Configuration config = getAbdera().getConfiguration();
    if (config instanceof AbderaConfiguration) {
      ((AbderaConfiguration)config).addNamedWriter(jsonWriter);
    }

instead, I would like to remove the cast to AbderaConfiguration and make it
cleaner.

and, BTW, I noticed there is no error handling in AbderaConfiguration.java
to make sure a writer for "name1" doesn't already exist before adding it to
"Map<String,NamedWriter> writers" struct.
have to submit a patch for it one of these days to fix this. unless James or
someone else gets to it sooner :)

thanks

On Sat, May 3, 2008 at 2:38 AM, David Calavera <david.calavera@gmail.com>
wrote:

> Yep, you can look at the custom writers section into the wiki:
>
> http://cwiki.apache.org/confluence/display/ABDERA/Custom+Writers
>
> On Sat, May 3, 2008 at 8:20 AM, Vasudeva Nori <vasunori@gmail.com> wrote:
>
> > The following code fragment on Abdera's Extension web page shows a
> "json":
> > writer.
> > writer json = abdera.getWriterFactory().getWriter("json");
> > entry.writeTo(json, System.out);
> >
> > is it possible to create a writer for "foo_format" and do the following
> >
> > Writer json = abdera.getWriterFactory().getWriter("foo_format");
> > entry.writeTo(json, System.out);
> > If so, how does one "associate" foo_format writer to "foo_format"? any
> > pointer to doing this in abdera would be great.
> >
> > thanks
> >
>
>
>
> --
> David Calavera
> http://www.thinkincode.net
>

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