Renamed RAttachedLiveObjectService to RLiveObjectService

pull/527/head
jackygurui 9 years ago
parent 4b3bca2b7a
commit f7ecddc1f0

@ -76,7 +76,7 @@ import org.redisson.core.RSortedSet;
import org.redisson.core.RTopic;
import org.redisson.liveobject.CodecProvider;
import org.redisson.liveobject.DefaultCodecProvider;
import org.redisson.liveobject.RAttachedLiveObjectService;
import org.redisson.liveobject.RLiveObjectService;
import io.netty.util.concurrent.Future;
import io.netty.util.internal.PlatformDependent;
@ -551,13 +551,13 @@ public class Redisson implements RedissonClient {
}
@Override
public RAttachedLiveObjectService getAttachedLiveObjectService() {
return new RedissonAttachedLiveObjectService(this, liveObjectClassCache, liveObjectDefaultCodecProvider);
public RLiveObjectService getLiveObjectService() {
return new RedissonLiveObjectService(this, liveObjectClassCache, liveObjectDefaultCodecProvider);
}
@Override
public RAttachedLiveObjectService getAttachedLiveObjectService(CodecProvider ProviderCodec) {
return new RedissonAttachedLiveObjectService(this, liveObjectClassCache, new DefaultCodecProvider());
public RLiveObjectService getLiveObjectService(CodecProvider ProviderCodec) {
return new RedissonLiveObjectService(this, liveObjectClassCache, new DefaultCodecProvider());
}
@Override

@ -60,7 +60,7 @@ import org.redisson.core.RSetMultimapCache;
import org.redisson.core.RSortedSet;
import org.redisson.core.RTopic;
import org.redisson.liveobject.CodecProvider;
import org.redisson.liveobject.RAttachedLiveObjectService;
import org.redisson.liveobject.RLiveObjectService;
/**
* Main Redisson interface for access
@ -664,7 +664,7 @@ public interface RedissonClient {
*
* @return
*/
RAttachedLiveObjectService getAttachedLiveObjectService();
RLiveObjectService getLiveObjectService();
/**
* Returns RedissonAttachedLiveObjectService which can be used to
@ -673,7 +673,7 @@ public interface RedissonClient {
* @param codecProvider the CodecProvider to be used to create the service
* @return
*/
RAttachedLiveObjectService getAttachedLiveObjectService(CodecProvider codecProvider);
RLiveObjectService getLiveObjectService(CodecProvider codecProvider);
/**
* Shuts down Redisson instance <b>NOT</b> Redis server

@ -17,7 +17,7 @@ import org.redisson.core.RObject;
//import org.redisson.core.RObjectAsync;
import org.redisson.liveobject.CodecProvider;
import org.redisson.liveobject.LiveObjectTemplate;
import org.redisson.liveobject.RAttachedLiveObjectService;
import org.redisson.liveobject.RLiveObjectService;
import org.redisson.liveobject.RLiveObject;
import org.redisson.liveobject.annotation.REntity;
import org.redisson.liveobject.annotation.RId;
@ -26,14 +26,14 @@ import org.redisson.liveobject.core.AccessorInterceptor;
import org.redisson.liveobject.core.LiveObjectInterceptor;
import org.redisson.liveobject.misc.Introspectior;
public class RedissonAttachedLiveObjectService implements RAttachedLiveObjectService {
public class RedissonLiveObjectService implements RLiveObjectService {
private final Map<Class, Class> classCache;
private final RedissonClient redisson;
private final CodecProvider codecProvider;
public RedissonAttachedLiveObjectService(RedissonClient redisson, Map<Class, Class> classCache, CodecProvider codecProvider) {
public RedissonLiveObjectService(RedissonClient redisson, Map<Class, Class> classCache, CodecProvider codecProvider) {
this.redisson = redisson;
this.classCache = classCache;
this.codecProvider = codecProvider;

@ -1,43 +0,0 @@
/**
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.liveobject;
//import java.util.concurrent.TimeUnit;
/**
*
* @author Rui Gu (https://github.com/jackygurui)
*
*/
public interface RAttachedLiveObjectService extends RLiveObjectService {
/**
* Finds the entity from Redis with the id.
*
* @param entityClass Entity class
* @param id identifier
* @param timeToLive sets the time to live on the object. Any calls to the accessor
* of this object will renew this. If it is not been accessed
* before the ttl reaches. This object is then expires and
* removed from redis. Think of it is been garbage collected.
* @param timeUnit sets the time unit of the time to live balue on the object.
* @param <T> Entity type
* @param <K> Key type
* @return In ATTACHED Mode, this always returns a proxy class. Even it does
* not exist in redis.
*/
// public <T, K> T get(Class<T> entityClass, K id, long timeToLive, TimeUnit timeUnit);
}

@ -1,89 +0,0 @@
/**
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.liveobject;
import io.netty.util.concurrent.Future;
/**
*
* @author Rui Gu (https://github.com/jackygurui)
*
* @param <T> Entity type
* @param <K> Key type
*/
public interface RDetachedLiveObjectService<T, K> extends RLiveObjectService {
/**
* Finds the entity from Redis with the id.
*
* @param entityClass Entity class
* @param id identifier
* @return In ATTACHED Mode, this always returns a proxy class. Even it does
* not exist in redis.
* In DETACHED Mode, this returns an instance of the entity class.
* IF it doesn't exist in redis, a runtime exception is thrown.
*/
public Future<T> getAsync(Class<T> entityClass, K id);
/**
* Persist the instance into redis
*
* @param instance the instance to be persisted
* @return K The id of the object.
*/
public K persist(T instance);
/**
* Persist the instance into redis
*
* @param instance the instance to be persisted
* @return K The id of the object.
*/
public Future<K> persistAsync(T instance);
/**
* Persist the instance into redis with specified time to live.
*
* @param instance the instance to be persisted
* @param ttl the time to live of the instance
* @return K The id of the object.
*/
public K persist(T instance, long ttl);
/**
* Persist the instance into redis with specified time to live.
*
* @param instance
* @param ttl the time to live of the instance
* @return K The id of the object.
*/
public Future<K> persistAsync(T instance, long ttl);
/**
* Remove the instance from redis by specifying the id
*
* @param id
*/
public void remove(K id);
/**
* Remove the instance from redis by specifying the id
*
* @param id
* @return Future.
*/
public Future<Void> removeAsync(K id);
}

@ -116,7 +116,7 @@ public class AccessorInterceptor {
if (type != null) {
if (type.isAnnotationPresent(REntity.class)) {
REntity.NamingScheme ns = type.getAnnotation(REntity.class).namingScheme().newInstance();
return (RLiveObject) redisson.getAttachedLiveObjectService(codecProvider).get(type, ns.resolveId(rr.getKeyName()));
return (RLiveObject) redisson.getLiveObjectService(codecProvider).get(type, ns.resolveId(rr.getKeyName()));
}
for (Method method : RedissonClient.class.getDeclaredMethods()) {
if (method.getName().startsWith("get")

@ -7,7 +7,7 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.redisson.core.RMap;
import org.redisson.core.RObject;
import org.redisson.liveobject.RAttachedLiveObjectService;
import org.redisson.liveobject.RLiveObjectService;
import org.redisson.liveobject.RLiveObject;
import org.redisson.liveobject.annotation.REntity;
import org.redisson.liveobject.annotation.RId;
@ -234,7 +234,7 @@ public class RedissonAttachedLiveObjectServiceTest extends BaseTest {
@Test
public void testBasics() {
RAttachedLiveObjectService s = redisson.getAttachedLiveObjectService();
RLiveObjectService s = redisson.getLiveObjectService();
TestREntity t = s.<TestREntity, String>get(TestREntity.class, "1");
assertEquals("1", t.getName());
assertTrue(!redisson.getMap(REntity.DefaultNamingScheme.INSTANCE.getName(TestREntity.class, "name", "1")).isExists());
@ -253,7 +253,7 @@ public class RedissonAttachedLiveObjectServiceTest extends BaseTest {
@Test
public void testLiveObjectWithCollection() {
RAttachedLiveObjectService s = redisson.getAttachedLiveObjectService();
RLiveObjectService s = redisson.getLiveObjectService();
TestREntityWithMap t = s.<TestREntityWithMap, String>get(TestREntityWithMap.class, "2");
RMap<String, String> map = redisson.<String, String>getMap("testMap");
t.setValue(map);
@ -275,7 +275,7 @@ public class RedissonAttachedLiveObjectServiceTest extends BaseTest {
@Test
public void testLiveObjectWithRObject() {
RAttachedLiveObjectService s = redisson.getAttachedLiveObjectService();
RLiveObjectService s = redisson.getLiveObjectService();
TestREntityWithRMap t = s.<TestREntityWithRMap, String>get(TestREntityWithRMap.class, "2");
RMap<String, String> map = redisson.<String, String>getMap("testMap");
t.setValue(map);
@ -291,7 +291,7 @@ public class RedissonAttachedLiveObjectServiceTest extends BaseTest {
@Test
public void testLiveObjectWithNestedLiveObjectAsId() {
RAttachedLiveObjectService s = redisson.getAttachedLiveObjectService();
RLiveObjectService s = redisson.getLiveObjectService();
TestREntity t1 = s.<TestREntity, String>get(TestREntity.class, "1");
try {
s.<TestREntityIdNested, TestREntity>get(TestREntityIdNested.class, t1);
@ -302,7 +302,7 @@ public class RedissonAttachedLiveObjectServiceTest extends BaseTest {
@Test
public void testLiveObjectWithNestedLiveObjectAsValue() throws Exception {
RAttachedLiveObjectService s = redisson.getAttachedLiveObjectService();
RLiveObjectService s = redisson.getLiveObjectService();
TestREntityWithRMap t1 = s.<TestREntityWithRMap, String>get(TestREntityWithRMap.class, "111");
TestREntityValueNested t2 = s.<TestREntityValueNested, String>get(TestREntityValueNested.class, "122");
RMap<String, String> map = redisson.<String, String>getMap("32123");

Loading…
Cancel
Save