lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Gazzarini <gxs...@gmail.com>
Subject Re: Load a java class on start up
Date Thu, 30 Jun 2016 14:23:45 GMT
Hi,
the lifecycle of your Solr extension (i.e. the component) is not 
something that's up to you.
Before designing the component you should read the framework docs [1], 
in order to understand the context where it will live, once deployed.

There's nothing, as far as I know, other than the component callbacks 
(e.g. the inform, init methods) that can help you to manage the 
lifecycle of a custom class you're using within the component. Look at 
the SolrCoreAware [2] interface, maybe it could fit your needs.
 From what you write it seems you could need something like a singleton 
(which is often an anti-pattern in distributed environment) , but 
without further details I'm just shooting in the dark

In addition: you wrote a component so I guess it shouldn't be so hard to 
have a look at one of the existing built-in components. I'm quite sure 
they already met (and solved) a similar issue.

Best,
Andrea

[1] 
https://lucene.apache.org/solr/6_1_0/solr-core/org/apache/solr/handler/component/SearchComponent.html
[2] https://wiki.apache.org/solr/SolrPlugins#SolrCoreAware

On 30/06/16 16:00, Mark Robinson wrote:
> Hi,
>
> I have a java OBJECT which I need to load once.
> I have written a java custom component, which I have added in
> "last-components" in solrconfig.xml, from which I want to access the above
> mentioned OBJECT when each search request comes in.
>
> Is there a way I can load a java object on server/ instance startup?
> OR
> Load it when the first call comes to SOLR?
>
> For the time being I created that Java object inside the custom component
> itself; but it is loaded each time a search request comes in.
>
> Could some one pls give some pointers on how my above requirement can be
> achieved in SOLR?
>
> Thanks!
> Mark
>


Mime
View raw message