On the functional side, it might be beneficial to keep the newInstance as is but introduce an initInstance. We might want instances to be initialized with some of their current arguments before we set the core. This way, we may unify all plugin & factory like functionality under one hood; the sequence would allways be something like: Object inst = solrConfig.newInstance(....); //... do something... solrConfig.initInstance(instance, ...arguments); //... do more....
For the sake of nitpicking on names, I'd advocate to use 'SolrCore.Initializable' instead of SolrCoreAware. The sole method being void init(SolrCore core); this makes the SolrConfig a SolrCore.Initializable. SolrCore.java: public interface Initializable { void init(SorlCore core); } SolrConfig.java: public interface Initializable { void init(SolrConfig config, Map<String, String> args); } public interface InitializableBy<T> { void init(T arg); } public interface InitializablePlugin<T> { void init(T plugin, Node node) throws Exception; } /** The core this config was initiallized with. */ private SolrCore core = null; /** The lit of instances pending core initialization. */ private java.util.List<SolrCore.Initializable> initList = new java.util.ArrayList<SolrCore.Initializable>(); public void init(SolrCore core) { if (core == null) { this.core = core; if (initList != null) { for(SolrCore.Initializable initItem : initList) { initItem.init(core); } initList = null; } } else { String error = "Attempting to initialize SolrConfig " + this + " twice, already bound to " + core ; if (core != this.core) throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, error); Config.log.warning(error); } } public void initInstance(SolrConfig.Initializable instance, Map<String, String> args) { instance.init(this, args); coreInitialize(instance); } public <T> void initInstance(SolrConfig.InitializableBy<T> instance, T arg) { instance.init(arg); coreInitialize(instance); } public <T> void initInstance(SolrConfig.InitializablePlugin<T> instance, T plugin, Node node) throws Exception { instance.init(plugin, node); coreInitialize(instance); } private void coreInitialize(Object instance) { if (instance instanceof SolrCore.Initializable) { SolrCore.Initializable initItem = (SolrCore.Initializable) instance; // delay call to SolrCore.Initializable.init if the config has not been initialized yet if (null == core) { initList.add(initItem); } else { initItem.init(core); } } } -- View this message in context: http://www.nabble.com/SolrConfig.Initializable-tf4665036.html#a13409366 Sent from the Solr - Dev mailing list archive at Nabble.com.