forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: mongodb-panache-reactive extension
fix: rename all this stuff fix: improve test - Use @MongoEntity - Better SSE test feat: optional support chore: move to axle package Merge reactive and blocking API into the same module fix bug quarkusio#5885 for Axle Remove the deleted reactive extension stage from the CI Documentation guide
- Loading branch information
1 parent
38e4228
commit f683dd6
Showing
32 changed files
with
3,972 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...c/main/java/io/quarkus/mongodb/panache/deployment/ReactivePanacheMongoEntityEnhancer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package io.quarkus.mongodb.panache.deployment; | ||
|
||
import java.lang.reflect.Modifier; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.bson.codecs.pojo.annotations.BsonIgnore; | ||
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 org.objectweb.asm.MethodVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
import io.quarkus.gizmo.DescriptorUtils; | ||
import io.quarkus.mongodb.panache.axle.runtime.ReactiveMongoOperations; | ||
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; | ||
|
||
public class ReactivePanacheMongoEntityEnhancer extends PanacheEntityEnhancer<MetamodelInfo<EntityModel<EntityField>>> { | ||
public final static String MONGO_OPERATIONS_NAME = ReactiveMongoOperations.class.getName(); | ||
public final static String MONGO_OPERATIONS_BINARY_NAME = MONGO_OPERATIONS_NAME.replace('.', '/'); | ||
|
||
private static final DotName DOTNAME_BSON_IGNORE = DotName.createSimple(BsonIgnore.class.getName()); | ||
|
||
final Map<String, EntityModel> entities = new HashMap<>(); | ||
|
||
public ReactivePanacheMongoEntityEnhancer(IndexView index) { | ||
super(index, PanacheResourceProcessor.DOTNAME_AXLE_PANACHE_ENTITY_BASE); | ||
modelInfo = new MetamodelInfo<>(); | ||
} | ||
|
||
@Override | ||
public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) { | ||
return new PanacheMongoEntityClassVisitor(className, outputClassVisitor, modelInfo, panacheEntityBaseClassInfo); | ||
} | ||
|
||
static class PanacheMongoEntityClassVisitor extends PanacheEntityClassVisitor<EntityField> { | ||
|
||
public PanacheMongoEntityClassVisitor(String className, ClassVisitor outputClassVisitor, | ||
MetamodelInfo<EntityModel<EntityField>> modelInfo, ClassInfo panacheEntityBaseClassInfo) { | ||
super(className, outputClassVisitor, modelInfo, panacheEntityBaseClassInfo); | ||
} | ||
|
||
@Override | ||
protected void injectModel(MethodVisitor mv) { | ||
mv.visitLdcInsn(thisClass); | ||
} | ||
|
||
@Override | ||
protected String getModelDescriptor() { | ||
return "Ljava/lang/Class;"; | ||
} | ||
|
||
@Override | ||
protected String getPanacheOperationsBinaryName() { | ||
return MONGO_OPERATIONS_BINARY_NAME; | ||
} | ||
|
||
@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); | ||
} | ||
} | ||
|
||
public void collectFields(ClassInfo classInfo) { | ||
EntityModel<EntityField> entityModel = new EntityModel<>(classInfo); | ||
for (FieldInfo fieldInfo : classInfo.fields()) { | ||
String name = fieldInfo.name(); | ||
if (Modifier.isPublic(fieldInfo.flags()) && !fieldInfo.hasAnnotation(DOTNAME_BSON_IGNORE)) { | ||
entityModel.addField(new EntityField(name, DescriptorUtils.typeToString(fieldInfo.type()))); | ||
} | ||
} | ||
modelInfo.addEntityModel(entityModel); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...in/java/io/quarkus/mongodb/panache/deployment/ReactivePanacheMongoRepositoryEnhancer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package io.quarkus.mongodb.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.mongodb.panache.axle.ReactivePanacheMongoRepository; | ||
import io.quarkus.mongodb.panache.axle.ReactivePanacheMongoRepositoryBase; | ||
import io.quarkus.panache.common.deployment.PanacheRepositoryEnhancer; | ||
|
||
public class ReactivePanacheMongoRepositoryEnhancer extends PanacheRepositoryEnhancer { | ||
public final static DotName PANACHE_REPOSITORY_BASE_NAME = DotName | ||
.createSimple(ReactivePanacheMongoRepositoryBase.class.getName()); | ||
|
||
public final static DotName PANACHE_REPOSITORY_NAME = DotName.createSimple(ReactivePanacheMongoRepository.class.getName()); | ||
|
||
public ReactivePanacheMongoRepositoryEnhancer(IndexView index) { | ||
super(index, PanacheResourceProcessor.DOTNAME_AXLE_PANACHE_REPOSITORY_BASE); | ||
} | ||
|
||
@Override | ||
public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) { | ||
return new PanacheMongoRepositoryClassVisitor(className, outputClassVisitor, panacheRepositoryBaseClassInfo, | ||
this.indexView); | ||
} | ||
|
||
static class PanacheMongoRepositoryClassVisitor extends PanacheRepositoryClassVisitor { | ||
|
||
public PanacheMongoRepositoryClassVisitor(String className, ClassVisitor outputClassVisitor, | ||
ClassInfo panacheRepositoryBaseClassInfo, IndexView indexView) { | ||
super(className, outputClassVisitor, panacheRepositoryBaseClassInfo, indexView); | ||
} | ||
|
||
@Override | ||
protected DotName getPanacheRepositoryDotName() { | ||
return PANACHE_REPOSITORY_NAME; | ||
} | ||
|
||
@Override | ||
protected DotName getPanacheRepositoryBaseDotName() { | ||
return PANACHE_REPOSITORY_BASE_NAME; | ||
} | ||
|
||
@Override | ||
protected String getPanacheOperationsBinaryName() { | ||
return ReactivePanacheMongoEntityEnhancer.MONGO_OPERATIONS_BINARY_NAME; | ||
} | ||
|
||
@Override | ||
protected void injectModel(MethodVisitor mv) { | ||
// inject Class | ||
mv.visitLdcInsn(entityType); | ||
} | ||
|
||
@Override | ||
protected String getModelDescriptor() { | ||
return "Ljava/lang/Class;"; | ||
} | ||
} | ||
} |
Oops, something went wrong.