HHH-7514 - Upgrade to Jandex 1.1
This commit is contained in:
parent
4282e23caa
commit
fd8a45b2b2
|
@ -1,6 +1,7 @@
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
apply from: "./libraries.gradle"
|
apply from: "./libraries.gradle"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -68,7 +68,8 @@ task jaxb {
|
||||||
cfgXjb = file( 'src/main/xjb/hbm-configuration-bindings.xjb' )
|
cfgXjb = file( 'src/main/xjb/hbm-configuration-bindings.xjb' )
|
||||||
hbmXjb = file( 'src/main/xjb/hbm-mapping-bindings.xjb' )
|
hbmXjb = file( 'src/main/xjb/hbm-mapping-bindings.xjb' )
|
||||||
ormXjb = file( 'src/main/xjb/orm-bindings.xjb' )
|
ormXjb = file( 'src/main/xjb/orm-bindings.xjb' )
|
||||||
}
|
}
|
||||||
|
|
||||||
// configure Gradle up-to-date checking
|
// configure Gradle up-to-date checking
|
||||||
inputs.files( [cfgXsd, hbmXsd, ormXsd, cfgXjb, hbmXjb, ormXjb] )
|
inputs.files( [cfgXsd, hbmXsd, ormXsd, cfgXjb, hbmXjb, ormXjb] )
|
||||||
outputs.dir( jaxbTargetDir )
|
outputs.dir( jaxbTargetDir )
|
||||||
|
|
|
@ -1,186 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
|
||||||
* indicated by the @author tags or express copyright attribution
|
|
||||||
* statements applied by the authors. All third-party contributions are
|
|
||||||
* distributed under license by Red Hat Inc.
|
|
||||||
*
|
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
|
||||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
|
||||||
* Lesser General Public License, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this distribution; if not, write to:
|
|
||||||
* Free Software Foundation, Inc.
|
|
||||||
* 51 Franklin Street, Fifth Floor
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.jboss.jandex;
|
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Aggregates information from multiple {@link Index} instances.
|
|
||||||
*
|
|
||||||
* @author John Bailey
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public class CompositeIndex implements IndexResult {
|
|
||||||
private final List<Index> indexes;
|
|
||||||
|
|
||||||
public CompositeIndex(Index... indexes) {
|
|
||||||
this( Arrays.asList( indexes ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompositeIndex(List<Index> indexes) {
|
|
||||||
this.indexes = indexes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<AnnotationInstance> getAnnotations(DotName annotationName) {
|
|
||||||
final Set<AnnotationInstance> allInstances = new HashSet<AnnotationInstance>();
|
|
||||||
for (Index index : indexes) {
|
|
||||||
copy( index.getAnnotations( annotationName ), allInstances );
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableSet( allInstances );
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void copy(Collection<T> source, Collection<T> target) {
|
|
||||||
if ( source != null ) {
|
|
||||||
target.addAll( source );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ClassInfo> getKnownClasses() {
|
|
||||||
final List<ClassInfo> allKnown = new ArrayList<ClassInfo>();
|
|
||||||
for ( Index index : indexes ) {
|
|
||||||
copy( index.getKnownClasses(), allKnown );
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableCollection( allKnown );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ClassInfo getClassByName(DotName className) {
|
|
||||||
for ( Index index : indexes ) {
|
|
||||||
final ClassInfo info = index.getClassByName( className );
|
|
||||||
if ( info != null ) {
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ClassInfo> getKnownDirectSubclasses(DotName className) {
|
|
||||||
final Set<ClassInfo> allKnown = new HashSet<ClassInfo>();
|
|
||||||
for ( Index index : indexes ) {
|
|
||||||
copy( index.getKnownDirectSubclasses( className ), allKnown );
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableSet( allKnown );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<ClassInfo> getAllKnownSubclasses(final DotName className) {
|
|
||||||
final Set<ClassInfo> allKnown = new HashSet<ClassInfo>();
|
|
||||||
final Set<DotName> processedClasses = new HashSet<DotName>();
|
|
||||||
getAllKnownSubClasses(className, allKnown, processedClasses);
|
|
||||||
return allKnown;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getAllKnownSubClasses(DotName className, Set<ClassInfo> allKnown, Set<DotName> processedClasses) {
|
|
||||||
final Set<DotName> subClassesToProcess = new HashSet<DotName>();
|
|
||||||
subClassesToProcess.add(className);
|
|
||||||
while (!subClassesToProcess.isEmpty()) {
|
|
||||||
final Iterator<DotName> toProcess = subClassesToProcess.iterator();
|
|
||||||
DotName name = toProcess.next();
|
|
||||||
toProcess.remove();
|
|
||||||
processedClasses.add(name);
|
|
||||||
getAllKnownSubClasses(name, allKnown, subClassesToProcess, processedClasses);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getAllKnownSubClasses(
|
|
||||||
DotName name,
|
|
||||||
Set<ClassInfo> allKnown,
|
|
||||||
Set<DotName> subClassesToProcess,
|
|
||||||
Set<DotName> processedClasses) {
|
|
||||||
for ( Index index : indexes ) {
|
|
||||||
final Collection<ClassInfo> list = index.getKnownDirectSubclasses( name );
|
|
||||||
if ( list != null ) {
|
|
||||||
for ( final ClassInfo clazz : list ) {
|
|
||||||
final DotName className = clazz.name();
|
|
||||||
if ( !processedClasses.contains( className ) ) {
|
|
||||||
allKnown.add( clazz );
|
|
||||||
subClassesToProcess.add( className );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ClassInfo> getKnownDirectImplementors(DotName className) {
|
|
||||||
final Set<ClassInfo> allKnown = new HashSet<ClassInfo>();
|
|
||||||
for ( Index index : indexes ) {
|
|
||||||
copy( index.getKnownDirectImplementors( className ), allKnown );
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableSet(allKnown); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ClassInfo> getAllKnownImplementors(DotName interfaceName) {
|
|
||||||
final Set<ClassInfo> allKnown = new HashSet<ClassInfo>();
|
|
||||||
final Set<DotName> subInterfacesToProcess = new HashSet<DotName>();
|
|
||||||
final Set<DotName> processedClasses = new HashSet<DotName>();
|
|
||||||
subInterfacesToProcess.add( interfaceName );
|
|
||||||
while ( !subInterfacesToProcess.isEmpty() ) {
|
|
||||||
final Iterator<DotName> toProcess = subInterfacesToProcess.iterator();
|
|
||||||
DotName name = toProcess.next();
|
|
||||||
toProcess.remove();
|
|
||||||
processedClasses.add( name );
|
|
||||||
getKnownImplementors( name, allKnown, subInterfacesToProcess, processedClasses );
|
|
||||||
}
|
|
||||||
return allKnown;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getKnownImplementors(
|
|
||||||
DotName name,
|
|
||||||
Set<ClassInfo> allKnown,
|
|
||||||
Set<DotName> subInterfacesToProcess,
|
|
||||||
Set<DotName> processedClasses) {
|
|
||||||
for (Index index : indexes) {
|
|
||||||
final List<ClassInfo> list = index.getKnownDirectImplementors(name);
|
|
||||||
if (list != null) {
|
|
||||||
for (final ClassInfo clazz : list) {
|
|
||||||
final DotName className = clazz.name();
|
|
||||||
if (!processedClasses.contains(className)) {
|
|
||||||
if ( Modifier.isInterface( clazz.flags() )) {
|
|
||||||
subInterfacesToProcess.add(className);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!allKnown.contains(clazz)) {
|
|
||||||
allKnown.add(clazz);
|
|
||||||
processedClasses.add(className);
|
|
||||||
getAllKnownSubClasses(className, allKnown, processedClasses);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
|
||||||
* indicated by the @author tags or express copyright attribution
|
|
||||||
* statements applied by the authors. All third-party contributions are
|
|
||||||
* distributed under license by Red Hat Inc.
|
|
||||||
*
|
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
|
||||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
|
||||||
* Lesser General Public License, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this distribution; if not, write to:
|
|
||||||
* Free Software Foundation, Inc.
|
|
||||||
* 51 Franklin Street, Fifth Floor
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.jboss.jandex;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The basic contract for accessing Jandex indexed information.
|
|
||||||
*
|
|
||||||
* @author Jason Greene
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public interface IndexResult {
|
|
||||||
public Collection<ClassInfo> getKnownClasses();
|
|
||||||
|
|
||||||
public ClassInfo getClassByName(DotName className);
|
|
||||||
|
|
||||||
public Collection<ClassInfo> getKnownDirectSubclasses(DotName className);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all known (including non-direct) sub classes of the given class. I.e., returns all known classes
|
|
||||||
* that are assignable to the given class.
|
|
||||||
*
|
|
||||||
* @param className The class
|
|
||||||
*
|
|
||||||
* @return All known subclasses
|
|
||||||
*/
|
|
||||||
public Collection<ClassInfo> getAllKnownSubclasses(final DotName className);
|
|
||||||
|
|
||||||
public Collection<ClassInfo> getKnownDirectImplementors(DotName className);
|
|
||||||
|
|
||||||
public Collection<ClassInfo> getAllKnownImplementors(final DotName interfaceName);
|
|
||||||
|
|
||||||
public Collection<AnnotationInstance> getAnnotations(DotName annotationName);
|
|
||||||
}
|
|
|
@ -56,7 +56,7 @@ import org.jboss.jandex.ClassInfo;
|
||||||
import org.jboss.jandex.CompositeIndex;
|
import org.jboss.jandex.CompositeIndex;
|
||||||
import org.jboss.jandex.DotName;
|
import org.jboss.jandex.DotName;
|
||||||
import org.jboss.jandex.Index;
|
import org.jboss.jandex.Index;
|
||||||
import org.jboss.jandex.IndexResult;
|
import org.jboss.jandex.IndexView;
|
||||||
import org.jboss.jandex.Indexer;
|
import org.jboss.jandex.Indexer;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
@ -183,7 +183,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
||||||
ScanResult scanResult = scan( bootstrapServiceRegistry );
|
ScanResult scanResult = scan( bootstrapServiceRegistry );
|
||||||
// 2) building a Jandex index
|
// 2) building a Jandex index
|
||||||
Set<String> collectedManagedClassNames = collectManagedClassNames( scanResult );
|
Set<String> collectedManagedClassNames = collectManagedClassNames( scanResult );
|
||||||
IndexResult jandexIndex = locateOrBuildJandexIndex( collectedManagedClassNames, scanResult.getPackageNames(), bootstrapServiceRegistry );
|
IndexView jandexIndex = locateOrBuildJandexIndex( collectedManagedClassNames, scanResult.getPackageNames(), bootstrapServiceRegistry );
|
||||||
// 3) building "metadata sources" to keep for later to use in building the SessionFactory
|
// 3) building "metadata sources" to keep for later to use in building the SessionFactory
|
||||||
metadataSources = prepareMetadataSources( jandexIndex, collectedManagedClassNames, scanResult, bootstrapServiceRegistry );
|
metadataSources = prepareMetadataSources( jandexIndex, collectedManagedClassNames, scanResult, bootstrapServiceRegistry );
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private MetadataSources prepareMetadataSources(
|
private MetadataSources prepareMetadataSources(
|
||||||
IndexResult jandexIndex,
|
IndexView jandexIndex,
|
||||||
Set<String> collectedManagedClassNames,
|
Set<String> collectedManagedClassNames,
|
||||||
ScanResult scanResult,
|
ScanResult scanResult,
|
||||||
BootstrapServiceRegistry bootstrapServiceRegistry) {
|
BootstrapServiceRegistry bootstrapServiceRegistry) {
|
||||||
|
@ -270,7 +270,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
||||||
return collectedNames;
|
return collectedNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IndexResult locateOrBuildJandexIndex(
|
private IndexView locateOrBuildJandexIndex(
|
||||||
Set<String> collectedManagedClassNames,
|
Set<String> collectedManagedClassNames,
|
||||||
List<String> packageNames,
|
List<String> packageNames,
|
||||||
BootstrapServiceRegistry bootstrapServiceRegistry) {
|
BootstrapServiceRegistry bootstrapServiceRegistry) {
|
||||||
|
@ -279,14 +279,14 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
||||||
// 2) pass that Index along to the metamodel code...
|
// 2) pass that Index along to the metamodel code...
|
||||||
//
|
//
|
||||||
// (1) is mocked up here, but JBoss AS does not currently pass in any Index to use...
|
// (1) is mocked up here, but JBoss AS does not currently pass in any Index to use...
|
||||||
IndexResult jandexIndex = (IndexResult) configurationValues.get( JANDEX_INDEX );
|
IndexView jandexIndex = (IndexView) configurationValues.get( JANDEX_INDEX );
|
||||||
if ( jandexIndex == null ) {
|
if ( jandexIndex == null ) {
|
||||||
jandexIndex = buildJandexIndex( collectedManagedClassNames, packageNames, bootstrapServiceRegistry );
|
jandexIndex = buildJandexIndex( collectedManagedClassNames, packageNames, bootstrapServiceRegistry );
|
||||||
}
|
}
|
||||||
return jandexIndex;
|
return jandexIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IndexResult buildJandexIndex(Set<String> classNamesSource, List<String> packageNames, BootstrapServiceRegistry bootstrapServiceRegistry) {
|
private IndexView buildJandexIndex(Set<String> classNamesSource, List<String> packageNames, BootstrapServiceRegistry bootstrapServiceRegistry) {
|
||||||
Indexer indexer = new Indexer();
|
Indexer indexer = new Indexer();
|
||||||
|
|
||||||
for ( String className : classNamesSource ) {
|
for ( String className : classNamesSource ) {
|
||||||
|
|
|
@ -1,15 +1,40 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
// build a map of the dependency artifacts to use. Allows centralized definition of the version of artifacts to
|
// build a map of the dependency artifacts to use. Allows centralized definition of the version of artifacts to
|
||||||
// use. In that respect it serves a role similar to <dependencyManagement> in Maven
|
// use. In that respect it serves a role similar to <dependencyManagement> in Maven
|
||||||
ext {
|
ext {
|
||||||
slf4jVersion = '1.6.1'
|
|
||||||
junitVersion = '4.10'
|
|
||||||
h2Version = '1.2.145'
|
|
||||||
bytemanVersion = '1.5.2'
|
|
||||||
infinispanVersion = '5.1.6.FINAL'
|
|
||||||
jnpVersion = '5.0.6.CR1'
|
|
||||||
|
|
||||||
libraries = [
|
slf4jVersion = '1.6.1'
|
||||||
|
junitVersion = '4.10'
|
||||||
|
h2Version = '1.2.145'
|
||||||
|
bytemanVersion = '1.5.2'
|
||||||
|
infinispanVersion = '5.1.6.FINAL'
|
||||||
|
jnpVersion = '5.0.6.CR1'
|
||||||
|
|
||||||
|
libraries = [
|
||||||
// Ant
|
// Ant
|
||||||
ant: 'org.apache.ant:ant:1.8.2',
|
ant: 'org.apache.ant:ant:1.8.2',
|
||||||
|
|
||||||
|
@ -19,7 +44,7 @@ libraries = [
|
||||||
// Annotations
|
// Annotations
|
||||||
commons_annotations:
|
commons_annotations:
|
||||||
'org.hibernate.common:hibernate-commons-annotations:4.0.1.Final@jar',
|
'org.hibernate.common:hibernate-commons-annotations:4.0.1.Final@jar',
|
||||||
jandex: 'org.jboss:jandex:1.0.3.Final',
|
jandex: 'org.jboss:jandex:1.1.0.Alpha1',
|
||||||
classmate: 'com.fasterxml:classmate:0.5.4',
|
classmate: 'com.fasterxml:classmate:0.5.4',
|
||||||
|
|
||||||
// Dom4J
|
// Dom4J
|
||||||
|
@ -79,6 +104,5 @@ libraries = [
|
||||||
ehcache: "net.sf.ehcache:ehcache-core:2.4.3",
|
ehcache: "net.sf.ehcache:ehcache-core:2.4.3",
|
||||||
proxool: "proxool:proxool:0.8.3",
|
proxool: "proxool:proxool:0.8.3",
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue