[hibernate-dev] AS7 use of the "hibernate.ejb.resource_scanner" property to override the default org.hibernate.ejb.packaging.Scanner...

Scott Marlow smarlow at redhat.com
Mon Mar 28 08:32:35 EDT 2011


On 03/28/2011 04:38 AM, Hardy Ferentschik wrote:
> Hi,
>
> as mentioned in the discussion on IRC I am definitely for a move to jandex.
> In fact the current metamodel code I am implementing uses jandex.
>
> Personally I did initially not think about the possibility to share the
> jandex
> index between AS7 and Hibernate, but it sounds of course like a good idea.
> Unfortunately, I don't know so much about the integration layer between AS
> and Hibernate, so if we definitely have to summarize/discuss.

The AS7 jandex context is only available during the deployment of the EE 
archive, which works fine for JPA persistence unit definitions.  On my 
branch 
(https://github.com/scottmarlow/jboss-as/raw/c607a6aab0533b9c0647b3f252386e402eecd1ac/jpa/src/main/java/org/jboss/as/jpa/hibernate/HibernateAnnotationScanner.java) 
is a Scanner implementation that will use the "deployment time only" 
jandex instance to scan the deployments for entities.

In the Scanner implementation, I had to resort to loading classes to 
satisfy the current Scanner implementation.  Perhaps in the next revison 
to the Scanner interface, we might add a method that doesn't return a 
Set of Class's but instead just returns the names:

public Set<String<?>> getClassByNamesInJar(URL jartoScan, Set<Class<? 
extends Annotation>> annotationsToLookFor)

Maybe we could do the same for getPackagesInJar (return a set of package 
names instead of Packages).

>
> One question which comes to my mind is how XML configuration fits into
> the picture
> here? Sharing a pure annotation repository/inde does not seem to be
> enough!?
>
> --Hardy

Jandex is just an index of annotations, the Scanner.getFilesInJar(URL 
jartoScan, Set<String> filePatterns) could probably still be used for 
getting XML configuration files.

Another point to consider is that the 
org.hibernate.ejb.packaging.Scanner is not covering all Hibernate 
integration points, but only the AS JPA integration (as far as I 
currently understand it).

Scott

>
>
> On Sun, 27 Mar 2011 19:36:43 +0200, Scott Marlow <smarlow at redhat.com>
> wrote:
>
>> We just discussed Hibernate 4.0 annotation scanning the other day and I
>> wanted to add to the conversation (which was about using
>> https://github.com/jbossas/jandex).
>>
>> As a workaround for https://issues.jboss.org/browse/JBAS-9141, I'll
>> request a merge of the following change. This is about AS7 setting the
>> "hibernate.ejb.resource_scanner" property to
>> org.jboss.as.jpa.hibernate.HibernateAnnotationScanner (which implements
>> the org.hibernate.ejb.packaging.Scanner interface).
>>
>> If we move away from supporting the current Scanner interface in
>> Hibernate 4.0, we should discuss the impact on the AS7 scanner
>> implementation.
>>
>> The HibernateAnnotationScanner class is in this commit (with other
>> changes that go with it):
>> https://github.com/scottmarlow/jboss-as/commit/5aaaa630f38d89d3bbbe832cac20e5eae0ff4c90
>>
>>
>> Scott
>> _______________________________________________
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev




More information about the hibernate-dev mailing list