ResourceLoaderAware inform() before or after init()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ResourceLoaderAware inform() before or after init()

David Smiley
Hi folks.

I am wondering what the expected initialization sequence of the analysis factories are with respect to init() and ResourceLoaderAware.inform().  At least judging from some tests, it seems that inform() is called afterwards.  I was expecting the other way around, so that init() can do all the init stuff it needs to do, instead of it being broken up between init() & inform().  In any case, this should be documented.  I'm working on LUCENE-4303 and I hoped to lookup class names in the init() method and have inform() be a simple setter for the loader.

~ David
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ResourceLoaderAware inform() before or after init()

Chris Hostetter-3

: I am wondering what the expected initialization sequence of the analysis
: factories are with respect to init() and ResourceLoaderAware.inform().  
: At least judging from some tests, it seems that inform() is called
: afterwards.  I was expecting the other way around, so that init() can do

The "inform" methods have always come after init(), largely tracing back
to lifecycle problems of objects trying to use other objects that haven't
been initialized yet.  (mainly because of SolrCoreAware but you can still
run into the same thing with ResourceLoaderAware)

practically speaking: most classes parse their init params to get
things like resouce names, then when inform(ResourceLoader) is called they
use those names to get the resources from the loader.

This has been doc'ed on the wiki for a long time, not sure why it never
made it into hte javadocs...

http://wiki.apache.org/solr/SolrPlugins#Plugin_Initialization


-Hoss

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: ResourceLoaderAware inform() before or after init()

Uwe Schindler
In reply to this post by David Smiley
Hi David,

there is currently an issue open in Lucene (LUCENE-4256) handling the issues
with using AnalyzerFactories outside Solr. We are planning to refactor this
and move init args + Resource loader to the constructor (with signature
enforced by SPI loader), so factories can init themselves completely in ctor
and make all their fields/settings final. As this is now moved out of Solr,
the original plugin init requirements are no longer necessarily followed in
the same way as before for analysis factories.

Until we fix this, just make it working. But init() is in all cased called
before inform(), currently.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: [hidden email]


> -----Original Message-----
> From: Smiley, David W. [mailto:[hidden email]]
> Sent: Monday, August 13, 2012 8:39 PM
> To: [hidden email] Dev
> Subject: ResourceLoaderAware inform() before or after init()
>
> Hi folks.
>
> I am wondering what the expected initialization sequence of the analysis
> factories are with respect to init() and ResourceLoaderAware.inform().  At
least
> judging from some tests, it seems that inform() is called afterwards.  I
was
> expecting the other way around, so that init() can do all the init stuff
it needs to
> do, instead of it being broken up between init() & inform().  In any case,
this
> should be documented.  I'm working on LUCENE-4303 and I hoped to lookup
> class names in the init() method and have inform() be a simple setter for
the
> loader.
>
> ~ David
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email] For additional
> commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]