diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index 381fc3ebdcb4b..93166305a5bb9 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -639,11 +639,6 @@
quarkus-panache-common-deployment
${project.version}
-
- io.quarkus
- quarkus-mongodb-panache-common-deployment
- ${project.version}
-
io.quarkus
quarkus-panache-mock
@@ -714,16 +709,6 @@
quarkus-mongodb-panache-deployment
${project.version}
-
- io.quarkus
- quarkus-mongodb-panache-kotlin
- ${project.version}
-
-
- io.quarkus
- quarkus-mongodb-panache-common
- ${project.version}
-
io.quarkus
quarkus-hibernate-search-elasticsearch
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/Capability.java b/core/deployment/src/main/java/io/quarkus/deployment/Capability.java
index dc1263da2918b..f2672f2ec5ea6 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/Capability.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/Capability.java
@@ -31,7 +31,6 @@ public enum Capability {
JWT,
TIKA,
MONGODB_PANACHE,
- MONGODB_PANACHE_KOTLIN,
FLYWAY,
LIQUIBASE,
SECURITY,
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java b/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java
index 90461bc4d0ee1..2f1c3145eb830 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java
@@ -10,7 +10,6 @@
import static io.quarkus.deployment.util.ReflectUtil.rawTypeIs;
import static io.quarkus.deployment.util.ReflectUtil.rawTypeOf;
import static io.quarkus.deployment.util.ReflectUtil.rawTypeOfParameter;
-import static java.util.Arrays.asList;
import java.io.IOException;
import java.lang.reflect.AnnotatedElement;
@@ -254,9 +253,6 @@ public static Consumer loadStepsFrom(Class> clazz, BuildTim
final Constructor>[] constructors = clazz.getDeclaredConstructors();
// this is the chain configuration that will contain all steps on this class and be returned
Consumer chainConfig = Functions.discardingConsumer();
- if (Modifier.isAbstract(clazz.getModifiers())) {
- return chainConfig;
- }
// this is the step configuration that applies to all steps on this class
Consumer stepConfig = Functions.discardingConsumer();
// this is the build step instance setup that applies to all steps on this class
@@ -486,7 +482,7 @@ public static Consumer loadStepsFrom(Class> clazz, BuildTim
}
// now iterate the methods
- final List methods = getMethods(clazz);
+ final Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
final int mods = method.getModifiers();
if (Modifier.isStatic(mods)) {
@@ -967,15 +963,6 @@ public String toString() {
return chainConfig;
}
- protected static List getMethods(Class> clazz) {
- List declaredMethods = new ArrayList<>();
- if (!clazz.getName().equals(Object.class.getName())) {
- declaredMethods.addAll(getMethods(clazz.getSuperclass()));
- declaredMethods.addAll(asList(clazz.getDeclaredMethods()));
- }
- return declaredMethods;
- }
-
private static BooleanSupplier and(BooleanSupplier a, BooleanSupplier b) {
return () -> a.getAsBoolean() && b.getAsBoolean();
}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/Feature.java b/core/deployment/src/main/java/io/quarkus/deployment/Feature.java
index 843cd31d9f4fd..56bab5e6a90d5 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/Feature.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/Feature.java
@@ -59,7 +59,6 @@ public enum Feature {
MAILER,
MONGODB_CLIENT,
MONGODB_PANACHE,
- MONGODB_PANACHE_KOTLIN,
MUTINY,
NARAYANA_JTA,
NARAYANA_STM,
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/util/AsmUtil.java b/core/deployment/src/main/java/io/quarkus/deployment/util/AsmUtil.java
index c72b9c9d88ba5..b1d43433b0780 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/util/AsmUtil.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/util/AsmUtil.java
@@ -1,20 +1,7 @@
package io.quarkus.deployment.util;
-import static java.util.Arrays.asList;
-import static org.objectweb.asm.Type.BOOLEAN_TYPE;
-import static org.objectweb.asm.Type.BYTE_TYPE;
-import static org.objectweb.asm.Type.CHAR_TYPE;
-import static org.objectweb.asm.Type.FLOAT_TYPE;
-import static org.objectweb.asm.Type.INT_TYPE;
-import static org.objectweb.asm.Type.LONG_TYPE;
-import static org.objectweb.asm.Type.SHORT_TYPE;
-import static org.objectweb.asm.Type.VOID_TYPE;
-import static org.objectweb.asm.Type.getType;
-
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.function.Function;
import org.jboss.jandex.ArrayType;
@@ -33,36 +20,6 @@
*/
public class AsmUtil {
- public static final List PRIMITIVES = asList(
- VOID_TYPE,
- BOOLEAN_TYPE,
- CHAR_TYPE,
- BYTE_TYPE,
- SHORT_TYPE,
- INT_TYPE,
- FLOAT_TYPE,
- LONG_TYPE);
- public static final List WRAPPERS = asList(
- getType(Void.class),
- getType(Boolean.class),
- getType(Character.class),
- getType(Byte.class),
- getType(Short.class),
- getType(Integer.class),
- getType(Float.class),
- getType(Long.class));
- public static final Map WRAPPER_TO_PRIMITIVE = new HashMap<>();
-
- static {
- for (int i = 0; i < AsmUtil.PRIMITIVES.size(); i++) {
- AsmUtil.WRAPPER_TO_PRIMITIVE.put(AsmUtil.WRAPPERS.get(i), AsmUtil.PRIMITIVES.get(i));
- }
- }
-
- public static org.objectweb.asm.Type autobox(org.objectweb.asm.Type primitive) {
- return WRAPPERS.get(primitive.getSort());
- }
-
/**
* Returns the Java bytecode signature of a given Jandex MethodInfo using the given type argument mappings.
* For example, given this method:
@@ -474,43 +431,6 @@ public static void unboxIfRequired(MethodVisitor mv, Type jandexType) {
}
}
- /**
- * Calls the right unboxing method for the given Jandex Type if it is a primitive.
- *
- * @param mv The MethodVisitor on which to visit the unboxing instructions
- * @param type The Jandex Type to unbox if it is a primitive.
- */
- public static void unboxIfRequired(MethodVisitor mv, org.objectweb.asm.Type type) {
- if (type.getSort() <= org.objectweb.asm.Type.DOUBLE) {
- switch (type.getSort()) {
- case org.objectweb.asm.Type.BOOLEAN:
- unbox(mv, "java/lang/Boolean", "booleanValue", "Z");
- break;
- case org.objectweb.asm.Type.BYTE:
- unbox(mv, "java/lang/Byte", "byteValue", "B");
- break;
- case org.objectweb.asm.Type.CHAR:
- unbox(mv, "java/lang/Character", "charValue", "C");
- break;
- case org.objectweb.asm.Type.DOUBLE:
- unbox(mv, "java/lang/Double", "doubleValue", "D");
- break;
- case org.objectweb.asm.Type.FLOAT:
- unbox(mv, "java/lang/Float", "floatValue", "F");
- break;
- case org.objectweb.asm.Type.INT:
- unbox(mv, "java/lang/Integer", "intValue", "I");
- break;
- case org.objectweb.asm.Type.LONG:
- unbox(mv, "java/lang/Long", "longValue", "J");
- break;
- case org.objectweb.asm.Type.SHORT:
- unbox(mv, "java/lang/Short", "shortValue", "S");
- break;
- }
- }
- }
-
private static void unbox(MethodVisitor mv, String owner, String methodName, String returnTypeSignature) {
mv.visitTypeInsn(Opcodes.CHECKCAST, owner);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, methodName, "()" + returnTypeSignature, false);
diff --git a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java
index f9aa3a09c5589..23561d8a5c24c 100644
--- a/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java
+++ b/extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java
@@ -108,10 +108,10 @@ protected String getConnectionString() {
}
private static void initializeReplicaSet(final List mongodConfigList) throws UnknownHostException {
- final String arbiterAddress = "mongodb://" + mongodConfigList.get(0).net().getServerAddress().getHostName() + ":"
+ final String arbitrerAddress = "mongodb://" + mongodConfigList.get(0).net().getServerAddress().getHostName() + ":"
+ mongodConfigList.get(0).net().getPort();
final MongoClientSettings mo = MongoClientSettings.builder()
- .applyConnectionString(new ConnectionString(arbiterAddress)).build();
+ .applyConnectionString(new ConnectionString(arbitrerAddress)).build();
try (MongoClient mongo = MongoClients.create(mo)) {
final MongoDatabase mongoAdminDB = mongo.getDatabase("admin");
diff --git a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheCompanionEnhancer.java b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheCompanionEnhancer.java
index a8e4585184f37..620bb5cb771bb 100644
--- a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheCompanionEnhancer.java
+++ b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheCompanionEnhancer.java
@@ -23,7 +23,7 @@ public class KotlinPanacheCompanionEnhancer extends PanacheEntityEnhancer methodCustomizers) {
- super(index, methodCustomizers);
+ super(index, KotlinPanacheResourceProcessor.PANACHE_ENTITY_BASE_DOTNAME, methodCustomizers);
modelInfo = new MetamodelInfo<>();
}
diff --git a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheEntityClassVisitor.java b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheEntityClassVisitor.java
index 74b478f1a039a..49df9ed685726 100644
--- a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheEntityClassVisitor.java
+++ b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheEntityClassVisitor.java
@@ -13,17 +13,18 @@
import io.quarkus.panache.common.deployment.EntityField;
import io.quarkus.panache.common.deployment.EntityModel;
import io.quarkus.panache.common.deployment.MetamodelInfo;
+import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
import io.quarkus.panache.common.deployment.PanacheMethodCustomizer;
-import io.quarkus.panache.common.deployment.visitors.PanacheEntityClassVisitor;
/**
* This visitor process kotlin entities and removes the final modifier from the compiler generated getters and setters.
* Unlike Java entities, we don't need to generate the getters and setters because kotlinc does that for us but kotlin,
* by default, is final so we need to open those up for hibernate to add its hooks.
*/
-class KotlinPanacheEntityClassVisitor extends PanacheEntityClassVisitor {
+class KotlinPanacheEntityClassVisitor extends PanacheEntityEnhancer.PanacheEntityClassVisitor {
private String entityBinaryType;
+ private org.objectweb.asm.Type entityType;
public KotlinPanacheEntityClassVisitor(String className, ClassVisitor outputClassVisitor,
MetamodelInfo> modelInfo,
@@ -37,7 +38,8 @@ public KotlinPanacheEntityClassVisitor(String className, ClassVisitor outputClas
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
- entityBinaryType = name;
+ entityBinaryType = name.replace('.', '/');
+ entityType = org.objectweb.asm.Type.getType("L" + entityBinaryType + ";");
}
@Override
@@ -50,10 +52,20 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str
}
@Override
- protected String getPanacheOperationsInternalName() {
+ protected String getModelDescriptor() {
+ return "Ljava/lang/Class;";
+ }
+
+ @Override
+ protected String getPanacheOperationsBinaryName() {
return KotlinPanacheEntityEnhancer.JPA_OPERATIONS_BINARY_NAME;
}
+ @Override
+ protected void injectModel(MethodVisitor mv) {
+ mv.visitLdcInsn(entityType);
+ }
+
@Override
protected void generateAccessorSetField(MethodVisitor mv, EntityField field) {
mv.visitMethodInsn(
diff --git a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheEntityEnhancer.java b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheEntityEnhancer.java
index f976635ad80ef..bd682866d26bd 100644
--- a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheEntityEnhancer.java
+++ b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheEntityEnhancer.java
@@ -1,11 +1,10 @@
package io.quarkus.hibernate.orm.panache.kotlin.deployment;
-import static io.quarkus.hibernate.orm.panache.kotlin.deployment.KotlinPanacheResourceProcessor.PANACHE_ENTITY_BASE;
-import static io.quarkus.hibernate.orm.panache.kotlin.deployment.KotlinPanacheResourceProcessor.TRANSIENT;
-
import java.lang.reflect.Modifier;
import java.util.List;
+import javax.persistence.Transient;
+
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.FieldInfo;
@@ -25,15 +24,16 @@ public class KotlinPanacheEntityEnhancer extends PanacheEntityEnhancer methodCustomizers) {
- super(index, methodCustomizers);
+ super(index, KotlinPanacheResourceProcessor.PANACHE_ENTITY_BASE_DOTNAME, methodCustomizers);
modelInfo = new MetamodelInfo<>();
}
@Override
public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) {
- return new KotlinPanacheEntityClassVisitor(className, outputClassVisitor, modelInfo,
- indexView.getClassByName(PANACHE_ENTITY_BASE),
+ return new KotlinPanacheEntityClassVisitor(className, outputClassVisitor, modelInfo, panacheEntityBaseClassInfo,
indexView.getClassByName(DotName.createSimple(className)), methodCustomizers);
}
@@ -43,7 +43,7 @@ public void collectFields(ClassInfo classInfo) {
String name = fieldInfo.name();
if (Modifier.isPublic(fieldInfo.flags())
&& !Modifier.isStatic(fieldInfo.flags())
- && !fieldInfo.hasAnnotation(TRANSIENT)) {
+ && !fieldInfo.hasAnnotation(DOTNAME_TRANSIENT)) {
entityModel.addField(new EntityField(name, DescriptorUtils.typeToString(fieldInfo.type())));
}
}
diff --git a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheRepositoryClassVisitor.java b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheRepositoryClassVisitor.java
index 6fd8e6b5b4a4b..674bf0ba3a44f 100644
--- a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheRepositoryClassVisitor.java
+++ b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheRepositoryClassVisitor.java
@@ -1,11 +1,11 @@
package io.quarkus.hibernate.orm.panache.kotlin.deployment;
-import static io.quarkus.deployment.util.AsmUtil.autobox;
import static io.quarkus.gizmo.Gizmo.ASM_API_VERSION;
import static io.quarkus.hibernate.orm.panache.kotlin.deployment.KotlinPanacheResourceProcessor.JPA_OPERATIONS;
-import static io.quarkus.hibernate.orm.panache.kotlin.deployment.KotlinPanacheResourceProcessor.PANACHE_REPOSITORY_BASE;
+import static io.quarkus.hibernate.orm.panache.kotlin.deployment.KotlinPanacheResourceProcessor.PANACHE_REPOSITORY_BASE_DOTNAME;
+import static io.quarkus.hibernate.orm.panache.kotlin.deployment.KotlinPanacheResourceProcessor.autobox;
import static io.quarkus.hibernate.orm.panache.kotlin.deployment.KotlinPanacheResourceProcessor.sanitize;
-import static io.quarkus.panache.common.deployment.visitors.PanacheRepositoryClassVisitor.findEntityTypeArgumentsForPanacheRepository;
+import static io.quarkus.panache.common.deployment.PanacheRepositoryEnhancer.PanacheRepositoryClassVisitor.findEntityTypeArgumentsForPanacheRepository;
import static org.jboss.jandex.DotName.createSimple;
import static org.objectweb.asm.Opcodes.ALOAD;
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
@@ -57,7 +57,7 @@ public void visit(int version, int access, String name, String signature, String
final String repositoryClassName = name.replace('/', '.');
String[] foundTypeArguments = findEntityTypeArgumentsForPanacheRepository(indexView, repositoryClassName,
- PANACHE_REPOSITORY_BASE);
+ PANACHE_REPOSITORY_BASE_DOTNAME);
String entityBinaryType = foundTypeArguments[0];
entitySignature = "L" + entityBinaryType + ";";
diff --git a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheRepositoryEnhancer.java b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheRepositoryEnhancer.java
index 53e58e4f21d47..003d256378604 100644
--- a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheRepositoryEnhancer.java
+++ b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheRepositoryEnhancer.java
@@ -8,7 +8,7 @@
public class KotlinPanacheRepositoryEnhancer extends PanacheRepositoryEnhancer {
public KotlinPanacheRepositoryEnhancer(IndexView index) {
- super(index, KotlinPanacheResourceProcessor.PANACHE_REPOSITORY_BASE);
+ super(index, KotlinPanacheResourceProcessor.PANACHE_REPOSITORY_BASE_DOTNAME);
}
@Override
diff --git a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheResourceProcessor.java b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheResourceProcessor.java
index a3b4e29795ca3..f463cca99af13 100644
--- a/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheResourceProcessor.java
+++ b/extensions/panache/hibernate-orm-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/orm/panache/kotlin/deployment/KotlinPanacheResourceProcessor.java
@@ -11,7 +11,6 @@
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
-import javax.persistence.Transient;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
@@ -41,6 +40,7 @@
import io.quarkus.panache.common.deployment.PanacheFieldAccessEnhancer;
import io.quarkus.panache.common.deployment.PanacheMethodCustomizer;
import io.quarkus.panache.common.deployment.PanacheMethodCustomizerBuildItem;
+import io.quarkus.panache.common.deployment.PanacheRepositoryEnhancer;
public final class KotlinPanacheResourceProcessor {
@@ -49,12 +49,12 @@ public final class KotlinPanacheResourceProcessor {
static final String JPA_OPERATIONS = createSimple(JpaOperations.class.getName())
.toString().replace(".", "/");
- static final DotName PANACHE_REPOSITORY_BASE = createSimple(PanacheRepositoryBase.class.getName());
- static final DotName PANACHE_REPOSITORY = createSimple(PanacheRepository.class.getName());
+ static final DotName PANACHE_REPOSITORY_BASE_DOTNAME = createSimple(PanacheRepositoryBase.class.getName());
+ static final DotName PANACHE_REPOSITORY_DOTNAME = createSimple(PanacheRepository.class.getName());
- static final DotName PANACHE_ENTITY_BASE = createSimple(PanacheEntityBase.class.getName());
- static final DotName PANACHE_ENTITY = createSimple(PanacheEntity.class.getName());
- static final DotName PANACHE_COMPANION = createSimple(PanacheCompanion.class.getName());
+ static final DotName PANACHE_ENTITY_BASE_DOTNAME = createSimple(PanacheEntityBase.class.getName());
+ static final DotName PANACHE_ENTITY_DOTNAME = createSimple(PanacheEntity.class.getName());
+ static final DotName PANACHE_COMPANION_DOTNAME = createSimple(PanacheCompanion.class.getName());
static final String PANACHE_ENTITY_BASE_SIGNATURE = toBinarySignature(PanacheEntityBase.class);
static final String PANACHE_ENTITY_SIGNATURE = toBinarySignature(PanacheEntity.class);
@@ -62,7 +62,6 @@ public final class KotlinPanacheResourceProcessor {
static final String OBJECT_SIGNATURE = toBinarySignature(Object.class);
static final String CLASS_SIGNATURE = toBinarySignature(Class.class);
- static final DotName TRANSIENT = DotName.createSimple(Transient.class.getName());
static final org.objectweb.asm.Type CLASS_TYPE = org.objectweb.asm.Type.getType(Class.class);
static final org.objectweb.asm.Type OBJECT_TYPE = org.objectweb.asm.Type.getType(Object.class);
@@ -73,6 +72,15 @@ public final class KotlinPanacheResourceProcessor {
org.objectweb.asm.Type.getType(PanacheEntityBase.class),
org.objectweb.asm.Type.getType(PanacheEntity.class),
org.objectweb.asm.Type.getType(PanacheCompanion.class));
+ public static final List PRIMITIVE_TYPES = asList(
+ org.objectweb.asm.Type.getType(Void.class),
+ org.objectweb.asm.Type.getType(Boolean.class),
+ org.objectweb.asm.Type.getType(Character.class),
+ org.objectweb.asm.Type.getType(Byte.class),
+ org.objectweb.asm.Type.getType(Short.class),
+ org.objectweb.asm.Type.getType(Integer.class),
+ org.objectweb.asm.Type.getType(Float.class),
+ org.objectweb.asm.Type.getType(Long.class));
static org.objectweb.asm.Type sanitize(org.objectweb.asm.Type[] argumentTypes) {
org.objectweb.asm.Type primitiveReplaced = null;
@@ -90,6 +98,10 @@ static org.objectweb.asm.Type sanitize(org.objectweb.asm.Type[] argumentTypes) {
return primitiveReplaced;
}
+ static org.objectweb.asm.Type autobox(org.objectweb.asm.Type primitive) {
+ return PRIMITIVE_TYPES.get(primitive.getSort());
+ }
+
@NotNull
static String toBinarySignature(Class> type) {
return org.objectweb.asm.Type.getType(type).getDescriptor();
@@ -135,16 +147,16 @@ void build(CombinedIndexBuildItem index,
KotlinPanacheRepositoryEnhancer daoEnhancer = new KotlinPanacheRepositoryEnhancer(index.getIndex());
Set daoClasses = new HashSet<>();
- for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(PANACHE_REPOSITORY_BASE)) {
+ for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(PANACHE_REPOSITORY_BASE_DOTNAME)) {
// Skip PanacheRepository
- if (classInfo.name().equals(PANACHE_REPOSITORY))
+ if (classInfo.name().equals(PANACHE_REPOSITORY_DOTNAME))
continue;
- if (daoEnhancer.skipRepository(classInfo))
+ if (PanacheRepositoryEnhancer.skipRepository(classInfo))
continue;
daoClasses.add(classInfo.name().toString());
}
- for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(PANACHE_REPOSITORY)) {
- if (daoEnhancer.skipRepository(classInfo))
+ for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(PANACHE_REPOSITORY_DOTNAME)) {
+ if (PanacheRepositoryEnhancer.skipRepository(classInfo))
continue;
daoClasses.add(classInfo.name().toString());
}
@@ -159,15 +171,15 @@ void build(CombinedIndexBuildItem index,
// Note that we do this in two passes because for some reason Jandex does not give us subtypes
// of PanacheEntity if we ask for subtypes of PanacheEntityBase
// NOTE: we don't skip abstract/generic entities because they still need accessors
- for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(PANACHE_COMPANION)) {
- if (classInfo.name().equals(PANACHE_ENTITY))
+ for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(PANACHE_COMPANION_DOTNAME)) {
+ if (classInfo.name().equals(PANACHE_ENTITY_DOTNAME))
continue;
if (modelClasses.add(classInfo.name().toString())) {
transformers.produce(new BytecodeTransformerBuildItem(classInfo.name().toString(), companionEnhancer));
}
}
- for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(PANACHE_ENTITY_BASE)) {
- if (classInfo.name().equals(PANACHE_ENTITY))
+ for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(PANACHE_ENTITY_BASE_DOTNAME)) {
+ if (classInfo.name().equals(PANACHE_ENTITY_DOTNAME))
continue;
if (modelClasses.add(classInfo.name().toString())) {
entityEnhancer.collectFields(classInfo);
diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/pom.xml b/extensions/panache/hibernate-orm-panache-kotlin/runtime/pom.xml
index a9890fa2d479b..7b468b79fa036 100644
--- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/pom.xml
+++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/pom.xml
@@ -63,7 +63,6 @@
org.jetbrains.kotlin
kotlin-reflect
${kotlin.version}
- test
org.ow2.asm
diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheCompanion.kt b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheCompanion.kt
index beaf6597c9e6c..c230798d60e58 100644
--- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheCompanion.kt
+++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheCompanion.kt
@@ -56,7 +56,7 @@ interface PanacheCompanion {
fun find(query: String, vararg params: Any): PanacheQuery = injectionMissing()
/**
- * Find entities using a query and the given sort options with optional indexed parameters.
+ * Find entities using a query and the given sort options, with optional indexed parameters.
*
* @param query a query string
* @param sort the sort strategy to use
diff --git a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheHibernateResourceProcessor.java b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheHibernateResourceProcessor.java
index f8b88fad31145..e1c600b6add26 100644
--- a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheHibernateResourceProcessor.java
+++ b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheHibernateResourceProcessor.java
@@ -40,6 +40,7 @@
import io.quarkus.panache.common.deployment.PanacheFieldAccessEnhancer;
import io.quarkus.panache.common.deployment.PanacheMethodCustomizer;
import io.quarkus.panache.common.deployment.PanacheMethodCustomizerBuildItem;
+import io.quarkus.panache.common.deployment.PanacheRepositoryEnhancer;
public final class PanacheHibernateResourceProcessor {
@@ -116,12 +117,12 @@ void build(CombinedIndexBuildItem index,
// Skip PanacheRepository
if (classInfo.name().equals(DOTNAME_PANACHE_REPOSITORY))
continue;
- if (daoEnhancer.skipRepository(classInfo))
+ if (PanacheRepositoryEnhancer.skipRepository(classInfo))
continue;
daoClasses.add(classInfo.name().toString());
}
for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(DOTNAME_PANACHE_REPOSITORY)) {
- if (daoEnhancer.skipRepository(classInfo))
+ if (PanacheRepositoryEnhancer.skipRepository(classInfo))
continue;
daoClasses.add(classInfo.name().toString());
}
diff --git a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaEntityEnhancer.java b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaEntityEnhancer.java
index df2ee5f216cdc..b66738d056c75 100644
--- a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaEntityEnhancer.java
+++ b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaEntityEnhancer.java
@@ -24,7 +24,6 @@
import io.quarkus.panache.common.deployment.MetamodelInfo;
import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
import io.quarkus.panache.common.deployment.PanacheMethodCustomizer;
-import io.quarkus.panache.common.deployment.visitors.PanacheEntityClassVisitor;
public class PanacheJpaEntityEnhancer extends PanacheEntityEnhancer>> {
@@ -42,14 +41,13 @@ public class PanacheJpaEntityEnhancer extends PanacheEntityEnhancer methodCustomizers) {
- super(index, methodCustomizers);
+ super(index, PanacheHibernateResourceProcessor.DOTNAME_PANACHE_ENTITY_BASE, methodCustomizers);
modelInfo = new MetamodelInfo<>();
}
@Override
public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) {
- return new PanacheJpaEntityClassVisitor(className, outputClassVisitor, modelInfo,
- indexView.getClassByName(PanacheHibernateResourceProcessor.DOTNAME_PANACHE_ENTITY_BASE),
+ return new PanacheJpaEntityClassVisitor(className, outputClassVisitor, modelInfo, panacheEntityBaseClassInfo,
indexView.getClassByName(DotName.createSimple(className)), methodCustomizers);
}
@@ -74,7 +72,7 @@ protected String getModelDescriptor() {
}
@Override
- protected String getPanacheOperationsInternalName() {
+ protected String getPanacheOperationsBinaryName() {
return JPA_OPERATIONS_BINARY_NAME;
}
diff --git a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaRepositoryEnhancer.java b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaRepositoryEnhancer.java
index 29ef3e9d485b5..16dace472aeba 100644
--- a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaRepositoryEnhancer.java
+++ b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaRepositoryEnhancer.java
@@ -1,13 +1,14 @@
package io.quarkus.hibernate.orm.panache.deployment;
+import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;
import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.MethodVisitor;
import io.quarkus.hibernate.orm.panache.PanacheRepository;
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
import io.quarkus.panache.common.deployment.PanacheRepositoryEnhancer;
-import io.quarkus.panache.common.deployment.visitors.PanacheRepositoryClassVisitor;
public class PanacheJpaRepositoryEnhancer extends PanacheRepositoryEnhancer {
@@ -21,14 +22,15 @@ public PanacheJpaRepositoryEnhancer(IndexView index) {
@Override
public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) {
- return new PanacheJpaRepositoryClassVisitor(className, outputClassVisitor,
+ return new PanacheJpaRepositoryClassVisitor(className, outputClassVisitor, panacheRepositoryBaseClassInfo,
this.indexView);
}
static class PanacheJpaRepositoryClassVisitor extends PanacheRepositoryClassVisitor {
- public PanacheJpaRepositoryClassVisitor(String className, ClassVisitor outputClassVisitor, IndexView indexView) {
- super(className, outputClassVisitor, indexView);
+ public PanacheJpaRepositoryClassVisitor(String className, ClassVisitor outputClassVisitor,
+ ClassInfo panacheRepositoryBaseClassInfo, IndexView indexView) {
+ super(className, outputClassVisitor, panacheRepositoryBaseClassInfo, indexView);
}
@Override
@@ -42,8 +44,19 @@ protected DotName getPanacheRepositoryBaseDotName() {
}
@Override
- protected String getPanacheOperationsInternalName() {
+ protected String getPanacheOperationsBinaryName() {
return PanacheJpaEntityEnhancer.JPA_OPERATIONS_BINARY_NAME;
}
+
+ @Override
+ protected void injectModel(MethodVisitor mv) {
+ // inject Class
+ mv.visitLdcInsn(entityType);
+ }
+
+ @Override
+ protected String getModelDescriptor() {
+ return "Ljava/lang/Class;";
+ }
}
}
diff --git a/extensions/panache/mongodb-panache-common/deployment/pom.xml b/extensions/panache/mongodb-panache-common/deployment/pom.xml
deleted file mode 100644
index c3c794379512d..0000000000000
--- a/extensions/panache/mongodb-panache-common/deployment/pom.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
- quarkus-mongodb-panache-common-parent
- io.quarkus
- 999-SNAPSHOT
- ../
-
- 4.0.0
-
- quarkus-mongodb-panache-common-deployment
- Quarkus - MongoDB with Panache - Common Deployment
-
-
-
- io.quarkus
- quarkus-core-deployment
-
-
- io.quarkus
- quarkus-jsonb-spi
-
-
- io.quarkus
- quarkus-jackson-spi
-
-
- io.quarkus
- quarkus-panache-common-deployment
-
-
- io.quarkus
- quarkus-mongodb-client-deployment
-
-
- io.quarkus
- quarkus-mongodb-panache-common
-
-
-
- io.quarkus
- quarkus-junit5-internal
- test
-
-
-
-
-
-
- maven-compiler-plugin
-
-
-
- io.quarkus
- quarkus-extension-processor
- ${project.version}
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java b/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java
deleted file mode 100644
index ed1f5649ef18c..0000000000000
--- a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java
+++ /dev/null
@@ -1,384 +0,0 @@
-package io.quarkus.mongodb.panache.deployment;
-
-import static io.quarkus.deployment.util.JandexUtil.resolveTypeParameters;
-import static org.jboss.jandex.DotName.createSimple;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
-
-import org.bson.codecs.pojo.annotations.BsonId;
-import org.bson.codecs.pojo.annotations.BsonIgnore;
-import org.bson.codecs.pojo.annotations.BsonProperty;
-import org.bson.types.ObjectId;
-import org.jboss.jandex.AnnotationInstance;
-import org.jboss.jandex.AnnotationValue;
-import org.jboss.jandex.ClassInfo;
-import org.jboss.jandex.CompositeIndex;
-import org.jboss.jandex.DotName;
-import org.jboss.jandex.FieldInfo;
-import org.jboss.jandex.IndexView;
-import org.jboss.jandex.Indexer;
-import org.jboss.jandex.MethodInfo;
-import org.jboss.jandex.Type;
-
-import io.quarkus.arc.deployment.ValidationPhaseBuildItem;
-import io.quarkus.builder.BuildException;
-import io.quarkus.deployment.annotations.BuildProducer;
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
-import io.quarkus.deployment.bean.JavaBeanUtil;
-import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem;
-import io.quarkus.deployment.builditem.ApplicationIndexBuildItem;
-import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;
-import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
-import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
-import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem;
-import io.quarkus.deployment.index.IndexingUtil;
-import io.quarkus.deployment.util.JandexUtil;
-import io.quarkus.jackson.spi.JacksonModuleBuildItem;
-import io.quarkus.jsonb.spi.JsonbDeserializerBuildItem;
-import io.quarkus.jsonb.spi.JsonbSerializerBuildItem;
-import io.quarkus.mongodb.deployment.MongoClientNameBuildItem;
-import io.quarkus.mongodb.deployment.MongoUnremovableClientsBuildItem;
-import io.quarkus.mongodb.panache.MongoEntity;
-import io.quarkus.mongodb.panache.PanacheMongoRecorder;
-import io.quarkus.mongodb.panache.ProjectionFor;
-import io.quarkus.mongodb.panache.jackson.ObjectIdDeserializer;
-import io.quarkus.mongodb.panache.jackson.ObjectIdSerializer;
-import io.quarkus.panache.common.deployment.PanacheEntityClassesBuildItem;
-import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
-import io.quarkus.panache.common.deployment.PanacheMethodCustomizer;
-import io.quarkus.panache.common.deployment.PanacheMethodCustomizerBuildItem;
-import io.quarkus.panache.common.deployment.PanacheRepositoryEnhancer;
-
-public abstract class BasePanacheMongoResourceProcessor {
- public static final DotName BSON_ID = createSimple(BsonId.class.getName());
- public static final DotName BSON_IGNORE = createSimple(BsonIgnore.class.getName());
- public static final DotName BSON_PROPERTY = createSimple(BsonProperty.class.getName());
- public static final DotName MONGO_ENTITY = createSimple(MongoEntity.class.getName());
- public static final DotName OBJECT_ID = createSimple(ObjectId.class.getName());
- public static final String OBJECT_SIGNATURE = toBinarySignature(Object.class);
- public static final DotName PROJECTION_FOR = createSimple(ProjectionFor.class.getName());
-
- protected static String toBinarySignature(Class> type) {
- return org.objectweb.asm.Type.getType(type).getDescriptor();
- }
-
- @BuildStep
- public void buildImperative(CombinedIndexBuildItem index, ApplicationIndexBuildItem applicationIndex,
- BuildProducer transformers,
- BuildProducer reflectiveClass,
- BuildProducer propertyMappingClass,
- List methodCustomizersBuildItems) {
-
- List methodCustomizers = methodCustomizersBuildItems.stream()
- .map(bi -> bi.getMethodCustomizer()).collect(Collectors.toList());
-
- processTypes(index, transformers, reflectiveClass, propertyMappingClass, getImperativeTypeBundle(),
- createRepositoryEnhancer(index), createEntityEnhancer(index, methodCustomizers));
- }
-
- @BuildStep
- public void buildReactive(CombinedIndexBuildItem index,
- BuildProducer reflectiveClass,
- BuildProducer propertyMappingClass,
- BuildProducer transformers,
- List methodCustomizersBuildItems) {
- List methodCustomizers = methodCustomizersBuildItems.stream()
- .map(bi -> bi.getMethodCustomizer()).collect(Collectors.toList());
-
- processTypes(index, transformers, reflectiveClass, propertyMappingClass, getReactiveTypeBundle(),
- createReactiveRepositoryEnhancer(index), createReactiveEntityEnhancer(index, methodCustomizers));
- }
-
- @BuildStep
- @Record(ExecutionTime.STATIC_INIT)
- protected void buildReplacementMap(List propertyMappingClasses, CombinedIndexBuildItem index,
- PanacheMongoRecorder recorder) {
- Map> replacementMap = new ConcurrentHashMap<>();
- for (PropertyMappingClassBuildStep classToMap : propertyMappingClasses) {
- DotName dotName = createSimple(classToMap.getClassName());
- ClassInfo classInfo = index.getIndex().getClassByName(dotName);
- if (classInfo != null) {
- // only compute field replacement for types inside the index
- Map classReplacementMap = replacementMap.computeIfAbsent(classToMap.getClassName(),
- className -> computeReplacement(classInfo));
- if (classToMap.getAliasClassName() != null) {
- // also register the replacement map for the projection classes
- replacementMap.put(classToMap.getAliasClassName(), classReplacementMap);
- }
- }
- }
-
- recorder.setReplacementCache(replacementMap);
- }
-
- private Map computeReplacement(ClassInfo classInfo) {
- Map replacementMap = new HashMap<>();
- for (FieldInfo field : classInfo.fields()) {
- AnnotationInstance bsonProperty = field.annotation(BSON_PROPERTY);
- if (bsonProperty != null) {
- replacementMap.put(field.name(), bsonProperty.value().asString());
- }
- }
- for (MethodInfo method : classInfo.methods()) {
- if (method.name().startsWith("get")) {
- // we try to replace also for getter
- AnnotationInstance bsonProperty = method.annotation(BSON_PROPERTY);
- if (bsonProperty != null) {
- String fieldName = JavaBeanUtil.decapitalize(method.name().substring(3));
- replacementMap.put(fieldName, bsonProperty.value().asString());
- }
- }
- }
- return replacementMap.isEmpty() ? Collections.emptyMap() : replacementMap;
- }
-
- protected abstract PanacheEntityEnhancer> createEntityEnhancer(CombinedIndexBuildItem index,
- List methodCustomizers);
-
- protected abstract PanacheEntityEnhancer> createReactiveEntityEnhancer(CombinedIndexBuildItem index,
- List methodCustomizers);
-
- protected abstract PanacheRepositoryEnhancer createReactiveRepositoryEnhancer(CombinedIndexBuildItem index);
-
- protected abstract PanacheRepositoryEnhancer createRepositoryEnhancer(CombinedIndexBuildItem index);
-
- private void extractMappings(Map classPropertyMapping, ClassInfo target, CombinedIndexBuildItem index) {
- for (FieldInfo fieldInfo : target.fields()) {
- if (fieldInfo.hasAnnotation(BSON_PROPERTY)) {
- AnnotationInstance bsonProperty = fieldInfo.annotation(BSON_PROPERTY);
- classPropertyMapping.put(fieldInfo.name(), bsonProperty.value().asString());
- }
- }
- for (MethodInfo methodInfo : target.methods()) {
- if (methodInfo.hasAnnotation(BSON_PROPERTY)) {
- AnnotationInstance bsonProperty = methodInfo.annotation(BSON_PROPERTY);
- classPropertyMapping.put(methodInfo.name(), bsonProperty.value().asString());
- }
- }
-
- // climb up the hierarchy of types
- if (!target.superClassType().name().equals(JandexUtil.DOTNAME_OBJECT)) {
- Type superType = target.superClassType();
- ClassInfo superClass = index.getIndex().getClassByName(superType.name());
- extractMappings(classPropertyMapping, superClass, index);
- }
- }
-
- @BuildStep
- protected PanacheEntityClassesBuildItem findEntityClasses(List entityClasses) {
- if (!entityClasses.isEmpty()) {
- Set ret = new HashSet<>();
- for (PanacheMongoEntityClassBuildItem entityClass : entityClasses) {
- ret.add(entityClass.get().name().toString());
- }
- return new PanacheEntityClassesBuildItem(ret);
- }
- return null;
- }
-
- protected abstract TypeBundle getImperativeTypeBundle();
-
- protected abstract TypeBundle getReactiveTypeBundle();
-
- @BuildStep
- protected void handleProjectionFor(CombinedIndexBuildItem index,
- BuildProducer propertyMappingClass,
- BuildProducer transformers) {
- // manage @BsonProperty for the @ProjectionFor annotation
- Map> propertyMapping = new HashMap<>();
- for (AnnotationInstance annotationInstance : index.getIndex().getAnnotations(PROJECTION_FOR)) {
- Type targetClass = annotationInstance.value().asClass();
- ClassInfo target = index.getIndex().getClassByName(targetClass.name());
- Map classPropertyMapping = new HashMap<>();
- extractMappings(classPropertyMapping, target, index);
- propertyMapping.put(targetClass.name(), classPropertyMapping);
- }
- for (AnnotationInstance annotationInstance : index.getIndex().getAnnotations(PROJECTION_FOR)) {
- Type targetClass = annotationInstance.value().asClass();
- Map targetPropertyMapping = propertyMapping.get(targetClass.name());
- if (targetPropertyMapping != null && !targetPropertyMapping.isEmpty()) {
- ClassInfo info = annotationInstance.target().asClass();
- ProjectionForEnhancer fieldEnhancer = new ProjectionForEnhancer(targetPropertyMapping);
- transformers.produce(new BytecodeTransformerBuildItem(info.name().toString(), fieldEnhancer));
- }
-
- // Register for building the property mapping cache
- propertyMappingClass
- .produce(new PropertyMappingClassBuildStep(targetClass.name().toString(),
- annotationInstance.target().asClass().name().toString()));
- }
- }
-
- @BuildStep
- public void mongoClientNames(ApplicationArchivesBuildItem applicationArchivesBuildItem,
- BuildProducer mongoClientName) {
- Set values = new HashSet<>();
- IndexView indexView = applicationArchivesBuildItem.getRootArchive().getIndex();
- Collection instances = indexView.getAnnotations(MONGO_ENTITY);
- for (AnnotationInstance annotation : instances) {
- AnnotationValue clientName = annotation.value("clientName");
- if ((clientName != null) && !clientName.asString().isEmpty()) {
- values.add(clientName.asString());
- }
- }
- for (String value : values) {
- // we don't want the qualifier @MongoClientName qualifier added
- // as these clients will only be looked up programmatically via name
- // see MongoOperations#mongoClient
- mongoClientName.produce(new MongoClientNameBuildItem(value, false));
- }
- }
-
- protected void processEntities(CombinedIndexBuildItem index,
- BuildProducer transformers, BuildProducer reflectiveClass,
- BuildProducer propertyMappingClass,
- PanacheEntityEnhancer> entityEnhancer, TypeBundle typeBundle) {
-
- Set modelClasses = new HashSet<>();
- // Note that we do this in two passes because for some reason Jandex does not give us subtypes
- // of PanacheMongoEntity if we ask for subtypes of PanacheMongoEntityBase
- for (ClassInfo classInfo : index.getIndex().getAllKnownSubclasses(typeBundle.entityBase().dotName())) {
- if (classInfo.name().equals(typeBundle.entity().dotName())) {
- continue;
- }
- if (modelClasses.add(classInfo.name().toString()))
- entityEnhancer.collectFields(classInfo);
- }
- for (ClassInfo classInfo : index.getIndex().getAllKnownSubclasses(typeBundle.entity().dotName())) {
- if (modelClasses.add(classInfo.name().toString()))
- entityEnhancer.collectFields(classInfo);
- }
-
- // iterate over all the entity classes
- for (String modelClass : modelClasses) {
- transformers.produce(new BytecodeTransformerBuildItem(modelClass, entityEnhancer));
-
- //register for reflection entity classes
- reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, modelClass));
-
- // Register for building the property mapping cache
- propertyMappingClass.produce(new PropertyMappingClassBuildStep(modelClass));
- }
- }
-
- protected void processRepositories(CombinedIndexBuildItem index,
- BuildProducer transformers,
- BuildProducer reflectiveClass,
- BuildProducer propertyMappingClass,
- PanacheRepositoryEnhancer repositoryEnhancer, TypeBundle typeBundle) {
-
- Set daoClasses = new HashSet<>();
- Set daoTypeParameters = new HashSet<>();
- for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(typeBundle.repositoryBase().dotName())) {
- // Skip PanacheMongoRepository and abstract repositories
- if (classInfo.name().equals(typeBundle.repository().dotName()) || repositoryEnhancer.skipRepository(classInfo)) {
- continue;
- }
- daoClasses.add(classInfo.name().toString());
- daoTypeParameters.addAll(
- resolveTypeParameters(classInfo.name(), typeBundle.repositoryBase().dotName(), index.getIndex()));
- }
- for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(typeBundle.repository().dotName())) {
- if (repositoryEnhancer.skipRepository(classInfo)) {
- continue;
- }
- daoClasses.add(classInfo.name().toString());
- daoTypeParameters.addAll(
- resolveTypeParameters(classInfo.name(), typeBundle.repositoryBase().dotName(), index.getIndex()));
- }
- for (String daoClass : daoClasses) {
- transformers.produce(new BytecodeTransformerBuildItem(daoClass, repositoryEnhancer));
- }
-
- for (Type parameterType : daoTypeParameters) {
- // Register for reflection the type parameters of the repository: this should be the entity class and the ID class
- reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, parameterType.name().toString()));
-
- // Register for building the property mapping cache
- propertyMappingClass.produce(new PropertyMappingClassBuildStep(parameterType.name().toString()));
- }
- }
-
- protected void processTypes(CombinedIndexBuildItem index,
- BuildProducer transformers,
- BuildProducer reflectiveClass,
- BuildProducer propertyMappingClass,
- TypeBundle typeBundle, PanacheRepositoryEnhancer repositoryEnhancer,
- PanacheEntityEnhancer> entityEnhancer) {
-
- processRepositories(index, transformers, reflectiveClass, propertyMappingClass,
- repositoryEnhancer, typeBundle);
- processEntities(index, transformers, reflectiveClass, propertyMappingClass,
- entityEnhancer, typeBundle);
- }
-
- @BuildStep
- protected ReflectiveHierarchyBuildItem registerForReflection(CombinedIndexBuildItem index) {
- Indexer indexer = new Indexer();
- Set additionalIndex = new HashSet<>();
- IndexingUtil.indexClass(ObjectId.class.getName(), indexer, index.getIndex(), additionalIndex,
- BasePanacheMongoResourceProcessor.class.getClassLoader());
- CompositeIndex compositeIndex = CompositeIndex.create(index.getIndex(), indexer.complete());
- Type type = Type.create(OBJECT_ID, Type.Kind.CLASS);
- return new ReflectiveHierarchyBuildItem(type, compositeIndex);
- }
-
- @BuildStep
- protected void registerJacksonSerDeser(BuildProducer customSerDeser) {
- customSerDeser.produce(
- new JacksonModuleBuildItem.Builder("ObjectIdModule")
- .add(ObjectIdSerializer.class.getName(),
- ObjectIdDeserializer.class.getName(),
- ObjectId.class.getName())
- .build());
- }
-
- @BuildStep
- protected void registerJsonbSerDeser(BuildProducer jsonbSerializers,
- BuildProducer jsonbDeserializers) {
- jsonbSerializers
- .produce(new JsonbSerializerBuildItem(io.quarkus.mongodb.panache.jsonb.ObjectIdSerializer.class.getName()));
- jsonbDeserializers
- .produce(new JsonbDeserializerBuildItem(io.quarkus.mongodb.panache.jsonb.ObjectIdDeserializer.class.getName()));
- }
-
- @BuildStep
- public void unremovableClients(BuildProducer unremovable) {
- unremovable.produce(new MongoUnremovableClientsBuildItem());
- }
-
- @BuildStep
- protected ValidationPhaseBuildItem.ValidationErrorBuildItem validate(ValidationPhaseBuildItem validationPhase,
- CombinedIndexBuildItem index) throws BuildException {
- // we verify that no ID fields are defined (via @BsonId) when extending PanacheMongoEntity or ReactivePanacheMongoEntity
- for (AnnotationInstance annotationInstance : index.getIndex().getAnnotations(BSON_ID)) {
- ClassInfo info = JandexUtil.getEnclosingClass(annotationInstance);
- if (JandexUtil.isSubclassOf(index.getIndex(), info,
- getImperativeTypeBundle().entity().dotName())) {
- BuildException be = new BuildException("You provide a MongoDB identifier via @BsonId inside '" + info.name() +
- "' but one is already provided by PanacheMongoEntity, " +
- "your class should extend PanacheMongoEntityBase instead, or use the id provided by PanacheMongoEntity",
- Collections.emptyList());
- return new ValidationPhaseBuildItem.ValidationErrorBuildItem(be);
- } else if (JandexUtil.isSubclassOf(index.getIndex(), info,
- getReactiveTypeBundle().entity().dotName())) {
- BuildException be = new BuildException("You provide a MongoDB identifier via @BsonId inside '" + info.name() +
- "' but one is already provided by ReactivePanacheMongoEntity, " +
- "your class should extend ReactivePanacheMongoEntityBase instead, or use the id provided by ReactivePanacheMongoEntity",
- Collections.emptyList());
- return new ValidationPhaseBuildItem.ValidationErrorBuildItem(be);
- }
- }
- return null;
- }
-}
diff --git a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/ByteCodeType.java b/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/ByteCodeType.java
deleted file mode 100644
index 498bd126b2edd..0000000000000
--- a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/ByteCodeType.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package io.quarkus.mongodb.panache.deployment;
-
-import static org.jboss.jandex.DotName.createSimple;
-import static org.objectweb.asm.Type.getType;
-
-import java.util.StringJoiner;
-
-import org.jboss.jandex.DotName;
-import org.objectweb.asm.Type;
-
-import io.quarkus.deployment.util.AsmUtil;
-
-public class ByteCodeType {
- private final Type type;
-
- public ByteCodeType(Type type) {
- this.type = type;
- }
-
- public ByteCodeType(Class> type) {
- this.type = getType(type);
- }
-
- public ByteCodeType(org.jboss.jandex.Type type) {
- String typeDescriptor = type.kind() == org.jboss.jandex.Type.Kind.PRIMITIVE
- ? type.toString()
- : "L" + type.name().toString().replace('.', '/') + ";";
- this.type = getType(typeDescriptor);
- }
-
- public String descriptor() {
- return type.getDescriptor();
- }
-
- public DotName dotName() {
- return createSimple(type.getClassName());
- }
-
- public String internalName() {
- return type.getInternalName();
- }
-
- @Override
- public String toString() {
- return new StringJoiner(", ", ByteCodeType.class.getSimpleName() + "[", "]")
- .add(type.toString())
- .toString();
- }
-
- public Type type() {
- return this.type;
- }
-
- public ByteCodeType unbox() {
- return new ByteCodeType(AsmUtil.WRAPPER_TO_PRIMITIVE.getOrDefault(type, type));
- }
-}
diff --git a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/TypeBundle.java b/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/TypeBundle.java
deleted file mode 100644
index a0d5f99671896..0000000000000
--- a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/TypeBundle.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package io.quarkus.mongodb.panache.deployment;
-
-public interface TypeBundle {
- ByteCodeType entity();
-
- ByteCodeType entityBase();
-
- ByteCodeType entityBaseCompanion();
-
- ByteCodeType entityCompanion();
-
- ByteCodeType entityCompanionBase();
-
- ByteCodeType operations();
-
- ByteCodeType queryType();
-
- ByteCodeType repository();
-
- ByteCodeType repositoryBase();
-
- ByteCodeType updateType();
-}
diff --git a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/visitors/PanacheMongoEntityClassVisitor.java b/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/visitors/PanacheMongoEntityClassVisitor.java
deleted file mode 100644
index a9448f118af45..0000000000000
--- a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/visitors/PanacheMongoEntityClassVisitor.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package io.quarkus.mongodb.panache.deployment.visitors;
-
-import static io.quarkus.deployment.util.AsmUtil.getDescriptor;
-import static io.quarkus.mongodb.panache.deployment.BasePanacheMongoResourceProcessor.OBJECT_SIGNATURE;
-import static java.util.Arrays.asList;
-import static org.objectweb.asm.Opcodes.CHECKCAST;
-import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
-
-import java.util.List;
-import java.util.StringJoiner;
-import java.util.function.Function;
-
-import org.jboss.jandex.AnnotationInstance;
-import org.jboss.jandex.AnnotationValue;
-import org.jboss.jandex.ClassInfo;
-import org.jboss.jandex.MethodInfo;
-import org.jboss.jandex.Type;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-import io.quarkus.deployment.util.AsmUtil;
-import io.quarkus.mongodb.panache.deployment.ByteCodeType;
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.panache.common.deployment.EntityField;
-import io.quarkus.panache.common.deployment.EntityModel;
-import io.quarkus.panache.common.deployment.MetamodelInfo;
-import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
-import io.quarkus.panache.common.deployment.PanacheMethodCustomizer;
-import io.quarkus.panache.common.deployment.visitors.PanacheEntityClassVisitor;
-
-public class PanacheMongoEntityClassVisitor extends PanacheEntityClassVisitor {
- private static final ByteCodeType CLASS = new ByteCodeType(Class.class);
-
- private final TypeBundle typeBundle;
-
- public PanacheMongoEntityClassVisitor(String className,
- ClassVisitor outputClassVisitor,
- MetamodelInfo> modelInfo,
- ClassInfo panacheEntityBaseClassInfo,
- ClassInfo entityInfo,
- List methodCustomizers,
- TypeBundle typeBundle) {
- super(className, outputClassVisitor, modelInfo, panacheEntityBaseClassInfo, entityInfo, methodCustomizers);
- this.typeBundle = typeBundle;
- }
-
- @Override
- protected void generateMethod(MethodInfo method, AnnotationValue targetReturnTypeErased) {
- String descriptor = AsmUtil.getDescriptor(method, name -> null);
- String signature = AsmUtil.getSignature(method, name -> null);
- List parameters = method.parameters();
-
- MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC,
- method.name(),
- descriptor,
- signature,
- null);
- for (int i = 0; i < parameters.size(); i++) {
- mv.visitParameter(method.parameterName(i), 0 /* modifiers */);
- }
- mv.visitCode();
- for (PanacheMethodCustomizer customizer : methodCustomizers) {
- customizer.customize(thisClass, method, mv);
- }
- mv.visitFieldInsn(Opcodes.GETSTATIC, thisClass.getInternalName(), "operations",
- typeBundle.operations().descriptor());
- injectModel(mv);
- for (int i = 0; i < parameters.size(); i++) {
- mv.visitIntInsn(Opcodes.ALOAD, i);
- }
- invokeOperation(mv, method, method.parameters());
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- }
-
- private void invokeOperation(MethodVisitor mv, MethodInfo method, List parameters) {
- String operationDescriptor;
- Function argMapper = type -> null;
-
- AnnotationInstance bridge = method.annotation(PanacheEntityEnhancer.DOTNAME_GENERATE_BRIDGE);
- AnnotationValue targetReturnTypeErased = bridge.value("targetReturnTypeErased");
- boolean erased = targetReturnTypeErased != null && targetReturnTypeErased.asBoolean();
-
- StringJoiner joiner = new StringJoiner("", "(", ")");
- joiner.add(CLASS.descriptor());
- for (Type parameter : parameters) {
- joiner.add(getDescriptor(parameter, argMapper));
- }
-
- List names = asList(typeBundle.queryType().dotName().toString(),
- typeBundle.updateType().dotName().toString());
- operationDescriptor = joiner +
- (erased || names.contains(method.returnType().name().toString())
- ? OBJECT_SIGNATURE
- : getDescriptor(method.returnType(), argMapper));
-
- mv.visitMethodInsn(INVOKEVIRTUAL, typeBundle.operations().internalName(), method.name(),
- operationDescriptor, false);
- if (method.returnType().kind() != Type.Kind.PRIMITIVE) {
- Type type = method.returnType();
- String cast;
- if (erased) {
- cast = thisClass.getInternalName();
- } else {
- cast = type.name().toString().replace('.', '/');
- }
- mv.visitTypeInsn(CHECKCAST, cast);
- }
- mv.visitInsn(AsmUtil.getReturnInstruction(method.returnType()));
- }
-
- @Override
- protected String getPanacheOperationsInternalName() {
- return typeBundle.operations().internalName();
- }
-
- @Override
- protected void generateAccessorSetField(MethodVisitor mv, EntityField field) {
- mv.visitFieldInsn(Opcodes.PUTFIELD, thisClass.getInternalName(), field.name, field.descriptor);
- }
-
- @Override
- protected void generateAccessorGetField(MethodVisitor mv, EntityField field) {
- mv.visitFieldInsn(Opcodes.GETFIELD, thisClass.getInternalName(), field.name, field.descriptor);
- }
-}
diff --git a/extensions/panache/mongodb-panache-common/pom.xml b/extensions/panache/mongodb-panache-common/pom.xml
deleted file mode 100644
index 9510146247760..0000000000000
--- a/extensions/panache/mongodb-panache-common/pom.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- quarkus-build-parent
- io.quarkus
- 999-SNAPSHOT
- ../../../build-parent/pom.xml
-
- 4.0.0
-
- quarkus-mongodb-panache-common-parent
- Quarkus - MongoDB with Panache - Common
- pom
-
- runtime
- deployment
-
-
\ No newline at end of file
diff --git a/extensions/panache/mongodb-panache-common/runtime/pom.xml b/extensions/panache/mongodb-panache-common/runtime/pom.xml
deleted file mode 100644
index b27a973cba4d0..0000000000000
--- a/extensions/panache/mongodb-panache-common/runtime/pom.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
- quarkus-mongodb-panache-common-parent
- io.quarkus
- 999-SNAPSHOT
- ../
-
- 4.0.0
-
- quarkus-mongodb-panache-common
- Quarkus - MongoDB with Panache - Common Runtime
-
-
-
- io.quarkus
- quarkus-core
-
-
- io.quarkus
- quarkus-panache-common
-
-
- io.quarkus
- quarkus-mongodb-client
-
-
- io.quarkus
- quarkus-panacheql
-
-
-
-
- io.quarkus
- quarkus-jsonb
- true
-
-
-
-
- io.quarkus
- quarkus-jackson
- true
-
-
- org.junit.jupiter
- junit-jupiter
- test
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
-
-
-
-
- maven-compiler-plugin
-
- -proc:none
-
-
-
- io.quarkus
- quarkus-bootstrap-maven-plugin
-
-
-
- org.jboss.jandex
- jandex-maven-plugin
-
-
- make-index
-
- jandex
-
-
-
-
-
-
-
-
-
diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/runtime/CommonReactivePanacheQueryImpl.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/runtime/CommonReactivePanacheQueryImpl.java
deleted file mode 100644
index b767f36126dfa..0000000000000
--- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/runtime/CommonReactivePanacheQueryImpl.java
+++ /dev/null
@@ -1,238 +0,0 @@
-package io.quarkus.mongodb.panache.reactive.runtime;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-
-import org.bson.Document;
-import org.bson.conversions.Bson;
-
-import com.mongodb.client.model.Collation;
-
-import io.quarkus.mongodb.FindOptions;
-import io.quarkus.mongodb.panache.runtime.MongoPropertyUtil;
-import io.quarkus.mongodb.reactive.ReactiveMongoCollection;
-import io.quarkus.panache.common.Page;
-import io.quarkus.panache.common.Range;
-import io.quarkus.panache.common.exception.PanacheQueryException;
-import io.smallrye.mutiny.Multi;
-import io.smallrye.mutiny.Uni;
-
-public class CommonReactivePanacheQueryImpl {
- private ReactiveMongoCollection collection;
- private Bson mongoQuery;
- private Bson sort;
- private Bson projections;
-
- private Page page;
- private Uni count;
-
- private Range range;
-
- private Collation collation;
-
- public CommonReactivePanacheQueryImpl(ReactiveMongoCollection extends Entity> collection, Bson mongoQuery, Bson sort) {
- this.collection = collection;
- this.mongoQuery = mongoQuery;
- this.sort = sort;
- }
-
- private CommonReactivePanacheQueryImpl(CommonReactivePanacheQueryImpl previousQuery, Bson projections, Class> type) {
- this.collection = previousQuery.collection.withDocumentClass(type);
- this.mongoQuery = previousQuery.mongoQuery;
- this.sort = previousQuery.sort;
- this.projections = projections;
- this.page = previousQuery.page;
- this.count = previousQuery.count;
- this.range = previousQuery.range;
- this.collation = previousQuery.collation;
- }
-
- // Builder
-
- public CommonReactivePanacheQueryImpl project(Class type) {
- // collect field names from public fields and getters
- Set fieldNames = MongoPropertyUtil.collectFields(type);
-
- // create the projection document
- Document projections = new Document();
- for (String fieldName : fieldNames) {
- projections.append(fieldName, 1);
- }
-
- return new CommonReactivePanacheQueryImpl(this, projections, type);
- }
-
- @SuppressWarnings("unchecked")
- public CommonReactivePanacheQueryImpl page(Page page) {
- this.page = page;
- this.range = null; // reset the range to be able to switch from range to page
- return (CommonReactivePanacheQueryImpl) this;
- }
-
- public CommonReactivePanacheQueryImpl page(int pageIndex, int pageSize) {
- return page(Page.of(pageIndex, pageSize));
- }
-
- public CommonReactivePanacheQueryImpl nextPage() {
- checkPagination();
- return page(page.next());
- }
-
- public CommonReactivePanacheQueryImpl previousPage() {
- checkPagination();
- return page(page.previous());
- }
-
- public CommonReactivePanacheQueryImpl firstPage() {
- checkPagination();
- return page(page.first());
- }
-
- public Uni> lastPage() {
- checkPagination();
- Uni> map = pageCount().map(pageCount -> page(page.index(pageCount - 1)));
- return map;
- }
-
- public Uni hasNextPage() {
- checkPagination();
- return pageCount().map(pageCount -> page.index < (pageCount - 1));
- }
-
- public boolean hasPreviousPage() {
- checkPagination();
- return page.index > 0;
- }
-
- public Uni pageCount() {
- checkPagination();
- return count().map(count -> {
- if (count == 0)
- return 1; // a single page of zero results
- return (int) Math.ceil((double) count / (double) page.size);
- });
- }
-
- public Page page() {
- checkPagination();
- return page;
- }
-
- private void checkPagination() {
- if (page == null) {
- throw new UnsupportedOperationException(
- "Cannot call a page related method, "
- + "call page(Page) or page(int, int) to initiate pagination first");
- }
- if (range != null) {
- throw new UnsupportedOperationException("Cannot call a page related method in a ranged query, " +
- "call page(Page) or page(int, int) to initiate pagination first");
- }
- }
-
- public CommonReactivePanacheQueryImpl range(int startIndex, int lastIndex) {
- this.range = Range.of(startIndex, lastIndex);
- // reset the page to its default to be able to switch from page to range
- this.page = null;
- return (CommonReactivePanacheQueryImpl) this;
- }
-
- public CommonReactivePanacheQueryImpl withCollation(Collation collation) {
- this.collation = collation;
- return (CommonReactivePanacheQueryImpl) this;
- }
-
- // Results
-
- @SuppressWarnings("unchecked")
- public Uni count() {
- if (count == null) {
- count = collection.countDocuments(mongoQuery);
- }
- return count;
- }
-
- @SuppressWarnings("unchecked")
- public Uni> list() {
- Multi results = stream();
- return results.collectItems().asList();
- }
-
- @SuppressWarnings("unchecked")
- public Multi stream() {
- FindOptions options = buildOptions();
- return mongoQuery == null ? collection.find(options) : collection.find(mongoQuery, options);
- }
-
- public Uni firstResult() {
- Uni> optionalEntity = firstResultOptional();
- return optionalEntity.map(optional -> optional.orElse(null));
- }
-
- public Uni> firstResultOptional() {
- FindOptions options = buildOptions(1);
- Multi results = mongoQuery == null ? collection.find(options) : collection.find(mongoQuery, options);
- return results.collectItems().first().map(o -> Optional.ofNullable(o));
- }
-
- @SuppressWarnings("unchecked")
- public Uni singleResult() {
- FindOptions options = buildOptions(2);
- Multi results = mongoQuery == null ? collection.find(options) : collection.find(mongoQuery, options);
- return results.collectItems().asList().map(list -> {
- if (list.size() != 1) {
- throw new PanacheQueryException("There should be only one result");
- } else {
- return list.get(0);
- }
- });
- }
-
- public Uni> singleResultOptional() {
- FindOptions options = buildOptions(2);
- Multi results = mongoQuery == null ? collection.find(options) : collection.find(mongoQuery, options);
- return results.collectItems().asList().map(list -> {
- if (list.size() == 2) {
- throw new PanacheQueryException("There should be no more than one result");
- }
- return list.isEmpty() ? Optional.empty() : Optional.of(list.get(0));
- });
- }
-
- private FindOptions buildOptions() {
- FindOptions options = new FindOptions();
- options.sort(sort);
- if (range != null) {
- // range is 0 based, so we add 1 to the limit
- options.skip(range.getStartIndex()).limit(range.getLastIndex() - range.getStartIndex() + 1);
- } else if (page != null) {
- options.skip(page.index * page.size).limit(page.size);
- }
- if (projections != null) {
- options.projection(this.projections);
- }
- if (this.collation != null) {
- options.collation(collation);
- }
- return options;
- }
-
- private FindOptions buildOptions(int maxResults) {
- FindOptions options = new FindOptions();
- options.sort(sort);
- if (range != null) {
- // range is 0 based, so we add 1 to the limit
- options.skip(range.getStartIndex());
- } else if (page != null) {
- options.skip(page.index * page.size);
- }
- if (projections != null) {
- options.projection(this.projections);
- }
- if (this.collation != null) {
- options.collation(collation);
- }
- return options.limit(maxResults);
- }
-}
diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/runtime/CommonPanacheQueryImpl.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/runtime/CommonPanacheQueryImpl.java
deleted file mode 100644
index 84b76af387ca7..0000000000000
--- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/runtime/CommonPanacheQueryImpl.java
+++ /dev/null
@@ -1,229 +0,0 @@
-package io.quarkus.mongodb.panache.runtime;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Stream;
-
-import org.bson.Document;
-import org.bson.conversions.Bson;
-
-import com.mongodb.client.FindIterable;
-import com.mongodb.client.MongoCollection;
-import com.mongodb.client.MongoCursor;
-import com.mongodb.client.model.Collation;
-
-import io.quarkus.panache.common.Page;
-import io.quarkus.panache.common.Range;
-import io.quarkus.panache.common.exception.PanacheQueryException;
-
-public class CommonPanacheQueryImpl {
- private MongoCollection collection;
- private Bson mongoQuery;
- private Bson sort;
- private Bson projections;
-
- private Page page;
- private Long count;
-
- private Range range;
-
- private Collation collation;
-
- public CommonPanacheQueryImpl(MongoCollection extends Entity> collection, Bson mongoQuery, Bson sort) {
- this.collection = collection;
- this.mongoQuery = mongoQuery;
- this.sort = sort;
- }
-
- private CommonPanacheQueryImpl(CommonPanacheQueryImpl> previousQuery, Bson projections, Class> documentClass) {
- this.collection = previousQuery.collection.withDocumentClass(documentClass);
- this.mongoQuery = previousQuery.mongoQuery;
- this.sort = previousQuery.sort;
- this.projections = projections;
- this.page = previousQuery.page;
- this.count = previousQuery.count;
- this.range = previousQuery.range;
- this.collation = previousQuery.collation;
- }
-
- public CommonPanacheQueryImpl project(Class type) {
- // collect field names from public fields and getters
- Set fieldNames = MongoPropertyUtil.collectFields(type);
-
- // create the projection document
- Document projections = new Document();
- for (String fieldName : fieldNames) {
- projections.append(fieldName, 1);
- }
-
- return new CommonPanacheQueryImpl<>(this, projections, type);
- }
-
- @SuppressWarnings("unchecked")
- public CommonPanacheQueryImpl page(Page page) {
- this.page = page;
- this.range = null; // reset the range to be able to switch from range to page
- return (CommonPanacheQueryImpl) this;
- }
-
- public CommonPanacheQueryImpl page(int pageIndex, int pageSize) {
- return page(Page.of(pageIndex, pageSize));
- }
-
- public CommonPanacheQueryImpl nextPage() {
- checkPagination();
- return page(page.next());
- }
-
- public CommonPanacheQueryImpl previousPage() {
- checkPagination();
- return page(page.previous());
- }
-
- public CommonPanacheQueryImpl firstPage() {
- checkPagination();
- return page(page.first());
- }
-
- public CommonPanacheQueryImpl lastPage() {
- checkPagination();
- return page(page.index(pageCount() - 1));
- }
-
- public boolean hasNextPage() {
- checkPagination();
- return page.index < (pageCount() - 1);
- }
-
- public boolean hasPreviousPage() {
- checkPagination();
- return page.index > 0;
- }
-
- public int pageCount() {
- checkPagination();
- long count = count();
- if (count == 0)
- return 1; // a single page of zero results
- return (int) Math.ceil((double) count / (double) page.size);
- }
-
- public Page page() {
- checkPagination();
- return page;
- }
-
- private void checkPagination() {
- if (page == null) {
- throw new UnsupportedOperationException(
- "Cannot call a page related method, "
- + "call page(Page) or page(int, int) to initiate pagination first");
- }
- if (range != null) {
- throw new UnsupportedOperationException("Cannot call a page related method in a ranged query, " +
- "call page(Page) or page(int, int) to initiate pagination first");
- }
- }
-
- public CommonPanacheQueryImpl range(int startIndex, int lastIndex) {
- this.range = Range.of(startIndex, lastIndex);
- // reset the page to its default to be able to switch from page to range
- this.page = null;
- return (CommonPanacheQueryImpl) this;
- }
-
- public CommonPanacheQueryImpl withCollation(Collation collation) {
- this.collation = collation;
- return (CommonPanacheQueryImpl) this;
- }
-
- // Results
-
- @SuppressWarnings("unchecked")
- public long count() {
- if (count == null) {
- count = collection.countDocuments(mongoQuery);
- }
- return count;
- }
-
- public List list() {
- return list(null);
- }
-
- @SuppressWarnings("unchecked")
- private List list(Integer limit) {
- List list = new ArrayList<>();
- FindIterable find = mongoQuery == null ? collection.find() : collection.find(mongoQuery);
- if (this.projections != null) {
- find.projection(projections);
- }
- if (this.collation != null) {
- find.collation(collation);
- }
- manageOffsets(find, limit);
- MongoCursor cursor = find.sort(sort).iterator();
-
- try {
- while (cursor.hasNext()) {
- T entity = cursor.next();
- list.add(entity);
- }
- } finally {
- cursor.close();
- }
- return list;
- }
-
- @SuppressWarnings("unchecked")
- public Stream stream() {
- return (Stream) list().stream();
- }
-
- public T firstResult() {
- List list = list(1);
- return list.isEmpty() ? null : list.get(0);
- }
-
- public Optional firstResultOptional() {
- return Optional.ofNullable(firstResult());
- }
-
- public T singleResult() {
- List list = list(2);
- if (list.size() != 1) {
- throw new PanacheQueryException("There should be only one result");
- }
-
- return list.get(0);
- }
-
- public Optional singleResultOptional() {
- List list = list(2);
- if (list.size() > 1) {
- throw new PanacheQueryException("There should be no more than one result");
- }
-
- return list.isEmpty() ? Optional.empty() : Optional.of(list.get(0));
- }
-
- private void manageOffsets(FindIterable find, Integer limit) {
- if (range != null) {
- find.skip(range.getStartIndex());
- if (limit == null) {
- // range is 0 based, so we add 1 to the limit
- find.limit(range.getLastIndex() - range.getStartIndex() + 1);
- }
- } else if (page != null) {
- find.skip(page.index * page.size);
- if (limit == null) {
- find.limit(page.size);
- }
- }
- if (limit != null) {
- find.limit(limit);
- }
- }
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/pom.xml b/extensions/panache/mongodb-panache-kotlin/deployment/pom.xml
deleted file mode 100644
index d5f09d2c73332..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/pom.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
- quarkus-mongodb-panache-kotlin-parent
- io.quarkus
- 999-SNAPSHOT
- ../
-
- 4.0.0
-
- quarkus-mongodb-panache-kotlin-deployment
- Quarkus - MongoDB with Panache - Kotlin Deployment
-
-
-
- io.quarkus
- quarkus-mongodb-panache-kotlin
-
-
- io.quarkus
- quarkus-mongodb-panache-common-deployment
-
-
- io.quarkus
- quarkus-mongodb-client-deployment
-
-
- io.quarkus
- quarkus-jsonb-spi
-
-
- io.quarkus
- quarkus-jackson-spi
-
-
-
- io.quarkus
- quarkus-junit5-internal
- test
-
-
-
-
-
-
- maven-compiler-plugin
-
-
-
- io.quarkus
- quarkus-extension-processor
- ${project.version}
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinGenerator.java b/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinGenerator.java
deleted file mode 100644
index 51967b9c7d08b..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinGenerator.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.deployment;
-
-import static io.quarkus.deployment.util.AsmUtil.getDescriptor;
-import static io.quarkus.deployment.util.AsmUtil.getSignature;
-import static io.quarkus.mongodb.panache.deployment.BasePanacheMongoResourceProcessor.OBJECT_SIGNATURE;
-import static java.util.Arrays.asList;
-import static org.objectweb.asm.Opcodes.ALOAD;
-import static org.objectweb.asm.Opcodes.CHECKCAST;
-import static org.objectweb.asm.Opcodes.GETSTATIC;
-import static org.objectweb.asm.Opcodes.ILOAD;
-import static org.objectweb.asm.Opcodes.INVOKESTATIC;
-import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
-import static org.objectweb.asm.Type.ARRAY;
-import static org.objectweb.asm.Type.getMethodDescriptor;
-import static org.objectweb.asm.Type.getType;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.StringJoiner;
-import java.util.function.Function;
-
-import org.jboss.jandex.AnnotationInstance;
-import org.jboss.jandex.AnnotationValue;
-import org.jboss.jandex.ClassInfo;
-import org.jboss.jandex.DotName;
-import org.jboss.jandex.IndexView;
-import org.jboss.jandex.MethodInfo;
-import org.jboss.jandex.Type;
-import org.jetbrains.annotations.NotNull;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-import io.quarkus.deployment.util.AsmUtil;
-import io.quarkus.deployment.util.JandexUtil;
-import io.quarkus.mongodb.panache.deployment.ByteCodeType;
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
-
-public class KotlinGenerator {
- public static final ByteCodeType NOT_NULL = new ByteCodeType(NotNull.class);
- private static final ByteCodeType CLASS = new ByteCodeType(Class.class);
-
- private final Function argMapper;
- private final ClassVisitor cv;
- private final List methods = new ArrayList<>();
- private final Map typeArguments;
- private final TypeBundle types;
- private final Map typeParameters;
-
- public KotlinGenerator(ClassVisitor classVisitor, Map typeParameters,
- Map typeArguments, TypeBundle types) {
- this.cv = classVisitor;
- this.typeParameters = typeParameters;
- this.typeArguments = typeArguments;
- this.types = types;
- this.argMapper = type -> typeArguments.get(type);
- }
-
- public static ByteCodeType[] findEntityTypeArguments(IndexView indexView, String repositoryClassName,
- DotName repositoryDotName) {
- for (ClassInfo classInfo : indexView.getAllKnownImplementors(repositoryDotName)) {
- if (repositoryClassName.equals(classInfo.name().toString())) {
- return recursivelyFindEntityTypeArguments(indexView, classInfo.name(), repositoryDotName);
- }
- }
-
- return null;
- }
-
- public static ByteCodeType[] recursivelyFindEntityTypeArguments(IndexView indexView, DotName clazz,
- DotName repositoryDotName) {
- if (clazz.equals(JandexUtil.DOTNAME_OBJECT)) {
- return null;
- }
-
- List typeParameters = JandexUtil
- .resolveTypeParameters(clazz, repositoryDotName, indexView);
- if (typeParameters.isEmpty())
- throw new IllegalStateException(
- "Failed to find supertype " + repositoryDotName + " from entity class " + clazz);
- return new ByteCodeType[] {
- new ByteCodeType(typeParameters.get(0)),
- new ByteCodeType(typeParameters.get(1))
- };
- }
-
- public void add(MethodInfo methodInfo) {
- methods.add(methodInfo);
- }
-
- private void addNullityChecks(MethodVisitor mv, List parameters) {
- for (int i = 0; i < parameters.size(); i++) {
- Type parameter = parameters.get(i);
- if (parameter.hasAnnotation(NOT_NULL.dotName())) {
- mv.visitVarInsn(ALOAD, i + 1);
- mv.visitLdcInsn(parameter.name());
- mv.visitMethodInsn(INVOKESTATIC, "kotlin/jvm/internal/Intrinsics", "checkParameterIsNotNull",
- "(Ljava/lang/Object;Ljava/lang/String;)V", false);
- }
- }
- }
-
- public void generate() {
- methods.forEach(m -> generate(m));
- }
-
- public void generate(MethodInfo method) {
- // Note: we can't use SYNTHETIC here because otherwise Mockito will never mock these methods
- MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC, method.name(),
- getDescriptor(method, argMapper), getSignature(method, argMapper), null);
-
- List parameters = method.parameters();
- for (int i = 0; i < parameters.size(); i++) {
- mv.visitParameter(method.parameterName(i), 0 /* modifiers */);
- }
-
- addNullityChecks(mv, parameters);
-
- loadOperationsReference(mv);
-
- loadArguments(mv, parameters);
- invokeOperation(mv, method, parameters);
-
- mv.visitMaxs(parameters.size() + 1, parameters.size());
-
- for (int i = 0; i < parameters.size(); i++) {
- Type argument = parameters.get(i);
- for (AnnotationInstance annotation : argument.annotations()) {
- mv.visitParameterAnnotation(i, "L" + annotation.name() + ";", true);
- }
- }
- }
-
- private void invokeOperation(MethodVisitor mv, MethodInfo method, List parameters) {
- String operationDescriptor;
-
- AnnotationInstance bridge = method.annotation(PanacheEntityEnhancer.DOTNAME_GENERATE_BRIDGE);
- AnnotationValue targetReturnTypeErased = bridge.value("targetReturnTypeErased");
- boolean erased = targetReturnTypeErased != null && targetReturnTypeErased.asBoolean();
-
- StringJoiner joiner = new StringJoiner("", "(", ")");
- joiner.add(CLASS.descriptor());
- for (Type parameter : parameters) {
- if (parameter.kind() != Type.Kind.PRIMITIVE) {
- String descriptor = getDescriptor(parameter, argMapper);
- if (typeArguments.containsValue(descriptor)) {
- descriptor = OBJECT_SIGNATURE;
- }
- joiner.add(descriptor);
- } else {
- joiner.add(OBJECT_SIGNATURE);
- }
- }
-
- List names = asList(types.queryType().dotName().toString(), types.updateType().dotName().toString());
- operationDescriptor = joiner +
- (erased || names.contains(method.returnType().name().toString())
- ? OBJECT_SIGNATURE
- : getDescriptor(method.returnType(), argMapper));
-
- mv.visitMethodInsn(INVOKEVIRTUAL, types.operations().internalName(), method.name(),
- operationDescriptor, false);
- if (method.returnType().kind() != Type.Kind.PRIMITIVE) {
- Type type = method.returnType();
- String cast;
- if (type.kind() == Type.Kind.TYPE_VARIABLE) {
- String applied = argMapper.apply(type.asTypeVariable().identifier());
- cast = applied.substring(1, applied.length() - 1);
- } else {
- cast = type.name().toString().replace('.', '/');
- }
- mv.visitTypeInsn(CHECKCAST, cast);
- }
- mv.visitInsn(AsmUtil.getReturnInstruction(method.returnType()));
- }
-
- private void loadArguments(MethodVisitor mv, List parameters) {
- mv.visitLdcInsn(org.objectweb.asm.Type.getType(typeArguments.get("Entity")));
- for (int i = 0; i < parameters.size(); i++) {
- Type methodParameter = parameters.get(i);
- org.objectweb.asm.Type parameter;
- if (methodParameter.kind() == Type.Kind.TYPE_VARIABLE) {
- parameter = typeParameters.get(parameters.get(i).asTypeVariable().identifier()).type();
- } else {
- parameter = getType(getDescriptor(methodParameter, s -> null));
- }
- mv.visitVarInsn(parameter.getOpcode(ILOAD), i + 1);
- if (parameter.getSort() < ARRAY) {
- org.objectweb.asm.Type wrapper = AsmUtil.autobox(parameter);
- mv.visitMethodInsn(INVOKESTATIC, wrapper.getInternalName(), "valueOf",
- getMethodDescriptor(wrapper, parameter), false);
- }
-
- }
- }
-
- private void loadOperationsReference(MethodVisitor mv) {
- mv.visitFieldInsn(GETSTATIC, types.entityBase().internalName(), "Companion",
- types.entityBaseCompanion().descriptor());
- mv.visitMethodInsn(INVOKEVIRTUAL, types.entityBaseCompanion().internalName(), "getOperations",
- "()" + types.operations().descriptor(), false);
- }
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinImperativeTypeBundle.java b/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinImperativeTypeBundle.java
deleted file mode 100644
index 9cc932c72e32c..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinImperativeTypeBundle.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.deployment;
-
-import io.quarkus.mongodb.panache.PanacheUpdate;
-import io.quarkus.mongodb.panache.deployment.ByteCodeType;
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.mongodb.panache.kotlin.PanacheMongoCompanion;
-import io.quarkus.mongodb.panache.kotlin.PanacheMongoCompanionBase;
-import io.quarkus.mongodb.panache.kotlin.PanacheMongoEntity;
-import io.quarkus.mongodb.panache.kotlin.PanacheMongoEntityBase;
-import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepository;
-import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepositoryBase;
-import io.quarkus.mongodb.panache.kotlin.PanacheQuery;
-import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations;
-
-class KotlinImperativeTypeBundle implements TypeBundle {
-
- @Override
- public ByteCodeType entity() {
- return new ByteCodeType(PanacheMongoEntity.class);
- }
-
- @Override
- public ByteCodeType entityBase() {
- return new ByteCodeType(PanacheMongoEntityBase.class);
- }
-
- @Override
- public ByteCodeType entityBaseCompanion() {
- return new ByteCodeType(PanacheMongoEntityBase.Companion.class);
- }
-
- @Override
- public ByteCodeType entityCompanion() {
- return new ByteCodeType(PanacheMongoCompanion.class);
- }
-
- @Override
- public ByteCodeType entityCompanionBase() {
- return new ByteCodeType(PanacheMongoCompanionBase.class);
- }
-
- @Override
- public ByteCodeType operations() {
- return new ByteCodeType(KotlinMongoOperations.class);
- }
-
- @Override
- public ByteCodeType queryType() {
- return new ByteCodeType(PanacheQuery.class);
- }
-
- @Override
- public ByteCodeType repository() {
- return new ByteCodeType(PanacheMongoRepository.class);
- }
-
- @Override
- public ByteCodeType repositoryBase() {
- return new ByteCodeType(PanacheMongoRepositoryBase.class);
- }
-
- @Override
- public ByteCodeType updateType() {
- return new ByteCodeType(PanacheUpdate.class);
- }
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinPanacheMongoEntityEnhancer.java b/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinPanacheMongoEntityEnhancer.java
deleted file mode 100644
index e2eda00f666ed..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinPanacheMongoEntityEnhancer.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.deployment;
-
-import static io.quarkus.mongodb.panache.deployment.BasePanacheMongoResourceProcessor.BSON_IGNORE;
-
-import java.lang.reflect.Modifier;
-import java.util.List;
-
-import org.jboss.jandex.ClassInfo;
-import org.jboss.jandex.DotName;
-import org.jboss.jandex.FieldInfo;
-import org.jboss.jandex.IndexView;
-import org.objectweb.asm.ClassVisitor;
-
-import io.quarkus.gizmo.DescriptorUtils;
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.mongodb.panache.deployment.visitors.PanacheMongoEntityClassVisitor;
-import io.quarkus.panache.common.deployment.EntityField;
-import io.quarkus.panache.common.deployment.EntityModel;
-import io.quarkus.panache.common.deployment.MetamodelInfo;
-import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
-import io.quarkus.panache.common.deployment.PanacheMethodCustomizer;
-
-public class KotlinPanacheMongoEntityEnhancer extends PanacheEntityEnhancer>> {
- private final TypeBundle types;
-
- public KotlinPanacheMongoEntityEnhancer(IndexView index, List methodCustomizers,
- TypeBundle types) {
- super(index, methodCustomizers);
- modelInfo = new MetamodelInfo<>();
- this.types = types;
- }
-
- @Override
- public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) {
- return new PanacheMongoEntityClassVisitor(className, outputClassVisitor, this.modelInfo,
- this.indexView.getClassByName(this.types.entityBase().dotName()),
- this.indexView.getClassByName(DotName.createSimple(className)),
- this.methodCustomizers, this.types);
- }
-
- @Override
- public void collectFields(ClassInfo classInfo) {
- EntityModel entityModel = new EntityModel<>(classInfo);
- for (FieldInfo fieldInfo : classInfo.fields()) {
- String name = fieldInfo.name();
- if (Modifier.isPublic(fieldInfo.flags())
- && !Modifier.isStatic(fieldInfo.flags())
- && !fieldInfo.hasAnnotation(BSON_IGNORE)) {
- entityModel.addField(new EntityField(name, DescriptorUtils.typeToString(fieldInfo.type())));
- }
- }
- modelInfo.addEntityModel(entityModel);
- }
-
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinPanacheMongoRepositoryEnhancer.java b/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinPanacheMongoRepositoryEnhancer.java
deleted file mode 100644
index 210de669dd7f8..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinPanacheMongoRepositoryEnhancer.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.deployment;
-
-import org.jboss.jandex.ClassInfo;
-import org.jboss.jandex.IndexView;
-import org.objectweb.asm.ClassVisitor;
-
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.mongodb.panache.kotlin.deployment.visitors.KotlinPanacheMongoRepositoryClassVisitor;
-import io.quarkus.panache.common.deployment.PanacheRepositoryEnhancer;
-
-public class KotlinPanacheMongoRepositoryEnhancer extends PanacheRepositoryEnhancer {
- private TypeBundle types;
-
- public KotlinPanacheMongoRepositoryEnhancer(IndexView index, TypeBundle types) {
- super(index, types.repositoryBase().dotName());
- this.types = types;
- }
-
- @Override
- public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) {
- return new KotlinPanacheMongoRepositoryClassVisitor(this.indexView, outputClassVisitor, className, types);
- }
-
- @Override
- public boolean skipRepository(ClassInfo classInfo) {
- return false;
- }
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinPanacheMongoResourceProcessor.java b/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinPanacheMongoResourceProcessor.java
deleted file mode 100644
index 6c1c2cd8eede0..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinPanacheMongoResourceProcessor.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.deployment;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.jboss.jandex.ClassInfo;
-
-import io.quarkus.deployment.Capability;
-import io.quarkus.deployment.Feature;
-import io.quarkus.deployment.annotations.BuildProducer;
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.builditem.ApplicationIndexBuildItem;
-import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;
-import io.quarkus.deployment.builditem.CapabilityBuildItem;
-import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
-import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
-import io.quarkus.mongodb.panache.deployment.BasePanacheMongoResourceProcessor;
-import io.quarkus.mongodb.panache.deployment.PropertyMappingClassBuildStep;
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
-import io.quarkus.panache.common.deployment.PanacheMethodCustomizer;
-import io.quarkus.panache.common.deployment.PanacheMethodCustomizerBuildItem;
-import io.quarkus.panache.common.deployment.PanacheRepositoryEnhancer;
-
-public class KotlinPanacheMongoResourceProcessor extends BasePanacheMongoResourceProcessor {
- public static final KotlinImperativeTypeBundle IMPERATIVE_TYPE_BUNDLE = new KotlinImperativeTypeBundle();
- public static final KotlinReactiveTypeBundle REACTIVE_TYPE_BUNDLE = new KotlinReactiveTypeBundle();
-
- @BuildStep
- public void buildImperativeCompanions(CombinedIndexBuildItem index, ApplicationIndexBuildItem applicationIndex,
- BuildProducer transformers,
- BuildProducer reflectiveClass,
- BuildProducer propertyMappingClass,
- List methodCustomizersBuildItems) {
-
- List methodCustomizers = methodCustomizersBuildItems.stream()
- .map(bi -> bi.getMethodCustomizer()).collect(Collectors.toList());
-
- processCompanions(index, transformers, reflectiveClass, propertyMappingClass,
- createCompanionEnhancer(index, methodCustomizers),
- getImperativeTypeBundle());
- }
-
- @BuildStep
- public void buildReactiveCompanions(CombinedIndexBuildItem index,
- BuildProducer reflectiveClass,
- BuildProducer propertyMappingClass,
- BuildProducer transformers,
- List methodCustomizersBuildItems) {
-
- List methodCustomizers = methodCustomizersBuildItems.stream()
- .map(bi -> bi.getMethodCustomizer()).collect(Collectors.toList());
-
- processCompanions(index, transformers, reflectiveClass, propertyMappingClass,
- createReactiveCompanionEnhancer(index, methodCustomizers),
- getReactiveTypeBundle());
- }
-
- protected KotlinImperativeTypeBundle getImperativeTypeBundle() {
- return IMPERATIVE_TYPE_BUNDLE;
- }
-
- protected KotlinReactiveTypeBundle getReactiveTypeBundle() {
- return REACTIVE_TYPE_BUNDLE;
- }
-
- @BuildStep
- protected CapabilityBuildItem capability() {
- return new CapabilityBuildItem(Capability.MONGODB_PANACHE_KOTLIN);
- }
-
- @BuildStep
- protected FeatureBuildItem featureBuildItem() {
- return new FeatureBuildItem(Feature.MONGODB_PANACHE_KOTLIN);
- }
-
- @Override
- public PanacheEntityEnhancer> createEntityEnhancer(CombinedIndexBuildItem index,
- List methodCustomizers) {
- return new KotlinPanacheMongoEntityEnhancer(index.getIndex(), methodCustomizers, getImperativeTypeBundle());
- }
-
- private PanacheMongoCompanionEnhancer createCompanionEnhancer(CombinedIndexBuildItem index,
- List methodCustomizers) {
- return new PanacheMongoCompanionEnhancer(index.getIndex(), methodCustomizers, getImperativeTypeBundle());
- }
-
- private PanacheMongoCompanionEnhancer createReactiveCompanionEnhancer(CombinedIndexBuildItem index,
- List methodCustomizers) {
- return new PanacheMongoCompanionEnhancer(index.getIndex(), methodCustomizers, getReactiveTypeBundle());
- }
-
- @Override
- public PanacheEntityEnhancer> createReactiveEntityEnhancer(CombinedIndexBuildItem index,
- List methodCustomizers) {
- return new KotlinPanacheMongoEntityEnhancer(index.getIndex(), methodCustomizers, getImperativeTypeBundle());
- }
-
- @Override
- public PanacheRepositoryEnhancer createRepositoryEnhancer(CombinedIndexBuildItem index) {
- return new KotlinPanacheMongoRepositoryEnhancer(index.getIndex(), getImperativeTypeBundle());
- }
-
- @Override
- public PanacheRepositoryEnhancer createReactiveRepositoryEnhancer(CombinedIndexBuildItem index) {
- return new KotlinPanacheMongoRepositoryEnhancer(index.getIndex(), getReactiveTypeBundle());
- }
-
- private void processCompanions(CombinedIndexBuildItem index,
- BuildProducer transformers,
- BuildProducer reflectiveClass,
- BuildProducer propertyMappingClass,
- PanacheEntityEnhancer> entityEnhancer, TypeBundle typeBundle) {
-
- Set modelClasses = new HashSet<>();
- // Note that we do this in two passes because for some reason Jandex does not give us subtypes
- // of PanacheMongoEntity if we ask for subtypes of PanacheMongoEntityBase
- for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(typeBundle.entityCompanionBase().dotName())) {
- if (classInfo.name().equals(typeBundle.entityCompanion().dotName())) {
- continue;
- }
- if (modelClasses.add(classInfo.name().toString()))
- entityEnhancer.collectFields(classInfo);
- }
- for (ClassInfo classInfo : index.getIndex().getAllKnownImplementors(typeBundle.entityCompanion().dotName())) {
- if (modelClasses.add(classInfo.name().toString()))
- entityEnhancer.collectFields(classInfo);
- }
-
- // iterate over all the entity classes
- for (String modelClass : modelClasses) {
- transformers.produce(new BytecodeTransformerBuildItem(modelClass, entityEnhancer));
-
- //register for reflection entity classes
- reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, modelClass));
-
- // Register for building the property mapping cache
- propertyMappingClass.produce(new PropertyMappingClassBuildStep(modelClass));
- }
- }
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinReactiveTypeBundle.java b/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinReactiveTypeBundle.java
deleted file mode 100644
index e5d58c47549a2..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/KotlinReactiveTypeBundle.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.deployment;
-
-import io.quarkus.mongodb.panache.deployment.ByteCodeType;
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoCompanion;
-import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoCompanionBase;
-import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoEntity;
-import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoEntityBase;
-import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoRepository;
-import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoRepositoryBase;
-import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheQuery;
-import io.quarkus.mongodb.panache.kotlin.reactive.runtime.KotlinReactiveMongoOperations;
-import io.quarkus.mongodb.panache.reactive.ReactivePanacheUpdate;
-
-class KotlinReactiveTypeBundle implements TypeBundle {
- @Override
- public ByteCodeType entity() {
- return new ByteCodeType(ReactivePanacheMongoEntity.class);
- }
-
- @Override
- public ByteCodeType entityBase() {
- return new ByteCodeType(ReactivePanacheMongoEntityBase.class);
- }
-
- @Override
- public ByteCodeType entityBaseCompanion() {
- return new ByteCodeType(ReactivePanacheMongoEntityBase.Companion.class);
- }
-
- @Override
- public ByteCodeType entityCompanion() {
- return new ByteCodeType(ReactivePanacheMongoCompanion.class);
- }
-
- @Override
- public ByteCodeType entityCompanionBase() {
- return new ByteCodeType(ReactivePanacheMongoCompanionBase.class);
- }
-
- @Override
- public ByteCodeType operations() {
- return new ByteCodeType(KotlinReactiveMongoOperations.class);
- }
-
- @Override
- public ByteCodeType queryType() {
- return new ByteCodeType(ReactivePanacheQuery.class);
- }
-
- @Override
- public ByteCodeType repository() {
- return new ByteCodeType(ReactivePanacheMongoRepository.class);
- }
-
- @Override
- public ByteCodeType repositoryBase() {
- return new ByteCodeType(ReactivePanacheMongoRepositoryBase.class);
- }
-
- @Override
- public ByteCodeType updateType() {
- return new ByteCodeType(ReactivePanacheUpdate.class);
- }
-
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/PanacheMongoCompanionEnhancer.java b/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/PanacheMongoCompanionEnhancer.java
deleted file mode 100644
index 176d7cd5b328d..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/PanacheMongoCompanionEnhancer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.deployment;
-
-import static io.quarkus.mongodb.panache.deployment.BasePanacheMongoResourceProcessor.BSON_IGNORE;
-
-import java.lang.reflect.Modifier;
-import java.util.List;
-
-import org.jboss.jandex.ClassInfo;
-import org.jboss.jandex.DotName;
-import org.jboss.jandex.FieldInfo;
-import org.jboss.jandex.IndexView;
-import org.objectweb.asm.ClassVisitor;
-
-import io.quarkus.gizmo.DescriptorUtils;
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.mongodb.panache.kotlin.deployment.visitors.PanacheMongoCompanionClassVisitor;
-import io.quarkus.panache.common.deployment.EntityField;
-import io.quarkus.panache.common.deployment.EntityModel;
-import io.quarkus.panache.common.deployment.MetamodelInfo;
-import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
-import io.quarkus.panache.common.deployment.PanacheMethodCustomizer;
-
-public class PanacheMongoCompanionEnhancer extends PanacheEntityEnhancer>> {
- private TypeBundle types;
-
- public PanacheMongoCompanionEnhancer(IndexView index, List methodCustomizers,
- TypeBundle types) {
- super(index, methodCustomizers);
- this.types = types;
- modelInfo = new MetamodelInfo<>();
- }
-
- @Override
- public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) {
- return new PanacheMongoCompanionClassVisitor(outputClassVisitor,
- indexView.getClassByName(DotName.createSimple(className)), indexView, types);
- }
-
- @Override
- public void collectFields(ClassInfo classInfo) {
- EntityModel entityModel = new EntityModel<>(classInfo);
- for (FieldInfo fieldInfo : classInfo.fields()) {
- String name = fieldInfo.name();
- if (Modifier.isPublic(fieldInfo.flags())
- && !Modifier.isStatic(fieldInfo.flags())
- && !fieldInfo.hasAnnotation(BSON_IGNORE)) {
- entityModel.addField(new EntityField(name, DescriptorUtils.typeToString(fieldInfo.type())));
- }
- }
- modelInfo.addEntityModel(entityModel);
- }
-
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/visitors/KotlinPanacheMongoRepositoryClassVisitor.java b/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/visitors/KotlinPanacheMongoRepositoryClassVisitor.java
deleted file mode 100644
index 6be6cd5574f47..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/visitors/KotlinPanacheMongoRepositoryClassVisitor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.deployment.visitors;
-
-import static io.quarkus.deployment.util.AsmUtil.getDescriptor;
-import static io.quarkus.mongodb.panache.kotlin.deployment.KotlinGenerator.findEntityTypeArguments;
-
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.jboss.jandex.AnnotationValue;
-import org.jboss.jandex.DotName;
-import org.jboss.jandex.IndexView;
-import org.jboss.jandex.MethodInfo;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.MethodVisitor;
-
-import io.quarkus.mongodb.panache.deployment.ByteCodeType;
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.mongodb.panache.kotlin.deployment.KotlinGenerator;
-import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
-import io.quarkus.panache.common.deployment.visitors.PanacheRepositoryClassVisitor;
-
-public class KotlinPanacheMongoRepositoryClassVisitor extends PanacheRepositoryClassVisitor {
- private final TypeBundle types;
- private KotlinGenerator generator;
- final Map toGenerate = new TreeMap<>();
- final Map toElide = new TreeMap<>();
-
- public KotlinPanacheMongoRepositoryClassVisitor(IndexView indexView, ClassVisitor outputClassVisitor, String className,
- TypeBundle types) {
- super(className, outputClassVisitor, indexView);
- this.types = types;
- }
-
- @Override
- protected final DotName getPanacheRepositoryDotName() {
- return types.repository().dotName();
- }
-
- @Override
- protected final DotName getPanacheRepositoryBaseDotName() {
- return types.repositoryBase().dotName();
- }
-
- @Override
- protected final String getPanacheOperationsInternalName() {
- return types.operations().internalName();
- }
-
- @Override
- public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
- super.visit(version, access, name, signature, superName, interfaces);
- final String repositoryClassName = name.replace('/', '.');
-
- ByteCodeType[] foundTypeArguments = findEntityTypeArguments(indexView, repositoryClassName,
- getPanacheRepositoryBaseDotName());
-
- ByteCodeType idType = foundTypeArguments[1].unbox();
- typeArguments.put("Id", idType.descriptor());
-
- Map typeParameters = new HashMap<>();
- typeParameters.put("Entity", foundTypeArguments[0]);
- typeParameters.put("Id", idType);
-
- daoClassInfo
- .methods()
- .forEach(method -> {
- String descriptor = getDescriptor(method, m -> null);
- if (method.hasAnnotation(PanacheEntityEnhancer.DOTNAME_GENERATE_BRIDGE)) {
- toGenerate.put(method.name() + descriptor, method);
- toElide.put(method.name() + descriptor, method);
- }
- });
- generator = new KotlinGenerator(this.cv, typeParameters, typeArguments, types);
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name, String descriptor, String signature,
- String[] exceptions) {
- MethodInfo methodInfo = toGenerate.get(name + descriptor);
- if (methodInfo == null) {
- if (toElide.get(name + descriptor) == null) {
- return super.visitMethod(access, name, descriptor, signature, exceptions);
- }
- } else {
- if (Modifier.isAbstract(daoClassInfo.flags())
- && methodInfo.hasAnnotation(PanacheEntityEnhancer.DOTNAME_GENERATE_BRIDGE)) {
- userMethods.add(name + "/" + descriptor);
- }
- }
-
- return null;
- }
-
- @Override
- protected void generateModelBridge(MethodInfo method, AnnotationValue targetReturnTypeErased) {
- generator.generate(method);
- }
-
- @Override
- protected void generateJvmBridge(MethodInfo method) {
- if (!Modifier.isAbstract(daoClassInfo.flags())) {
- super.generateJvmBridge(method);
- }
- }
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/visitors/PanacheMongoCompanionClassVisitor.java b/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/visitors/PanacheMongoCompanionClassVisitor.java
deleted file mode 100644
index 338476bb56d3a..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/deployment/src/main/java/io/quarkus/mongodb/panache/kotlin/deployment/visitors/PanacheMongoCompanionClassVisitor.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.deployment.visitors;
-
-import static io.quarkus.gizmo.Gizmo.ASM_API_VERSION;
-import static org.jboss.jandex.DotName.createSimple;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringJoiner;
-import java.util.TreeMap;
-
-import org.jboss.jandex.ClassInfo;
-import org.jboss.jandex.IndexView;
-import org.jboss.jandex.MethodInfo;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.MethodVisitor;
-
-import io.quarkus.deployment.util.AsmUtil;
-import io.quarkus.mongodb.panache.deployment.ByteCodeType;
-import io.quarkus.mongodb.panache.deployment.TypeBundle;
-import io.quarkus.mongodb.panache.kotlin.deployment.KotlinGenerator;
-import io.quarkus.panache.common.deployment.PanacheEntityEnhancer;
-
-public class PanacheMongoCompanionClassVisitor extends ClassVisitor {
- private final Map bridgeMethods = new TreeMap<>();
- private final IndexView indexView;
- private String entityBinaryType;
- private String entitySignature;
- private KotlinGenerator generator;
- private TypeBundle types;
-
- public PanacheMongoCompanionClassVisitor(ClassVisitor outputClassVisitor, ClassInfo entityInfo, IndexView indexView,
- TypeBundle types) {
- super(ASM_API_VERSION, outputClassVisitor);
- this.indexView = indexView;
- this.types = types;
-
- entityInfo
- .methods()
- .forEach(method -> {
- if (method.hasAnnotation(PanacheEntityEnhancer.DOTNAME_GENERATE_BRIDGE)) {
- bridgeMethods.put(method.name() + AsmUtil.getDescriptor(method, m -> null), method);
- }
- });
- }
-
- @Override
- public String toString() {
- return new StringJoiner(", ", PanacheMongoCompanionClassVisitor.class.getSimpleName() + "[", "]")
- .add(entityBinaryType)
- .toString();
- }
-
- @Override
- public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
- super.visit(version, access, name, signature, superName, interfaces);
-
- String className = name.replace('.', '/');
-
- ByteCodeType[] foundTypeArguments = KotlinGenerator.recursivelyFindEntityTypeArguments(indexView,
- createSimple(name.replace('/', '.')), types.entityCompanionBase().dotName());
-
- entityBinaryType = className.replace("$Companion", "");
- entitySignature = "L" + entityBinaryType + ";";
-
- Map typeArguments = new HashMap<>();
- typeArguments.put("Entity", entitySignature);
- typeArguments.put("Id", foundTypeArguments[1].descriptor());
-
- Map typeParameters = new HashMap<>();
- typeParameters.put("Entity", foundTypeArguments[0]);
- typeParameters.put("Id", foundTypeArguments[1]);
-
- generator = new KotlinGenerator(this.cv, typeParameters, typeArguments, types);
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
- MethodInfo methodInfo = bridgeMethods.get(name + descriptor);
- if (methodInfo == null) {
- return super.visitMethod(access, name, descriptor, signature, exceptions);
- } else {
- generator.add(methodInfo);
- }
- return null;
- }
-
- @Override
- public void visitEnd() {
- generator.generate();
- if (cv != null) {
- cv.visitEnd();
- }
- }
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/pom.xml b/extensions/panache/mongodb-panache-kotlin/pom.xml
deleted file mode 100644
index 468ddbfb7de9d..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/pom.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- quarkus-build-parent
- io.quarkus
- 999-SNAPSHOT
- ../../../build-parent/pom.xml
-
- 4.0.0
-
- quarkus-mongodb-panache-kotlin-parent
- Quarkus - MongoDB with Panache - Kotlin Parent
- pom
-
- runtime
- deployment
-
-
\ No newline at end of file
diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/pom.xml b/extensions/panache/mongodb-panache-kotlin/runtime/pom.xml
deleted file mode 100644
index 3002360e4ac20..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/runtime/pom.xml
+++ /dev/null
@@ -1,203 +0,0 @@
-
-
-
- quarkus-mongodb-panache-kotlin-parent
- io.quarkus
- 999-SNAPSHOT
- ../
-
- 4.0.0
-
- quarkus-mongodb-panache-kotlin
- Quarkus - MongoDB with Panache - Kotlin Runtime
- Simplify your persistence code for MongoDB via the active record or the repository pattern
-
-
- io.quarkus
- quarkus-core
-
-
- io.quarkus
- quarkus-panache-common
-
-
- io.quarkus
- quarkus-mongodb-panache-common
-
-
-
-
- io.quarkus
- quarkus-jsonb
- true
-
-
-
-
- io.quarkus
- quarkus-jackson
- true
-
-
- org.jetbrains.kotlin
- kotlin-stdlib-jdk8
-
-
- org.junit.jupiter
- junit-jupiter
- test
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
- org.jetbrains.kotlin
- kotlin-reflect
- ${kotlin.version}
- test
-
-
- org.ow2.asm
- asm
- test
-
-
- io.quarkus
- quarkus-mongodb-panache
- test
-
-
- io.quarkus
- quarkus-mongodb-panache-common-deployment
- test
-
-
- io.quarkus.gizmo
- gizmo
- test
-
-
-
-
-
- jcenter
- JCenter
- https://jcenter.bintray.com/
-
-
-
-
-
-
- io.quarkus
- quarkus-bootstrap-maven-plugin
-
-
-
- org.jboss.jandex
- jandex-maven-plugin
-
-
- make-index
-
- jandex
-
-
-
-
-
- org.jetbrains.kotlin
- kotlin-maven-plugin
- ${kotlin.version}
-
-
- compile
- compile
-
- compile
-
-
-
-
-
-
-
-
-
- test-compile
- test-compile
-
- test-compile
-
-
-
-
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- -proc:none
-
-
-
-
- default-compile
- none
-
-
-
- default-testCompile
- none
-
-
- java-compile
- compile
-
- compile
-
-
-
- java-test-compile
- test-compile
- testCompile
-
-
-
-
- org.jetbrains.dokka
- dokka-maven-plugin
- 0.10.1
-
-
- javadoc
- pre-site
-
- dokka
-
-
-
-
- html
-
- src/main/java
- src/main/kotlin
-
-
-
-
- https://docs.oracle.com/javase/8/docs/api/
- https://docs.oracle.com/javase/8/docs/api/package-list
-
-
-
-
-
-
-
diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/java/io/quarkus/mongodb/panache/kotlin/reactive/runtime/ReactivePanacheQueryImpl.java b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/java/io/quarkus/mongodb/panache/kotlin/reactive/runtime/ReactivePanacheQueryImpl.java
deleted file mode 100644
index c68131430b7c7..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/java/io/quarkus/mongodb/panache/kotlin/reactive/runtime/ReactivePanacheQueryImpl.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.reactive.runtime;
-
-import java.util.List;
-
-import org.bson.conversions.Bson;
-
-import com.mongodb.client.model.Collation;
-
-import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheQuery;
-import io.quarkus.mongodb.panache.reactive.runtime.CommonReactivePanacheQueryImpl;
-import io.quarkus.mongodb.reactive.ReactiveMongoCollection;
-import io.quarkus.panache.common.Page;
-import io.smallrye.mutiny.Multi;
-import io.smallrye.mutiny.Uni;
-
-@SuppressWarnings("unchecked")
-public class ReactivePanacheQueryImpl implements ReactivePanacheQuery {
- private final CommonReactivePanacheQueryImpl delegate;
-
- ReactivePanacheQueryImpl(ReactiveMongoCollection extends Entity> collection, Bson mongoQuery, Bson sort) {
- this.delegate = new CommonReactivePanacheQueryImpl<>(collection, mongoQuery, sort);
- }
-
- private ReactivePanacheQueryImpl(CommonReactivePanacheQueryImpl delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public ReactivePanacheQuery project(Class type) {
- return new ReactivePanacheQueryImpl<>(delegate.project(type));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ReactivePanacheQuery page(Page page) {
- delegate.page(page);
- return this;
- }
-
- @Override
- public ReactivePanacheQuery page(int pageIndex, int pageSize) {
- return page(Page.of(pageIndex, pageSize));
- }
-
- @Override
- public ReactivePanacheQuery nextPage() {
- delegate.nextPage();
- return this;
- }
-
- @Override
- public ReactivePanacheQuery previousPage() {
- delegate.previousPage();
- return this;
- }
-
- @Override
- public ReactivePanacheQuery firstPage() {
- delegate.firstPage();
- return this;
- }
-
- @Override
- public Uni> lastPage() {
- Uni> uni = delegate.lastPage();
- return uni.map(q -> this);
- }
-
- @Override
- public Uni hasNextPage() {
- return delegate.hasNextPage();
- }
-
- @Override
- public boolean hasPreviousPage() {
- return delegate.hasPreviousPage();
- }
-
- @Override
- public Uni pageCount() {
- return delegate.pageCount();
- }
-
- @Override
- public Page page() {
- return delegate.page();
- }
-
- @Override
- public ReactivePanacheQuery range(int startIndex, int lastIndex) {
- delegate.range(startIndex, lastIndex);
- return this;
- }
-
- @Override
- public ReactivePanacheQuery withCollation(Collation collation) {
- delegate.withCollation(collation);
- return this;
- }
-
- @Override
- public Uni count() {
- return delegate.count();
- }
-
- @Override
- public Uni> list() {
- return delegate.list();
- }
-
- @Override
- public Multi stream() {
- return delegate.stream();
- }
-
- @Override
- public Uni firstResult() {
- return delegate.firstResult();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Uni singleResult() {
- return delegate.singleResult();
- }
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/java/io/quarkus/mongodb/panache/kotlin/runtime/PanacheQueryImpl.java b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/java/io/quarkus/mongodb/panache/kotlin/runtime/PanacheQueryImpl.java
deleted file mode 100644
index a1d326f9816bc..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/java/io/quarkus/mongodb/panache/kotlin/runtime/PanacheQueryImpl.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin.runtime;
-
-import java.util.List;
-import java.util.stream.Stream;
-
-import org.bson.conversions.Bson;
-
-import com.mongodb.client.MongoCollection;
-import com.mongodb.client.model.Collation;
-
-import io.quarkus.mongodb.panache.kotlin.PanacheQuery;
-import io.quarkus.mongodb.panache.runtime.CommonPanacheQueryImpl;
-import io.quarkus.panache.common.Page;
-
-public class PanacheQueryImpl implements PanacheQuery {
- private final CommonPanacheQueryImpl delegate;
-
- PanacheQueryImpl(MongoCollection extends Entity> collection, Bson mongoQuery, Bson sort) {
- this.delegate = new CommonPanacheQueryImpl<>(collection, mongoQuery, sort);
- }
-
- private PanacheQueryImpl(CommonPanacheQueryImpl delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public PanacheQuery project(Class type) {
- return new PanacheQueryImpl<>(delegate.project(type));
- }
-
- @Override
- public PanacheQuery page(Page page) {
- delegate.page(page);
- return this;
- }
-
- @Override
- public PanacheQuery page(int pageIndex, int pageSize) {
- return page(Page.of(pageIndex, pageSize));
- }
-
- @Override
- public PanacheQuery nextPage() {
- delegate.nextPage();
- return this;
- }
-
- @Override
- public PanacheQuery previousPage() {
- delegate.previousPage();
- return this;
- }
-
- @Override
- public PanacheQuery firstPage() {
- delegate.firstPage();
- return this;
- }
-
- @Override
- public PanacheQuery lastPage() {
- delegate.lastPage();
- return this;
- }
-
- @Override
- public boolean hasNextPage() {
- return delegate.hasNextPage();
- }
-
- @Override
- public boolean hasPreviousPage() {
- return delegate.hasPreviousPage();
- }
-
- @Override
- public int pageCount() {
- return delegate.pageCount();
- }
-
- @Override
- public Page page() {
- return delegate.page();
- }
-
- @Override
- public PanacheQuery range(int startIndex, int lastIndex) {
- delegate.range(startIndex, lastIndex);
- return this;
- }
-
- @Override
- public PanacheQuery withCollation(Collation collation) {
- delegate.withCollation(collation);
- return this;
- }
-
- // Results
-
- @Override
- public long count() {
- return delegate.count();
- }
-
- @Override
- public List list() {
- return delegate.list();
- }
-
- @Override
- public Stream stream() {
- return delegate.stream();
- }
-
- @Override
- public Entity firstResult() {
- return delegate.firstResult();
- }
-
- @Override
- public Entity singleResult() {
- return delegate.singleResult();
- }
-
-}
diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt
deleted file mode 100644
index ed893fd7cc9d5..0000000000000
--- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt
+++ /dev/null
@@ -1,702 +0,0 @@
-package io.quarkus.mongodb.panache.kotlin
-
-import com.mongodb.client.MongoCollection
-import com.mongodb.client.MongoDatabase
-import io.quarkus.mongodb.panache.kotlin.PanacheMongoEntityBase.Companion.operations
-import io.quarkus.mongodb.panache.PanacheUpdate
-import io.quarkus.panache.common.Parameters
-import io.quarkus.panache.common.Sort
-import io.quarkus.panache.common.impl.GenerateBridge
-import org.bson.Document
-import org.bson.types.ObjectId
-import java.util.stream.Stream
-
-/**
- * Define persistence and query methods for an Entity with a default ID type of [ObjectId]
- *
- * @param Entity the entity type
- */
-interface PanacheMongoCompanion: PanacheMongoCompanionBase
-
-/**
- * Define persistence and query methods for an Entity with a type of Id
- *
- * @param Entity the entity type
- * @param Id the ID type
- */
-interface PanacheMongoCompanionBase {
- /**
- * Find an entity of this type by ID.
- *
- * @param id the ID of the entity to find.
- * @return the entity found, or `null` if not found.
- */
- @GenerateBridge(targetReturnTypeErased = true)
- fun findById(id: Id): Entity? = throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a query, with optional indexed parameters.
- *
- * @param query a query string
- * @param params optional sequence of indexed parameters
- * @return a new [PanacheQuery] instance for the given query
- * @see [find]
- * @see [list]
- * @see [stream]
- */
- @GenerateBridge
- fun find(query: String, vararg params: Any?): PanacheQuery =
- throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a query and the given sort options with optional indexed parameters.
- *
- * @param query a query string
- * @param sort the sort strategy to use
- * @param params optional sequence of indexed parameters
- * @return a new [PanacheQuery] instance for the given query
- * @see [find]
- * @see [list]
- * @see [stream]
- */
- @GenerateBridge
- fun find(query: String, sort: Sort, vararg params: Any?): PanacheQuery =
- throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a query, with named parameters.
- *
- * @param query a query string
- * @param params [Map] of named parameters
- * @return a new [PanacheQuery] instance for the given query
- * @see [find]
- * @see [list]
- * @see [stream]
- */
- @GenerateBridge
- fun find(query: String, params: Map): PanacheQuery =
- throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a query and the given sort options, with named parameters.
- *
- * @param query a query string
- * @param sort the sort strategy to use
- * @param params [Map] of indexed parameters
- * @return a new [PanacheQuery] instance for the given query
- * @see [find]
- * @see [list]
- * @see [stream]
- */
- @GenerateBridge
- fun find(query: String, sort: Sort, params: Map): PanacheQuery =
- throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a query, with named parameters.
- *
- * @param query a query string
- * @param params Parameters of named parameters
- * @return a new [PanacheQuery] instance for the given query
- * @see [find]
- * @see [list]
- * @see [stream]
- */
- @GenerateBridge
- fun find(query: String, params: Parameters): PanacheQuery =
- throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a query and the given sort options with named parameters.
- *
- * @param query a query string
- * @param sort the sort strategy to use
- * @param params Parameters of indexed parameters
- * @return a new [PanacheQuery] instance for the given query
- * @see [find]
- * @see [list]
- * @see [stream]
- */
- @GenerateBridge
- fun find(query: String, sort: Sort, params: Parameters): PanacheQuery =
- throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a BSON query.
- *
- * @param query a query string
- * @return a new [PanacheQuery] instance for the given query
- * @see [find]
- * @see [list]
- * @see [stream]
- */
- @GenerateBridge
- fun find(query: Document): PanacheQuery = throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a a BSON query and a BSON sort.
- *
- * @param query a query string
- * @param sort the sort strategy to use
- * @return a new [PanacheQuery] instance for the given query
- * @see [find]
- * @see [list]
- * @see [stream]
- */
- @GenerateBridge
- fun find(query: Document, sort: Document): PanacheQuery = throw operations.implementationInjectionMissing()
-
- /**
- * Find all entities of this type.
- *
- * @return a new [PanacheQuery] instance to find all entities of this type.
- * @see [findAll]
- * @see [listAll]
- * @see [streamAll]
- */
- @GenerateBridge
- fun findAll(): PanacheQuery = throw operations.implementationInjectionMissing()
-
- /**
- * Find all entities of this type, in the given order.
- *
- * @param sort the sort order to use
- * @return a new [PanacheQuery] instance to find all entities of this type.
- * @see [findAll]
- * @see [listAll]
- * @see [streamAll]
- */
- @GenerateBridge
- fun findAll(sort: Sort): PanacheQuery = throw operations.implementationInjectionMissing()
-
- /**
- * Find entities matching a query, with optional indexed parameters.
- * This method is a shortcut for `find(query, params).list()`.
- *
- * @param query a query string
- * @param params optional sequence of indexed parameters
- * @return a [List] containing all results, without paging
- * @see [list]
- * @see [find]
- * @see [stream]
- */
- @GenerateBridge
- fun list(query: String, vararg params: Any?): List = throw operations.implementationInjectionMissing()
-
- /**
- * Find entities matching a query and the given sort options, with optional indexed parameters.
- * This method is a shortcut for `find(query, sort, params).list()`.
- *
- * @param query a query string
- * @param sort the sort strategy to use
- * @param params optional sequence of indexed parameters
- * @return a [List] containing all results, without paging
- * @see [list]
- * @see [find]
- * @see [stream]
- */
- @GenerateBridge
- fun list(query: String, sort: Sort, vararg params: Any?): List =
- throw operations.implementationInjectionMissing()
-
- /**
- * Find entities matching a query, with named parameters.
- * This method is a shortcut for `find(query, params).list()`.
- *
- * @param query a query string
- * @param params [Map] of named parameters
- * @return a [List] containing all results, without paging
- * @see [list]
- * @see [find]
- * @see [stream]
- */
- @GenerateBridge
- fun list(query: String, params: Map): List = throw operations.implementationInjectionMissing()
-
- /**
- * Find entities matching a query and the given sort options, with named parameters.
- * This method is a shortcut for `find(query, sort, params).list()`.
- *
- * @param query a query string
- * @param sort the sort strategy to use
- * @param params [Map] of indexed parameters
- * @return a [List] containing all results, without paging
- * @see [list]
- * @see [find]
- * @see [stream]
- */
- @GenerateBridge
- fun list(query: String, sort: Sort, params: Map): List =
- throw operations.implementationInjectionMissing()
-
- /**
- * Find entities matching a query, with named parameters.
- * This method is a shortcut for `find(query, params).list()`.
- *
- * @param query a query string
- * @param params Parameters of named parameters
- * @return a [List] containing all results, without paging
- * @see [list]
- * @see [find]
- * @see [stream]
- */
- @GenerateBridge
- fun list(query: String, params: Parameters): List = throw operations.implementationInjectionMissing()
-
- /**
- * Find entities matching a query and the given sort options, with named parameters.
- * This method is a shortcut for `find(query, sort, params).list()`.
- *
- * @param query a query string
- * @param sort the sort strategy to use
- * @param params Parameters of indexed parameters
- * @return a [List] containing all results, without paging
- * @see [list]
- * @see [find]
- * @see [stream]
- */
- @GenerateBridge
- fun list(query: String, sort: Sort, params: Parameters): List =
- throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a BSON query.
- * This method is a shortcut for `find(query).list()`.
- *
- * @param query a query document
- * @return a [List] containing all results, without paging
- * @see [list]
- * @see [find]
- * @see [stream]
- */
- @GenerateBridge
- fun list(query: Document): List = throw operations.implementationInjectionMissing()
-
- /**
- * Find entities using a a BSON query and a BSON sort.
- * This method is a shortcut for `find(query, sort).list()`.
- *
- * @param query a query document
- * @param sort the sort document
- * @return a [List] containing all results, without paging
- * @see [list]
- * @see [find]
- * @see [stream]
- */
- @GenerateBridge
- fun list(query: Document, sort: Document): List = throw operations.implementationInjectionMissing()
-
- /**
- * Find all entities of this type.
- * This method is a shortcut for `findAll().list()`.
- *
- * @return a [List] containing all results, without paging
- * @see [listAll]
- * @see [findAll]
- * @see [streamAll]
- */
- @GenerateBridge
- fun listAll(): List = throw operations.implementationInjectionMissing()
-
- /**
- * Find all entities of this type, in the given order.
- * This method is a shortcut for `findAll(sort).list()`.
- *
- * @param sort the sort order to use
- * @return a [List] containing all results, without paging
- * @see [listAll]
- * @see [findAll]
- * @see [streamAll]
- */
- @GenerateBridge
- fun listAll(sort: Sort): List = throw operations.implementationInjectionMissing()
-
- /**
- * Find entities matching a query, with optional indexed parameters.
- * This method is a shortcut for `find(query, params).stream()`.
- *
- * @param query a query string
- * @param params optional sequence of indexed parameters
- * @return a Stream containing all results, without paging
- * @see [stream]
- * @see [find]
- * @see [list]
- */
- @GenerateBridge
- fun stream(query: String, vararg params: Any?): Stream