[Yanel-dev] Configuring a resource
Michael Wechner
michael.wechner at wyona.com
Mon Dec 20 23:58:27 CET 2010
On 12/20/10 5:02 PM, Rob Adamson wrote:
>>> My goal is to move the object
>>> configuration (and hence code dependencies) out of the resource
>>> classes.
>> can you give an example?
> public class AssetServiceResource extends Resource ... {
>
> private final QueryFactory queryFactory;
>
> public AssetServiceResource() throws MalformedURLException {
> // TODO externalise
> this(new SolrSearchService(new
> CommonsHttpSolrServer("http://localhost:8080/solr")));
> }
>
> public AssetServiceResource(QueryFactory queryFactory) {
> this.queryFactory = queryFactory;
> }
>
> ...
>
> I want to configure a QueryFactory externally, then have it passed in somehow.
So, I guess you could do this like
QueryFactory qf = ((MyRealm) getRealm()).getQueryFactory();
> I think the custom realm may be a way of doing this, with a lookup
> method. So I'll try that.
please let me know if case you should encounter problems with this.
Another solution might be to "attach" this to a custom repository.
HTH
Michael
> Thanks,
> Rob
More information about the Yanel-development
mailing list