abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Diephouse <dan.diepho...@mulesource.com>
Subject Re: Getting access to the Factory/Abdera instances
Date Wed, 31 Oct 2007 00:18:10 GMT
Ewww :-) Having the Abdera instance injected and calling 
Provider.getAbdera() is much cleaner IMO. You never know if people might 
want to have multiple instances around (maybe one has different 
extensions or parsers configured? Not sure... but I've been thoroughly 
scared of calls to static instances ever since Axis 1.x ;-))

- Dan

James M Snell wrote:
> I've recently made a change to Abdera so that we can do:
>
> Abdera abdera = Abdera.getInstance();
>
> Since applications should only use a single instance of Abdera, perhaps
> using this would be good enough?
>
> - James
>
> Dan Diephouse wrote:
>   
>> 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:
>>
>>  @Override
>>  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:
>>
>>  @Override
>>  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.
>>
>> Thoughts?
>>
>> - Dan
>>
>>     


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


Mime
View raw message