Skip to content

Commit 08f2970

Browse files
committed
#107 - hibernate-models-bytebuddy
# Conflicts: # hibernate-models/src/main/java/org/hibernate/models/spi/ModelsConfiguration.java
1 parent 3e4c9ce commit 08f2970

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+419
-1015
lines changed

hibernate-models-bytebuddy/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id "published-java-module"
3+
id "shared-testing"
34
}
45

56
description = "Support for hibernate-models based on ByteBuddy (isolated dependency)"
@@ -12,6 +13,4 @@ dependencies {
1213
api project( ":hibernate-models" )
1314

1415
implementation libs.byteBuddy
15-
16-
testImplementation project( ":hibernate-models-testing" )
1716
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright: Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.models.bytebuddy;
6+
7+
/**
8+
* Settings for hibernate-models ByteBuddy support
9+
*
10+
* @author Steve Ebersole
11+
*/
12+
public interface Settings {
13+
/**
14+
* Used to pass the ByteBuddy {@linkplain net.bytebuddy.pool.TypePool}.
15+
*/
16+
String TYPE_POOL_PARAM = "hibernate.models.bytebuddy.typePool";
17+
}

hibernate-models-bytebuddy/src/main/java/org/hibernate/models/bytebuddy/internal/AbstractAnnotationTarget.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.lang.annotation.Annotation;
88
import java.util.Map;
99

10+
import org.hibernate.models.bytebuddy.spi.ByteBuddyModelsContext;
1011
import org.hibernate.models.internal.AnnotationTargetSupport;
1112

1213
import net.bytebuddy.description.annotation.AnnotationSource;
@@ -15,15 +16,15 @@
1516
* @author Steve Ebersole
1617
*/
1718
public abstract class AbstractAnnotationTarget implements AnnotationTargetSupport {
18-
private final SourceModelBuildingContextImpl modelContext;
19+
private final ByteBuddyModelsContext modelContext;
1920

2021
private Map<Class<? extends Annotation>, ? extends Annotation> usageMap;
2122

22-
public AbstractAnnotationTarget(SourceModelBuildingContextImpl modelContext) {
23+
public AbstractAnnotationTarget(ByteBuddyModelsContext modelContext) {
2324
this.modelContext = modelContext;
2425
}
2526

26-
public SourceModelBuildingContextImpl getModelContext() {
27+
public ByteBuddyModelsContext getModelContext() {
2728
return modelContext;
2829
}
2930

hibernate-models-bytebuddy/src/main/java/org/hibernate/models/bytebuddy/internal/AnnotationDescriptorImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import java.lang.annotation.Annotation;
88

9+
import org.hibernate.models.bytebuddy.spi.ByteBuddyModelsContext;
910
import org.hibernate.models.internal.StandardAnnotationDescriptor;
1011
import org.hibernate.models.spi.AnnotationDescriptor;
1112
import org.hibernate.models.spi.SourceModelBuildingContext;
@@ -29,7 +30,7 @@ public AnnotationDescriptorImpl(
2930
super( annotationType, repeatableContainer, buildingContext );
3031
}
3132

32-
public A createUsage(AnnotationDescription annotationDescription, SourceModelBuildingContextImpl context) {
33+
public A createUsage(AnnotationDescription annotationDescription, ByteBuddyModelsContext context) {
3334
return AnnotationUsageBuilder.makeUsage( annotationDescription, this, context );
3435
}
3536
}

hibernate-models-bytebuddy/src/main/java/org/hibernate/models/bytebuddy/internal/AnnotationUsageBuilder.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
import java.util.concurrent.ConcurrentHashMap;
1616
import java.util.function.BiConsumer;
1717

18+
import org.hibernate.models.bytebuddy.spi.ByteBuddyModelsContext;
1819
import org.hibernate.models.bytebuddy.spi.ValueExtractor;
1920
import org.hibernate.models.internal.util.CollectionHelper;
2021
import org.hibernate.models.spi.AnnotationDescriptor;
2122
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
2223
import org.hibernate.models.spi.AttributeDescriptor;
24+
import org.hibernate.models.spi.SourceModelBuildingContext;
2325

2426
import net.bytebuddy.description.annotation.AnnotationDescription;
2527
import net.bytebuddy.description.annotation.AnnotationList;
@@ -35,7 +37,7 @@ public class AnnotationUsageBuilder {
3537
public static <A extends Annotation> A makeUsage(
3638
AnnotationDescription annotationDescription,
3739
AnnotationDescriptor<A> annotationDescriptor,
38-
SourceModelBuildingContextImpl modelContext) {
40+
SourceModelBuildingContext modelContext) {
3941
final Map<String, Object> attributeValues = extractAttributeValues(
4042
annotationDescription,
4143
annotationDescriptor,
@@ -47,7 +49,7 @@ public static <A extends Annotation> A makeUsage(
4749
private static <A extends Annotation> Map<String, Object> extractAttributeValues(
4850
AnnotationDescription annotationDescription,
4951
AnnotationDescriptor<A> annotationDescriptor,
50-
SourceModelBuildingContextImpl modelContext) {
52+
SourceModelBuildingContext modelContext) {
5153

5254
if ( CollectionHelper.isEmpty( annotationDescriptor.getAttributes() ) ) {
5355
return Collections.emptyMap();
@@ -57,7 +59,7 @@ private static <A extends Annotation> Map<String, Object> extractAttributeValues
5759
for ( int i = 0; i < annotationDescriptor.getAttributes().size(); i++ ) {
5860
final AttributeDescriptor<?> attributeDescriptor = annotationDescriptor.getAttributes().get( i );
5961
final ValueExtractor<?> extractor = modelContext
60-
.as( SourceModelBuildingContextImpl.class )
62+
.as( ByteBuddyModelContextImpl.class )
6163
.getValueExtractor( attributeDescriptor.getTypeDescriptor() );
6264
final Object attributeValue = extractor.extractValue(
6365
annotationDescription,
@@ -71,7 +73,7 @@ private static <A extends Annotation> Map<String, Object> extractAttributeValues
7173

7274
public static Map<Class<? extends Annotation>, ? extends Annotation> collectUsages(
7375
AnnotationSource annotationSource,
74-
SourceModelBuildingContextImpl modelContext) {
76+
ByteBuddyModelsContext modelContext) {
7577
if ( annotationSource == null ) {
7678
return Collections.emptyMap();
7779
}
@@ -90,7 +92,7 @@ private static <A extends Annotation> Map<String, Object> extractAttributeValues
9092
public static void processAnnotations(
9193
AnnotationList annotations,
9294
BiConsumer<Class<? extends Annotation>, Annotation> consumer,
93-
SourceModelBuildingContextImpl buildingContext) {
95+
ByteBuddyModelsContext buildingContext) {
9496
final AnnotationDescriptorRegistry annotationDescriptorRegistry = buildingContext.getAnnotationDescriptorRegistry();
9597

9698
for ( AnnotationDescription annotation : annotations ) {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.util.HashMap;
88
import java.util.Map;
99

10-
import org.hibernate.models.bytebuddy.spi.ByteBuddyModelsBuildingContext;
10+
import org.hibernate.models.bytebuddy.spi.ByteBuddyModelsContext;
1111
import org.hibernate.models.bytebuddy.spi.ValueConverter;
1212
import org.hibernate.models.bytebuddy.spi.ValueExtractor;
1313
import org.hibernate.models.internal.AbstractModelBuildingContext;
@@ -28,9 +28,9 @@
2828
*
2929
* @author Steve Ebersole
3030
*/
31-
public class SourceModelBuildingContextImpl
31+
public class ByteBuddyModelContextImpl
3232
extends AbstractModelBuildingContext
33-
implements ByteBuddyModelsBuildingContext {
33+
implements ByteBuddyModelsContext {
3434
private final TypePool typePool;
3535

3636
private final ClassDetailsRegistryImpl classDetailsRegistry;
@@ -39,13 +39,13 @@ public class SourceModelBuildingContextImpl
3939
private final Map<ValueTypeDescriptor, ValueConverter> valueConverters = new HashMap<>();
4040
private final Map<ValueTypeDescriptor, ValueExtractor> valueExtractors = new HashMap<>();
4141

42-
public SourceModelBuildingContextImpl(
42+
public ByteBuddyModelContextImpl(
4343
TypePool typePool,
4444
RegistryPrimer registryPrimer) {
4545
this( typePool, SimpleClassLoading.SIMPLE_CLASS_LOADING, registryPrimer );
4646
}
4747

48-
public SourceModelBuildingContextImpl(
48+
public ByteBuddyModelContextImpl(
4949
TypePool typePool,
5050
ClassLoading classLoading,
5151
RegistryPrimer registryPrimer) {

hibernate-models-bytebuddy/src/main/java/org/hibernate/models/bytebuddy/internal/ClassDetailsBuilderImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package org.hibernate.models.bytebuddy.internal;
66

7+
import org.hibernate.models.bytebuddy.spi.ByteBuddyModelsContext;
78
import org.hibernate.models.spi.ClassDetails;
89
import org.hibernate.models.spi.ClassDetailsBuilder;
910
import org.hibernate.models.spi.SourceModelBuildingContext;
@@ -12,9 +13,9 @@
1213
* @author Steve Ebersole
1314
*/
1415
public class ClassDetailsBuilderImpl implements ClassDetailsBuilder {
15-
private final SourceModelBuildingContextImpl modelContext;
16+
private final ByteBuddyModelsContext modelContext;
1617

17-
public ClassDetailsBuilderImpl(SourceModelBuildingContextImpl modelContext) {
18+
public ClassDetailsBuilderImpl(ByteBuddyModelsContext modelContext) {
1819
this.modelContext = modelContext;
1920
}
2021

hibernate-models-bytebuddy/src/main/java/org/hibernate/models/bytebuddy/internal/ClassDetailsImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.ArrayList;
88
import java.util.List;
99

10+
import org.hibernate.models.bytebuddy.spi.ByteBuddyModelsContext;
1011
import org.hibernate.models.internal.ClassDetailsSupport;
1112
import org.hibernate.models.internal.jdk.SerialJdkClassDetails;
1213
import org.hibernate.models.internal.util.CollectionHelper;
@@ -49,7 +50,7 @@ public class ClassDetailsImpl extends AbstractAnnotationTarget implements ClassD
4950
private List<MethodDetails> methods;
5051
private List<RecordComponentDetails> recordComponents;
5152

52-
public ClassDetailsImpl(TypeDescription typeDescription, SourceModelBuildingContextImpl modelContext) {
53+
public ClassDetailsImpl(TypeDescription typeDescription, ByteBuddyModelsContext modelContext) {
5354
super( modelContext );
5455
this.typeDescription = typeDescription;
5556
this.superClassDetails = determineSuperType( typeDescription, modelContext );

hibernate-models-bytebuddy/src/main/java/org/hibernate/models/bytebuddy/internal/ClassDetailsRegistryImpl.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717
* @author Steve Ebersole
1818
*/
1919
public class ClassDetailsRegistryImpl extends AbstractClassDetailsRegistry {
20-
private final SourceModelBuildingContextImpl modelContext;
2120
private final ClassDetailsBuilderImpl classDetailsBuilder;
2221

23-
public ClassDetailsRegistryImpl(SourceModelBuildingContextImpl context) {
22+
public ClassDetailsRegistryImpl(ByteBuddyModelContextImpl context) {
2423
super( context );
25-
this.modelContext = context;
2624
this.classDetailsBuilder = new ClassDetailsBuilderImpl( context );
2725
}
2826

hibernate-models-bytebuddy/src/main/java/org/hibernate/models/bytebuddy/internal/FieldDetailsImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.Map;
1212

1313
import org.hibernate.models.IllegalCastException;
14+
import org.hibernate.models.bytebuddy.spi.ByteBuddyModelsContext;
1415
import org.hibernate.models.internal.AnnotationTargetSupport;
1516
import org.hibernate.models.spi.AnnotationDescriptor;
1617
import org.hibernate.models.spi.ClassDetails;
@@ -40,7 +41,7 @@ public class FieldDetailsImpl
4041
public FieldDetailsImpl(
4142
FieldDescription.InDefinedShape underlyingField,
4243
ClassDetailsImpl declaringClassDetails,
43-
SourceModelBuildingContextImpl modelContext) {
44+
ByteBuddyModelsContext modelContext) {
4445
super( modelContext );
4546
this.underlyingField = underlyingField;
4647
this.declaringClassDetails = declaringClassDetails;

0 commit comments

Comments
 (0)