abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Diephouse <dan.diepho...@mulesource.com>
Subject Getting access to the Factory/Abdera instances
Date Tue, 30 Oct 2007 23:51:51 GMT
I was wondering if instead of passing the Abdera instance around all the 
time on the request instance, if we could just inject it into providers 
instead. While theoretically we could have a single provider serve 
multiple Abdera instances, I don't really think its that likely. People 
may do it, but I think the majority of people won't.

If we could do something like Provider.setAbdera(abdera) it would make 
access to the Factory quite a bit easier as well. For instance, inside 
the CollectionProvider bits I have to do this currently:

  public List<Person> getAuthors(Customer entry, RequestContext request) 
throws ResponseContextException {
    Person author = request.getAbdera().getFactory().newAuthor();
    author.setName("Acme Industries");
    return Arrays.asList(author);

Now contrast it to what it could be if we had a 1:1 relationship between 
an Abdera instance and a Provider/CollectionProvider:

  public List<Person> getAuthors(Customer entry) throws 
ResponseContextException {
    Person author = getFactory().newAuthor();
    author.setName("Acme Industries");
    return Arrays.asList(author);

It's not life changing, but its cleaner as the RequestContext doesn't 
need to be passed to get the authors. It would also make the 
AbstractCollectionProvider a fair bit cleaner.


- Dan

Dan Diephouse
http://mulesource.com | http://netzooid.com/blog

View raw message