|
|
|
@ -110,23 +110,6 @@ public class RedissonLiveObjectService implements RLiveObjectService {
|
|
|
|
|
return ClassUtils.getField(proxied, "liveObjectLiveMap");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public <T> T create(Class<T> entityClass) {
|
|
|
|
|
validateClass(entityClass);
|
|
|
|
|
try {
|
|
|
|
|
Class<? extends T> proxyClass = getProxyClass(entityClass);
|
|
|
|
|
Object id = generateId(entityClass);
|
|
|
|
|
T proxied = instantiateLiveObject(proxyClass, id);
|
|
|
|
|
if (!getMap(proxied).fastPut("redisson_live_object", "1")) {
|
|
|
|
|
throw new IllegalArgumentException("Object already exists");
|
|
|
|
|
}
|
|
|
|
|
return proxied;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
unregisterClass(entityClass);
|
|
|
|
|
throw ex instanceof RuntimeException ? (RuntimeException) ex : new RuntimeException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private <T> Object generateId(Class<T> entityClass) throws NoSuchFieldException {
|
|
|
|
|
String idFieldName = getRIdFieldName(entityClass);
|
|
|
|
|
RId annotation = entityClass
|
|
|
|
@ -149,18 +132,6 @@ public class RedissonLiveObjectService implements RLiveObjectService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public <T, K> T getOrCreate(Class<T> entityClass, K id) {
|
|
|
|
|
try {
|
|
|
|
|
T proxied = instantiateLiveObject(getProxyClass(entityClass), id);
|
|
|
|
|
getMap(proxied).fastPut("redisson_live_object", "1");
|
|
|
|
|
return proxied;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
unregisterClass(entityClass);
|
|
|
|
|
throw ex instanceof RuntimeException ? (RuntimeException) ex : new RuntimeException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public <T> T attach(T detachedObject) {
|
|
|
|
|
validateDetached(detachedObject);
|
|
|
|
|