RLiveObject should implement RExpirable

pull/2247/head^2
Nikita Koksharov 6 years ago
parent 27aae56795
commit 6af30bca91

@ -751,7 +751,7 @@ public class RedissonLiveObjectService implements RLiveObjectService {
} }
Class<? extends T> proxied = builder.method(ElementMatchers.isDeclaredBy( Class<? extends T> proxied = builder.method(ElementMatchers.isDeclaredBy(
Introspectior.getTypeDescription(RLiveObject.class)) ElementMatchers.anyOf(RLiveObject.class, RExpirable.class, RObject.class))
.and(ElementMatchers.isGetter().or(ElementMatchers.isSetter()) .and(ElementMatchers.isGetter().or(ElementMatchers.isSetter())
.or(ElementMatchers.named("isPhantom")) .or(ElementMatchers.named("isPhantom"))
.or(ElementMatchers.named("delete")))) .or(ElementMatchers.named("delete"))))
@ -773,11 +773,6 @@ public class RedissonLiveObjectService implements RLiveObjectService {
.or(ElementMatchers.named("set")))) .or(ElementMatchers.named("set"))))
.intercept(MethodDelegation.to(FieldAccessorInterceptor.class)) .intercept(MethodDelegation.to(FieldAccessorInterceptor.class))
.method(ElementMatchers.isDeclaredBy(RObject.class)
.or(ElementMatchers.isDeclaredBy(RObjectAsync.class)))
.intercept(MethodDelegation.to(RObjectInterceptor.class))
.implement(RObject.class)
.method(ElementMatchers.isDeclaredBy(RExpirable.class) .method(ElementMatchers.isDeclaredBy(RExpirable.class)
.or(ElementMatchers.isDeclaredBy(RExpirableAsync.class))) .or(ElementMatchers.isDeclaredBy(RExpirableAsync.class)))
.intercept(MethodDelegation.to(RExpirableInterceptor.class)) .intercept(MethodDelegation.to(RExpirableInterceptor.class))

@ -19,7 +19,7 @@ package org.redisson.api;
* *
* @author Rui Gu (https://github.com/jackygurui) * @author Rui Gu (https://github.com/jackygurui)
*/ */
public interface RLiveObject { public interface RLiveObject extends RExpirable {
/** /**
* Returns the value of the field that has the RId annotation. * Returns the value of the field that has the RId annotation.
@ -38,22 +38,4 @@ public interface RLiveObject {
*/ */
void setLiveObjectId(Object liveObjectId); void setLiveObjectId(Object liveObjectId);
/**
* Returns true if this object holds no other values apart from the field
* annotated with RId. This involves in invoking the isExist() method on the
* underlying RMap. Since the field with RId annotation is encoded in the
* name of the underlying RMap, so to ensure the map exist in redis, set a
* non null value to any of the other fields.
*
* @return <code>true</code> is object exists
* @see org.redisson.api.RMap
*/
boolean isExists();
/**
* Deletes the underlying RMap.
* @return <code>true</code> if object deleted successfully
*/
boolean delete();
} }

@ -121,14 +121,6 @@ public class LiveObjectInterceptor {
return namingScheme.resolveId(map.getName()); return namingScheme.resolveId(map.getName());
} }
if ("getLiveObjectLiveMap".equals(method.getName())) {
return map;
}
if ("isExists".equals(method.getName())) {
return map.isExists();
}
if ("delete".equals(method.getName())) { if ("delete".equals(method.getName())) {
FieldList<InDefinedShape> fields = Introspectior.getFieldsWithAnnotation(me.getClass().getSuperclass(), RIndex.class); FieldList<InDefinedShape> fields = Introspectior.getFieldsWithAnnotation(me.getClass().getSuperclass(), RIndex.class);
RBatch batch = redisson.createBatch(); RBatch batch = redisson.createBatch();
@ -146,7 +138,7 @@ public class LiveObjectInterceptor {
return deleteFuture.getNow() > 0; return deleteFuture.getNow() > 0;
} }
throw new NoSuchMethodException(); return method.invoke(map, args);
} }
private String getMapKey(Object id) { private String getMapKey(Object id) {

@ -54,6 +54,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.redisson.api.RLiveObject;
import org.redisson.api.RObject; import org.redisson.api.RObject;
import org.redisson.cache.LRUCacheMap; import org.redisson.cache.LRUCacheMap;
@ -142,7 +143,7 @@ public class ClassUtils {
private static Iterable<Class<?>> getClassHierarchy(Class<?> clazz) { private static Iterable<Class<?>> getClassHierarchy(Class<?> clazz) {
// Don't descend into hierarchy for RObjects // Don't descend into hierarchy for RObjects
if (Arrays.asList(clazz.getInterfaces()).contains(RObject.class)) { if (Arrays.asList(clazz.getInterfaces()).contains(RLiveObject.class)) {
return Collections.<Class<?>>singleton(clazz); return Collections.<Class<?>>singleton(clazz);
} }
List<Class<?>> classes = new ArrayList<Class<?>>(); List<Class<?>> classes = new ArrayList<Class<?>>();

Loading…
Cancel
Save