diff --git a/src/main/java/org/redisson/Redisson.java b/src/main/java/org/redisson/Redisson.java index 4aefe1e4d..3cb845860 100755 --- a/src/main/java/org/redisson/Redisson.java +++ b/src/main/java/org/redisson/Redisson.java @@ -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 diff --git a/src/main/java/org/redisson/RedissonClient.java b/src/main/java/org/redisson/RedissonClient.java index a12bbb5d6..26dc9abb6 100755 --- a/src/main/java/org/redisson/RedissonClient.java +++ b/src/main/java/org/redisson/RedissonClient.java @@ -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 NOT Redis server diff --git a/src/main/java/org/redisson/RedissonAttachedLiveObjectService.java b/src/main/java/org/redisson/RedissonLiveObjectService.java similarity index 96% rename from src/main/java/org/redisson/RedissonAttachedLiveObjectService.java rename to src/main/java/org/redisson/RedissonLiveObjectService.java index 4bde7ecb5..420699bb7 100644 --- a/src/main/java/org/redisson/RedissonAttachedLiveObjectService.java +++ b/src/main/java/org/redisson/RedissonLiveObjectService.java @@ -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 classCache; private final RedissonClient redisson; private final CodecProvider codecProvider; - public RedissonAttachedLiveObjectService(RedissonClient redisson, Map classCache, CodecProvider codecProvider) { + public RedissonLiveObjectService(RedissonClient redisson, Map classCache, CodecProvider codecProvider) { this.redisson = redisson; this.classCache = classCache; this.codecProvider = codecProvider; diff --git a/src/main/java/org/redisson/liveobject/RAttachedLiveObjectService.java b/src/main/java/org/redisson/liveobject/RAttachedLiveObjectService.java deleted file mode 100644 index 92efe7c77..000000000 --- a/src/main/java/org/redisson/liveobject/RAttachedLiveObjectService.java +++ /dev/null @@ -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 Entity type - * @param Key type - * @return In ATTACHED Mode, this always returns a proxy class. Even it does - * not exist in redis. - */ -// public T get(Class entityClass, K id, long timeToLive, TimeUnit timeUnit); -} diff --git a/src/main/java/org/redisson/liveobject/RDetachedLiveObjectService.java b/src/main/java/org/redisson/liveobject/RDetachedLiveObjectService.java deleted file mode 100644 index 04329ff56..000000000 --- a/src/main/java/org/redisson/liveobject/RDetachedLiveObjectService.java +++ /dev/null @@ -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 Entity type - * @param Key type - */ -public interface RDetachedLiveObjectService 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 getAsync(Class 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 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 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 removeAsync(K id); -} diff --git a/src/main/java/org/redisson/liveobject/core/AccessorInterceptor.java b/src/main/java/org/redisson/liveobject/core/AccessorInterceptor.java index ea96700a4..cb89d7563 100644 --- a/src/main/java/org/redisson/liveobject/core/AccessorInterceptor.java +++ b/src/main/java/org/redisson/liveobject/core/AccessorInterceptor.java @@ -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") diff --git a/src/test/java/org/redisson/RedissonAttachedLiveObjectServiceTest.java b/src/test/java/org/redisson/RedissonAttachedLiveObjectServiceTest.java index 2ec3dab87..592903f9e 100644 --- a/src/test/java/org/redisson/RedissonAttachedLiveObjectServiceTest.java +++ b/src/test/java/org/redisson/RedissonAttachedLiveObjectServiceTest.java @@ -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.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.get(TestREntityWithMap.class, "2"); RMap map = redisson.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.get(TestREntityWithRMap.class, "2"); RMap map = redisson.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.get(TestREntity.class, "1"); try { s.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.get(TestREntityWithRMap.class, "111"); TestREntityValueNested t2 = s.get(TestREntityValueNested.class, "122"); RMap map = redisson.getMap("32123");