[hibernate-dev] Jandex, scanning and discovery
Hardy Ferentschik
hardy at hibernate.org
Mon Apr 28 14:09:16 EDT 2014
On 28 Jan 2014, at 17:20, Steve Ebersole <steve at hibernate.org> wrote:
> Almost done with this. We are much more aggressive about indexing stuff into Jandex now (which is a good thing) when we are not handed a Jandex Index.
>
> However, this does mean we need to be more careful in the case of JPA and exclude-non-listed-classes. ATM we drive annotations based on Jandex (aka, the classes known to Jandex). However, if we know index classes that should not be used as entities, etc (because of exclude-non-listed-classes) we are breaking the JPA spec. To this end, I suggest that scanning:
> 1) Index everything
> 2) Keep a running tab of "allowable managed classes and packages".
>
> Later, when beginning interpretation of annotations (via Jandex) we can cross-reference that with the list of allowable managed classes. Currently we do:
>
> for ( ClassInfo classInfo : bindingContext.getJandexAccess().getIndex().getKnownClasses() ) {
> // use them all...
> }
>
>
> What I am suggesting is:
>
> interface ManagedClassFilter {
> public boolean allowAsManagedClass(ClassInfo classInfo);
> }
>
> for ( ClassInfo classInfo : bindingContext.getJandexAccess().getIndex().getKnownClasses() ) {
> if ( !managedClassFiler.allowAsManagedClass( classInfo ) ) {
> continue;
> }
> }
>
> Further, rather than maintaining potentially large lists of allowable class and package names, I'd also suggest we recognize the cases when we have open-ended discovery in play and simply use an "all inclusive" strategy.
sounds good.
More information about the hibernate-dev
mailing list