I started implementing this suggestion and am running into one hitch.

The cleanest solution is to have a single place manage Aware/Inform. The cleanest place for this is in ResourceLoader (refactored Config superclass)

 public Object newInstance(String cname, String... subpackages) {
    ...
      Object obj = clazz.newInstance();
      if( obj instanceof ResourceLoaderAware ) {
        ((ResourceLoaderAware)obj).informResourceLoader( this );
      }
      if( obj instanceof SolrCoreAware ) {
        if( core != null ) {
          ((SolrCoreAware)obj).informSolrCore( core );
        }
        else {
          waitingForCore.add( ((SolrCoreAware)obj) );
        }
      }
    ...
 }


BUT this has one major drawback. This will call informXXX *before* init() is called. In the core case, it may call before *or* after!

Alternatively, we can put the Aware/Inform logic in the AbstractPluginLoader -- this works fine for ResourceLoaderAware, but gets complicated for SolrCoreAware (as is AbstractPluginLoader does not know about the core, and without huge changes can not wait till the core is fully loaded)

Thoughts?

ryan

Reply via email to