|
|
@ -32,7 +32,7 @@ import org.redisson.api.RedissonReactiveClient;
|
|
|
|
import org.redisson.api.annotation.REntity;
|
|
|
|
import org.redisson.api.annotation.REntity;
|
|
|
|
import org.redisson.api.annotation.RId;
|
|
|
|
import org.redisson.api.annotation.RId;
|
|
|
|
import org.redisson.client.codec.Codec;
|
|
|
|
import org.redisson.client.codec.Codec;
|
|
|
|
import org.redisson.codec.CodecProvider;
|
|
|
|
import org.redisson.codec.ReferenceCodecProvider;
|
|
|
|
import org.redisson.config.Config;
|
|
|
|
import org.redisson.config.Config;
|
|
|
|
import org.redisson.liveobject.misc.ClassUtils;
|
|
|
|
import org.redisson.liveobject.misc.ClassUtils;
|
|
|
|
import org.redisson.liveobject.misc.Introspectior;
|
|
|
|
import org.redisson.liveobject.misc.Introspectior;
|
|
|
@ -103,7 +103,7 @@ public class RedissonObjectFactory {
|
|
|
|
|
|
|
|
|
|
|
|
public static <T> T fromReference(RedissonClient redisson, RedissonReference rr) throws Exception {
|
|
|
|
public static <T> T fromReference(RedissonClient redisson, RedissonReference rr) throws Exception {
|
|
|
|
Class<? extends Object> type = rr.getType();
|
|
|
|
Class<? extends Object> type = rr.getType();
|
|
|
|
CodecProvider codecProvider = redisson.getConfig().getCodecProvider();
|
|
|
|
ReferenceCodecProvider codecProvider = redisson.getConfig().getReferenceCodecProvider();
|
|
|
|
if (type != null) {
|
|
|
|
if (type != null) {
|
|
|
|
if (ClassUtils.isAnnotationPresent(type, REntity.class)) {
|
|
|
|
if (ClassUtils.isAnnotationPresent(type, REntity.class)) {
|
|
|
|
RLiveObjectService liveObjectService = redisson.getLiveObjectService();
|
|
|
|
RLiveObjectService liveObjectService = redisson.getLiveObjectService();
|
|
|
@ -133,7 +133,7 @@ public class RedissonObjectFactory {
|
|
|
|
|
|
|
|
|
|
|
|
public static <T> T fromReference(RedissonReactiveClient redisson, RedissonReference rr) throws Exception {
|
|
|
|
public static <T> T fromReference(RedissonReactiveClient redisson, RedissonReference rr) throws Exception {
|
|
|
|
Class<? extends Object> type = rr.getReactiveType();
|
|
|
|
Class<? extends Object> type = rr.getReactiveType();
|
|
|
|
CodecProvider codecProvider = redisson.getConfig().getCodecProvider();
|
|
|
|
ReferenceCodecProvider codecProvider = redisson.getConfig().getReferenceCodecProvider();
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Live Object from reference in reactive client is not supported yet.
|
|
|
|
* Live Object from reference in reactive client is not supported yet.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -158,12 +158,12 @@ public class RedissonObjectFactory {
|
|
|
|
|
|
|
|
|
|
|
|
if (object instanceof RObject && !(object instanceof RLiveObject)) {
|
|
|
|
if (object instanceof RObject && !(object instanceof RLiveObject)) {
|
|
|
|
RObject rObject = ((RObject) object);
|
|
|
|
RObject rObject = ((RObject) object);
|
|
|
|
config.getCodecProvider().registerCodec((Class) rObject.getCodec().getClass(), (Class) rObject.getClass(), rObject.getName(), rObject.getCodec());
|
|
|
|
config.getReferenceCodecProvider().registerCodec((Class) rObject.getCodec().getClass(), (Class) rObject.getClass(), rObject.getName(), rObject.getCodec());
|
|
|
|
return new RedissonReference(object.getClass(), ((RObject) object).getName(), ((RObject) object).getCodec());
|
|
|
|
return new RedissonReference(object.getClass(), ((RObject) object).getName(), ((RObject) object).getCodec());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (object instanceof RObjectReactive && !(object instanceof RLiveObject)) {
|
|
|
|
if (object instanceof RObjectReactive && !(object instanceof RLiveObject)) {
|
|
|
|
RObjectReactive rObject = ((RObjectReactive) object);
|
|
|
|
RObjectReactive rObject = ((RObjectReactive) object);
|
|
|
|
config.getCodecProvider().registerCodec((Class) rObject.getCodec().getClass(), (Class) rObject.getClass(), rObject.getName(), rObject.getCodec());
|
|
|
|
config.getReferenceCodecProvider().registerCodec((Class) rObject.getCodec().getClass(), (Class) rObject.getClass(), rObject.getName(), rObject.getCodec());
|
|
|
|
return new RedissonReference(object.getClass(), ((RObjectReactive) object).getName(), ((RObjectReactive) object).getCodec());
|
|
|
|
return new RedissonReference(object.getClass(), ((RObjectReactive) object).getName(), ((RObjectReactive) object).getCodec());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -173,7 +173,7 @@ public class RedissonObjectFactory {
|
|
|
|
REntity anno = ClassUtils.getAnnotation(rEntity, REntity.class);
|
|
|
|
REntity anno = ClassUtils.getAnnotation(rEntity, REntity.class);
|
|
|
|
NamingScheme ns = anno.namingScheme()
|
|
|
|
NamingScheme ns = anno.namingScheme()
|
|
|
|
.getDeclaredConstructor(Codec.class)
|
|
|
|
.getDeclaredConstructor(Codec.class)
|
|
|
|
.newInstance(config.getCodecProvider().getCodec(anno, (Class) rEntity));
|
|
|
|
.newInstance(config.getReferenceCodecProvider().getCodec(anno, (Class) rEntity));
|
|
|
|
String name = Introspectior
|
|
|
|
String name = Introspectior
|
|
|
|
.getFieldsWithAnnotation(rEntity, RId.class)
|
|
|
|
.getFieldsWithAnnotation(rEntity, RId.class)
|
|
|
|
.getOnly().getName();
|
|
|
|
.getOnly().getName();
|
|
|
|