From fd8a45b2b246df9343adf2ec0df9acc298f69704 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 22 Aug 2012 13:41:16 -0500 Subject: [PATCH] HHH-7514 - Upgrade to Jandex 1.1 --- build.gradle | 1 + hibernate-core/hibernate-core.gradle | 23 +-- .../java/org/jboss/jandex/CompositeIndex.java | 186 ------------------ .../java/org/jboss/jandex/IndexResult.java | 56 ------ .../EntityManagerFactoryBuilderImpl.java | 12 +- libraries.gradle | 154 +++++++++------ 6 files changed, 108 insertions(+), 324 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/jboss/jandex/CompositeIndex.java delete mode 100644 hibernate-core/src/main/java/org/jboss/jandex/IndexResult.java diff --git a/build.gradle b/build.gradle index 331aada9b9..22aa62c4d2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'eclipse' apply plugin: 'idea' apply from: "./libraries.gradle" + allprojects { repositories { mavenCentral() diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index b259b540ac..620c95f837 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -56,19 +56,20 @@ idea { task jaxb { ext { - // output directory - jaxbTargetDir = file( "${buildDir}/generated-src/jaxb/main" ) + // output directory + jaxbTargetDir = file( "${buildDir}/generated-src/jaxb/main" ) - // input schemas - cfgXsd = file( 'src/main/resources/org/hibernate/hibernate-configuration-4.0.xsd') - hbmXsd = file( 'src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd' ) - ormXsd = file( 'src/main/resources/org/hibernate/ejb/orm_2_0.xsd' ) + // input schemas + cfgXsd = file( 'src/main/resources/org/hibernate/hibernate-configuration-4.0.xsd') + hbmXsd = file( 'src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd' ) + ormXsd = file( 'src/main/resources/org/hibernate/ejb/orm_2_0.xsd' ) + + // input bindings + cfgXjb = file( 'src/main/xjb/hbm-configuration-bindings.xjb' ) + hbmXjb = file( 'src/main/xjb/hbm-mapping-bindings.xjb' ) + ormXjb = file( 'src/main/xjb/orm-bindings.xjb' ) + } - // input bindings - cfgXjb = file( 'src/main/xjb/hbm-configuration-bindings.xjb' ) - hbmXjb = file( 'src/main/xjb/hbm-mapping-bindings.xjb' ) - ormXjb = file( 'src/main/xjb/orm-bindings.xjb' ) -} // configure Gradle up-to-date checking inputs.files( [cfgXsd, hbmXsd, ormXsd, cfgXjb, hbmXjb, ormXjb] ) outputs.dir( jaxbTargetDir ) diff --git a/hibernate-core/src/main/java/org/jboss/jandex/CompositeIndex.java b/hibernate-core/src/main/java/org/jboss/jandex/CompositeIndex.java deleted file mode 100644 index d0a7fcac9f..0000000000 --- a/hibernate-core/src/main/java/org/jboss/jandex/CompositeIndex.java +++ /dev/null @@ -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 indexes; - - public CompositeIndex(Index... indexes) { - this( Arrays.asList( indexes ) ); - } - - public CompositeIndex(List indexes) { - this.indexes = indexes; - } - - @Override - public Collection getAnnotations(DotName annotationName) { - final Set allInstances = new HashSet(); - for (Index index : indexes) { - copy( index.getAnnotations( annotationName ), allInstances ); - } - return Collections.unmodifiableSet( allInstances ); - } - - private void copy(Collection source, Collection target) { - if ( source != null ) { - target.addAll( source ); - } - } - - @Override - public Collection getKnownClasses() { - final List allKnown = new ArrayList(); - 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 getKnownDirectSubclasses(DotName className) { - final Set allKnown = new HashSet(); - for ( Index index : indexes ) { - copy( index.getKnownDirectSubclasses( className ), allKnown ); - } - return Collections.unmodifiableSet( allKnown ); - } - - @Override - public Set getAllKnownSubclasses(final DotName className) { - final Set allKnown = new HashSet(); - final Set processedClasses = new HashSet(); - getAllKnownSubClasses(className, allKnown, processedClasses); - return allKnown; - } - - private void getAllKnownSubClasses(DotName className, Set allKnown, Set processedClasses) { - final Set subClassesToProcess = new HashSet(); - subClassesToProcess.add(className); - while (!subClassesToProcess.isEmpty()) { - final Iterator toProcess = subClassesToProcess.iterator(); - DotName name = toProcess.next(); - toProcess.remove(); - processedClasses.add(name); - getAllKnownSubClasses(name, allKnown, subClassesToProcess, processedClasses); - } - } - - private void getAllKnownSubClasses( - DotName name, - Set allKnown, - Set subClassesToProcess, - Set processedClasses) { - for ( Index index : indexes ) { - final Collection 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 getKnownDirectImplementors(DotName className) { - final Set allKnown = new HashSet(); - for ( Index index : indexes ) { - copy( index.getKnownDirectImplementors( className ), allKnown ); - } - return Collections.unmodifiableSet(allKnown); } - - @Override - public Collection getAllKnownImplementors(DotName interfaceName) { - final Set allKnown = new HashSet(); - final Set subInterfacesToProcess = new HashSet(); - final Set processedClasses = new HashSet(); - subInterfacesToProcess.add( interfaceName ); - while ( !subInterfacesToProcess.isEmpty() ) { - final Iterator 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 allKnown, - Set subInterfacesToProcess, - Set processedClasses) { - for (Index index : indexes) { - final List 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); - } - } - } - } - } - } - } -} diff --git a/hibernate-core/src/main/java/org/jboss/jandex/IndexResult.java b/hibernate-core/src/main/java/org/jboss/jandex/IndexResult.java deleted file mode 100644 index a85fc392bc..0000000000 --- a/hibernate-core/src/main/java/org/jboss/jandex/IndexResult.java +++ /dev/null @@ -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 getKnownClasses(); - - public ClassInfo getClassByName(DotName className); - - public Collection 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 getAllKnownSubclasses(final DotName className); - - public Collection getKnownDirectImplementors(DotName className); - - public Collection getAllKnownImplementors(final DotName interfaceName); - - public Collection getAnnotations(DotName annotationName); -} diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java index b8003354f5..d4b4113e0a 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java @@ -56,7 +56,7 @@ import org.jboss.jandex.ClassInfo; import org.jboss.jandex.CompositeIndex; import org.jboss.jandex.DotName; import org.jboss.jandex.Index; -import org.jboss.jandex.IndexResult; +import org.jboss.jandex.IndexView; import org.jboss.jandex.Indexer; import org.jboss.logging.Logger; @@ -183,7 +183,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil ScanResult scanResult = scan( bootstrapServiceRegistry ); // 2) building a Jandex index Set 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 metadataSources = prepareMetadataSources( jandexIndex, collectedManagedClassNames, scanResult, bootstrapServiceRegistry ); @@ -210,7 +210,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil @SuppressWarnings("unchecked") private MetadataSources prepareMetadataSources( - IndexResult jandexIndex, + IndexView jandexIndex, Set collectedManagedClassNames, ScanResult scanResult, BootstrapServiceRegistry bootstrapServiceRegistry) { @@ -270,7 +270,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil return collectedNames; } - private IndexResult locateOrBuildJandexIndex( + private IndexView locateOrBuildJandexIndex( Set collectedManagedClassNames, List packageNames, BootstrapServiceRegistry bootstrapServiceRegistry) { @@ -279,14 +279,14 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil // 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... - IndexResult jandexIndex = (IndexResult) configurationValues.get( JANDEX_INDEX ); + IndexView jandexIndex = (IndexView) configurationValues.get( JANDEX_INDEX ); if ( jandexIndex == null ) { jandexIndex = buildJandexIndex( collectedManagedClassNames, packageNames, bootstrapServiceRegistry ); } return jandexIndex; } - private IndexResult buildJandexIndex(Set classNamesSource, List packageNames, BootstrapServiceRegistry bootstrapServiceRegistry) { + private IndexView buildJandexIndex(Set classNamesSource, List packageNames, BootstrapServiceRegistry bootstrapServiceRegistry) { Indexer indexer = new Indexer(); for ( String className : classNamesSource ) { diff --git a/libraries.gradle b/libraries.gradle index 8338b78cfb..4631796672 100644 --- a/libraries.gradle +++ b/libraries.gradle @@ -1,84 +1,108 @@ +/* + * 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 // use. In that respect it serves a role similar to in Maven 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 = [ - // Ant - ant: 'org.apache.ant:ant:1.8.2', + 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' - // Antlr - antlr: 'antlr:antlr:2.7.7', + libraries = [ + // Ant + ant: 'org.apache.ant:ant:1.8.2', - // Annotations - commons_annotations: - 'org.hibernate.common:hibernate-commons-annotations:4.0.1.Final@jar', - jandex: 'org.jboss:jandex:1.0.3.Final', - classmate: 'com.fasterxml:classmate:0.5.4', + // Antlr + antlr: 'antlr:antlr:2.7.7', - // Dom4J - dom4j: 'dom4j:dom4j:1.6.1@jar', + // Annotations + commons_annotations: + 'org.hibernate.common:hibernate-commons-annotations:4.0.1.Final@jar', + jandex: 'org.jboss:jandex:1.1.0.Alpha1', + classmate: 'com.fasterxml:classmate:0.5.4', - // Javassist - javassist: 'org.javassist:javassist:3.15.0-GA', + // Dom4J + dom4j: 'dom4j:dom4j:1.6.1@jar', - // javax - jpa: 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-7plus', - jta: 'org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.0.Final', - validation: 'javax.validation:validation-api:1.0.0.GA', - jacc: 'org.jboss.spec.javax.security.jacc:jboss-jacc-api_1.4_spec:1.0.0.Final', + // Javassist + javassist: 'org.javassist:javassist:3.15.0-GA', - // logging - logging: 'org.jboss.logging:jboss-logging:3.1.0.GA', - logging_processor: 'org.jboss.logging:jboss-logging-processor:1.0.0.Final', + // javax + jpa: 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-7plus', + jta: 'org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.0.Final', + validation: 'javax.validation:validation-api:1.0.0.GA', + jacc: 'org.jboss.spec.javax.security.jacc:jboss-jacc-api_1.4_spec:1.0.0.Final', - // jaxb task - jaxb: 'com.sun.xml.bind:jaxb-xjc:2.1.6', - jaxb2_basics: 'org.jvnet.jaxb2_commons:jaxb2-basics:0.6.0', - jaxb2_ant: 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.6.0', - // ~~~~~~~~~~~~~~~~~~~~~~~~~~ testing + // logging + logging: 'org.jboss.logging:jboss-logging:3.1.0.GA', + logging_processor: 'org.jboss.logging:jboss-logging-processor:1.0.0.Final', - // logging for testing - slf4j_api: "org.slf4j:slf4j-api:${slf4jVersion}", - slf4j_log4j12: "org.slf4j:slf4j-log4j12:${slf4jVersion}", - jcl_slf4j: "org.slf4j:jcl-over-slf4j:${slf4jVersion}", - jcl_api: 'commons-logging:commons-logging-api:99.0-does-not-exist', - jcl: 'commons-logging:commons-logging:99.0-does-not-exist', + // jaxb task + jaxb: 'com.sun.xml.bind:jaxb-xjc:2.1.6', + jaxb2_basics: 'org.jvnet.jaxb2_commons:jaxb2-basics:0.6.0', + jaxb2_ant: 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.6.0', + // ~~~~~~~~~~~~~~~~~~~~~~~~~~ testing + + // logging for testing + slf4j_api: "org.slf4j:slf4j-api:${slf4jVersion}", + slf4j_log4j12: "org.slf4j:slf4j-log4j12:${slf4jVersion}", + jcl_slf4j: "org.slf4j:jcl-over-slf4j:${slf4jVersion}", + jcl_api: 'commons-logging:commons-logging-api:99.0-does-not-exist', + jcl: 'commons-logging:commons-logging:99.0-does-not-exist', - junit: "junit:junit:${junitVersion}", - byteman: "org.jboss.byteman:byteman:${bytemanVersion}", - byteman_install: "org.jboss.byteman:byteman-install:${bytemanVersion}", - byteman_bmunit: "org.jboss.byteman:byteman-bmunit:${bytemanVersion}", - jpa_modelgen: 'org.hibernate:hibernate-jpamodelgen:1.1.1.Final', - shrinkwrap_api: 'org.jboss.shrinkwrap:shrinkwrap-api:1.0.0-beta-6', - shrinkwrap: 'org.jboss.shrinkwrap:shrinkwrap-impl-base:1.0.0-beta-6', - validator: 'org.hibernate:hibernate-validator:4.2.0.Final', - h2: "com.h2database:h2:${h2Version}", - jboss_jta: "org.jboss.jbossts:jbossjta:4.16.4.Final", - xapool: "com.experlog:xapool:1.5.0", - mockito: 'org.mockito:mockito-core:1.9.0', - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ infinsipan - infinispan: "org.infinispan:infinispan-core:${infinispanVersion}", - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ infinispan test - infinispan_test: "org.infinispan:infinispan-core:${infinispanVersion}:tests@jar", - rhq: "org.rhq.helpers:rhq-pluginAnnotations:3.0.4", - jboss_common_core: "org.jboss:jboss-common-core:2.2.16.GA@jar", - jnp_client: "org.jboss.naming:jnp-client:${jnpVersion}", - jnp_server: "org.jboss.naming:jnpserver:${jnpVersion}", + junit: "junit:junit:${junitVersion}", + byteman: "org.jboss.byteman:byteman:${bytemanVersion}", + byteman_install: "org.jboss.byteman:byteman-install:${bytemanVersion}", + byteman_bmunit: "org.jboss.byteman:byteman-bmunit:${bytemanVersion}", + jpa_modelgen: 'org.hibernate:hibernate-jpamodelgen:1.1.1.Final', + shrinkwrap_api: 'org.jboss.shrinkwrap:shrinkwrap-api:1.0.0-beta-6', + shrinkwrap: 'org.jboss.shrinkwrap:shrinkwrap-impl-base:1.0.0-beta-6', + validator: 'org.hibernate:hibernate-validator:4.2.0.Final', + h2: "com.h2database:h2:${h2Version}", + jboss_jta: "org.jboss.jbossts:jbossjta:4.16.4.Final", + xapool: "com.experlog:xapool:1.5.0", + mockito: 'org.mockito:mockito-core:1.9.0', - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ c3p0 - c3p0: "c3p0:c3p0:0.9.1", - ehcache: "net.sf.ehcache:ehcache-core:2.4.3", - proxool: "proxool:proxool:0.8.3", + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ infinsipan + infinispan: "org.infinispan:infinispan-core:${infinispanVersion}", + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ infinispan test + infinispan_test: "org.infinispan:infinispan-core:${infinispanVersion}:tests@jar", + rhq: "org.rhq.helpers:rhq-pluginAnnotations:3.0.4", + jboss_common_core: "org.jboss:jboss-common-core:2.2.16.GA@jar", + jnp_client: "org.jboss.naming:jnp-client:${jnpVersion}", + jnp_server: "org.jboss.naming:jnpserver:${jnpVersion}", + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ c3p0 + c3p0: "c3p0:c3p0:0.9.1", + ehcache: "net.sf.ehcache:ehcache-core:2.4.3", + proxool: "proxool:proxool:0.8.3", - ] + ] }