abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Annotations
Date Mon, 30 Jul 2007 20:51:15 GMT
I've been thinking lately about the possibility of defining a set of
Java 5 annotations that would allow developers to mark up their beans in
a way that allows serialization into Atom elements.  For instance,

  @AtomEntry
  public static class Foo {

    @AtomID
    public String getId() {
      return "http://example.org/foo";
    }

    @AtomTitle(type=Text.Type.TEXT)
    public String getTitle() {
      return "Foo";
    }

    @AtomLink(rel="alternate")
    public String getAltLink() {
      return "http://example.org";
    }

    @AtomLink(rel="enclosure")
    public String getOtherLink() {
      return "http://example.com/foo.jpg";
    }

    @AtomContent(type=Content.Type.XHTML)
    public String getContent() {
      return "Bar";
    }
  }

The trick to making this successful would be to make sure the
annotations are expressive enough to capture the broad range of options
in Atom while not making it too complex.  A special converter would be
provided that would take an object instance annotated in this way and
return the appropriate Atom object, e.g.

  Foo foo = new Foo();
  Entry entry = Converter.convert(foo, abdera);

The main question I have is whether or not this would be useful enough
to go through the trouble of implementing it.  Thoughts?

- James

Mime
View raw message