You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Ramana OpenSource <ra...@gmail.com> on 2014/09/10 19:20:58 UTC

How to get access to SolrCore in init method of Handler Class

Hi,

I need to load a file in instance's conf directory and this data is going
to be used in handleRequestBody() implementation. As of now, i am loading
the file in the handleRequestBody method like below.

SolrCore solrCore = req.getCore();
solrCore .getResourceLoader().getLines(fileToLoad);

But, To make it better, I would like to load this file only once and in the
init() method of handler class. I am not sure how to get the access of
SolrCore in the init method.

Any help would be appreciated.

Thanks,
Ramana.

Re: How to get access to SolrCore in init method of Handler Class

Posted by Ramana OpenSource <ra...@gmail.com>.
Thanks Chris. I have implemented SolrCoreAware  interface and loading the
required file in the inform method.

Thanks,
Ramana.

On Wed, Sep 10, 2014 at 10:59 PM, Chris Hostetter <ho...@fucit.org>
wrote:

>
> : But, To make it better, I would like to load this file only once and in
> the
> : init() method of handler class. I am not sure how to get the access of
> : SolrCore in the init method.
>
> you can't access the SolrCore during hte init() method, because at the
> time it's called the SolrCore itself is not yet fully initialized.
>
> what you can do is implement the SolrCoreAware interface, and then
> you will be garunteed that *after* your init method is called, and before
> you are ever asked to handle any requests, your inform(SolrCore) method
> will be called...
>
>
> -Hoss
> http://www.lucidworks.com/
>

Re: How to get access to SolrCore in init method of Handler Class

Posted by Chris Hostetter <ho...@fucit.org>.
: But, To make it better, I would like to load this file only once and in the
: init() method of handler class. I am not sure how to get the access of
: SolrCore in the init method.

you can't access the SolrCore during hte init() method, because at the 
time it's called the SolrCore itself is not yet fully initialized.

what you can do is implement the SolrCoreAware interface, and then 
you will be garunteed that *after* your init method is called, and before 
you are ever asked to handle any requests, your inform(SolrCore) method 
will be called...


-Hoss
http://www.lucidworks.com/