Comments added

pull/6/head
Nikita 11 years ago
parent 1eb7882fa0
commit d669c0236c

@ -13,16 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.core;
package org.redisson;
import org.redisson.core.MessageListener;
import com.lambdaworks.redis.pubsub.RedisPubSubAdapter;
public class RedisPubSubTopicListener<K, V> extends RedisPubSubAdapter<K, V> {
public class RedisPubSubTopicListenerWrapper<K, V> extends RedisPubSubAdapter<K, V> {
private final MessageListener<V> listener;
private final K name;
public RedisPubSubTopicListener(MessageListener<V> listener, K name) {
public RedisPubSubTopicListenerWrapper(MessageListener<V> listener, K name) {
super();
this.listener = listener;
this.name = name;
@ -52,7 +54,7 @@ public class RedisPubSubTopicListener<K, V> extends RedisPubSubAdapter<K, V> {
return false;
if (getClass() != obj.getClass())
return false;
RedisPubSubTopicListener other = (RedisPubSubTopicListener) obj;
RedisPubSubTopicListenerWrapper other = (RedisPubSubTopicListenerWrapper) obj;
if (listener == null) {
if (other.listener != null)
return false;

@ -24,7 +24,6 @@ import org.redisson.connection.ConnectionManager;
import org.redisson.connection.ConnectionManager.PubSubEntry;
import org.redisson.core.MessageListener;
import org.redisson.core.RTopic;
import org.redisson.core.RedisPubSubTopicListener;
import com.lambdaworks.redis.RedisConnection;
import com.lambdaworks.redis.pubsub.RedisPubSubAdapter;
@ -34,8 +33,8 @@ public class RedissonTopic<M> extends RedissonObject implements RTopic<M> {
private final CountDownLatch subscribeLatch = new CountDownLatch(1);
private final AtomicBoolean subscribeOnce = new AtomicBoolean();
private final Map<Integer, RedisPubSubTopicListener<String, M>> listeners =
new ConcurrentHashMap<Integer, RedisPubSubTopicListener<String, M>>();
private final Map<Integer, RedisPubSubTopicListenerWrapper<String, M>> listeners =
new ConcurrentHashMap<Integer, RedisPubSubTopicListenerWrapper<String, M>>();
private final ConnectionManager connectionManager;
private PubSubEntry pubSubEntry;
@ -80,7 +79,7 @@ public class RedissonTopic<M> extends RedissonObject implements RTopic<M> {
@Override
public int addListener(MessageListener<M> listener) {
RedisPubSubTopicListener<String, M> pubSubListener = new RedisPubSubTopicListener<String, M>(listener, getName());
RedisPubSubTopicListenerWrapper<String, M> pubSubListener = new RedisPubSubTopicListenerWrapper<String, M>(listener, getName());
listeners.put(pubSubListener.hashCode(), pubSubListener);
pubSubEntry.addListener(pubSubListener);
return pubSubListener.hashCode();
@ -88,7 +87,7 @@ public class RedissonTopic<M> extends RedissonObject implements RTopic<M> {
@Override
public void removeListener(int listenerId) {
RedisPubSubTopicListener<String, M> pubSubListener = listeners.remove(listenerId);
RedisPubSubTopicListenerWrapper<String, M> pubSubListener = listeners.remove(listenerId);
pubSubEntry.removeListener(pubSubListener);
}

@ -17,6 +17,15 @@ package org.redisson.core;
import java.util.EventListener;
/**
* Listener for Redis messages published via RTopic Redisson object
*
* @author Nikita Koksharov
*
* @param <M> message
*
* @see org.redisson.core.RTopic
*/
public interface MessageListener<M> extends EventListener {
void onMessage(M msg);

@ -15,8 +15,19 @@
*/
package org.redisson.core;
/**
* Distributed alternative to the {@link java.util.concurrent.atomic.AtomicLong}
*
* @author Nikita Koksharov
*
*/
public interface RAtomicLong extends RObject {
/**
* Atomically decrements by one the current value.
*
* @return the previous value
*/
long getAndDecrement();
/**

@ -17,6 +17,12 @@ package org.redisson.core;
import java.util.concurrent.TimeUnit;
/**
* Distributed alternative to the {@link java.util.concurrent.CountDownLatch}
*
* @author Nikita Koksharov
*
*/
public interface RCountDownLatch extends RObject {
void await() throws InterruptedException;

@ -17,6 +17,13 @@ package org.redisson.core;
import java.util.List;
/**
* Distributed and concurrent implementation of {@link java.util.List}
*
* @author Nikita Koksharov
*
* @param <V> value
*/
public interface RList<V> extends List<V>, RObject {
}

@ -17,6 +17,12 @@ package org.redisson.core;
import java.util.concurrent.locks.Lock;
/**
* Distributed implementation of {@link java.util.concurrent.locks.Lock}
*
* @author Nikita Koksharov
*
*/
public interface RLock extends Lock, RObject {
}

@ -17,6 +17,15 @@ package org.redisson.core;
import java.util.concurrent.ConcurrentMap;
/**
* Distributed and concurrent implementation of {@link java.util.concurrent.ConcurrentMap}
* and {@link java.util.Map}
*
* @author Nikita Koksharov
*
* @param <K> key
* @param <V> value
*/
public interface RMap<K, V> extends ConcurrentMap<K, V>, RObject {
}

@ -15,6 +15,12 @@
*/
package org.redisson.core;
/**
* Base interface for all Redisson objects
*
* @author Nikita Koksharov
*
*/
public interface RObject {
/**

@ -17,6 +17,13 @@ package org.redisson.core;
import java.util.Queue;
/**
* Distributed and concurrent implementation of {@link java.util.List}
*
* @author Nikita Koksharov
*
* @param <V> value
*/
public interface RQueue<V> extends Queue<V>, RObject {
}

@ -17,6 +17,13 @@ package org.redisson.core;
import java.util.Set;
/**
* Distributed and concurrent implementation of {@link java.util.Set}
*
* @author Nikita Koksharov
*
* @param <V> value
*/
public interface RSet<V> extends Set<V>, RObject {
}

@ -19,6 +19,8 @@ package org.redisson.core;
/**
* Distributed topic. Messages are delivered to all message listeners across Redis cluster.
*
* @author Nikita Koksharov
*
* @param <M> the type of message object
*/
public interface RTopic<M> extends RObject {

Loading…
Cancel
Save