
org.redisson.reactive.RedissonLockReactive Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redisson Show documentation
Show all versions of redisson Show documentation
Redis Java client with features of In-Memory Data Grid
/**
* Copyright 2016 Nikita Koksharov
*
* 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.reactive;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonLock;
import org.redisson.api.RFuture;
import org.redisson.api.RLockAsync;
import org.redisson.api.RLockReactive;
import org.redisson.command.CommandAsyncExecutor;
import org.redisson.command.CommandReactiveExecutor;
/**
*
* @author Nikita Koksharov
*
*/
public class RedissonLockReactive extends RedissonExpirableReactive implements RLockReactive {
private final RLockAsync instance;
public RedissonLockReactive(CommandReactiveExecutor connectionManager, String name, UUID id) {
super(connectionManager, name);
instance = createLock(connectionManager, name, id);
}
protected RLockAsync createLock(CommandAsyncExecutor connectionManager, String name, UUID id) {
return new RedissonLock(commandExecutor, name, id);
}
@Override
public Publisher forceUnlock() {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.forceUnlockAsync();
}
});
}
@Override
public Publisher unlock() {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.unlockAsync();
}
});
}
@Override
public Publisher unlock(final long threadId) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.unlockAsync(threadId);
}
});
}
@Override
public Publisher tryLock() {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.tryLockAsync();
}
});
}
@Override
public Publisher lock() {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.lockAsync();
}
});
}
@Override
public Publisher lock(final long threadId) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.lockAsync(threadId);
}
});
}
@Override
public Publisher lock(final long leaseTime, final TimeUnit unit) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.lockAsync(leaseTime, unit);
}
});
}
@Override
public Publisher lock(final long leaseTime, final TimeUnit unit, final long threadId) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.lockAsync(leaseTime, unit, threadId);
}
});
}
@Override
public Publisher tryLock(final long threadId) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.tryLockAsync(threadId);
}
});
}
@Override
public Publisher tryLock(final long waitTime, final TimeUnit unit) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.tryLockAsync(waitTime, unit);
}
});
}
@Override
public Publisher tryLock(final long waitTime, final long leaseTime, final TimeUnit unit) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.tryLockAsync(waitTime, leaseTime, unit);
}
});
}
@Override
public Publisher tryLock(final long waitTime, final long leaseTime, final TimeUnit unit, final long threadId) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.tryLockAsync(waitTime, leaseTime, unit, threadId);
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy