<div dir="ltr">Hi,<div><br></div><div>---</div><div>TL,DR: Hibernate components would like to receive the Jandex index during deployment. A new method IndexView#close() may help to address concerns about long-living index view references</div><div>---<br></div><div><br></div><div>Different projects from the Hibernate umbrella (e.g. ORM, Validator and Search) rely heavily on meta-data given via annotations. In order to speed up annotation retrieval, we are looking into using the Jandex index created for deployments by the container.</div><div><br></div><div>This would require subsystems like JipiJapa or the one for Bean Validation to pass the IndexView for the deployment to the bootstrapped component. The change itself should be easy, I hope. But Scott expressed concerns about components keeping references to the index after the deployment phase has succeeded. As indexes can be large, this may potentially blockĀ a big chunk of memory for as long as the deployment is running.</div><div><br></div><div>Of course we can promise that Hibernate components wouldn&#39;t keep such references ;) But if that&#39;s not enough, could this concern be mitigated by adding a new method IndexView#close()?</div><div><br></div><div>This method would free all resources of the index and would be called by the container after the deployment has finished. Any operation on a closed index view would throw an exception indicating that the view has been closed. Then, even if a component accidentally kept a reference to an IndexView, it wouldn&#39;t retain much memory (of course the index view wouldn&#39;t be of much use to the component in that state).</div><div><br></div><div>Would that be an acceptable way forward? If so, I could send a pull request towards Jandex. In a next step WF would have to make use of that new version and invoke close() on a deployment&#39;s index at a suitable time during the deployment lifecycle and eventually pass the index to ORM et al.<br></div><div><br></div><div>In a subsequent step we may consider to address use cases such as dynamic reconfiguration which would require to access the index *after* deployment time. One way for addressing this may be to allow for passing in some kind of executor which would expect e.g. a Lambda doing work on an IndexView passed in by the executor. That way components could access the index at runtime, while not keeping a reference to it themselves and thus allowing the container to manage the index and e.g. close or re-open it upon execution. But I think this could be done as a follow-up.</div><div><br></div><div>Any thoughts?</div><div><br></div><div>Thanks,</div><div><br></div><div>--Gunnar</div><div><br></div><div>PS: As a side note, Hibernate Validator currently reads annotations lazily at runtime (when first validating a specific bean type). When using Jandex, we&#39;d have to change this to eagerly build up all the meta-data for the types listed in the index passed during bootstrap. A bit of work, but as said we hope to gain a nice performance improvement from it.</div><div><br></div></div>