Code formatted according to checkstyle rules

pull/1923/head
Nikita Koksharov 6 years ago
parent b563197e24
commit 25a7239e42

@ -379,7 +379,9 @@
**/org/redisson/reactive/**/*.java,
**/org/redisson/remote/**/*.java,
**/org/redisson/rx/**/*.java,
**/org/redisson/spring/**/*.java,
</includes>
<consoleOutput>true</consoleOutput>
<enableRSS>false</enableRSS>
<configLocation>/checkstyle.xml</configLocation>

@ -73,7 +73,7 @@ public class RedissonCache implements Cache {
Object value = map.get(key);
if (value == null) {
addCacheMiss();
}else{
} else {
addCacheHit();
}
return toValueWrapper(value);
@ -83,7 +83,7 @@ public class RedissonCache implements Cache {
Object value = map.get(key);
if (value == null) {
addCacheMiss();
}else{
} else {
addCacheHit();
if (value.getClass().getName().equals(NullValue.class.getName())) {
return null;
@ -159,31 +159,36 @@ public class RedissonCache implements Cache {
try {
value = map.get(key);
if (value == null) {
try {
value = toStoreValue(valueLoader.call());
} catch (Throwable ex) {
RuntimeException exception;
try {
Class<?> c = Class.forName("org.springframework.cache.Cache$ValueRetrievalException");
Constructor<?> constructor = c.getConstructor(Object.class, Callable.class, Throwable.class);
exception = (RuntimeException) constructor.newInstance(key, valueLoader, ex);
} catch (Exception e) {
throw new IllegalStateException(e);
}
throw exception;
}
put(key, value);
value = putValue(key, valueLoader, value);
}
} finally {
lock.unlock();
}
}else{
} else {
addCacheHit();
}
return (T) fromStoreValue(value);
}
private <T> Object putValue(Object key, Callable<T> valueLoader, Object value) {
try {
value = toStoreValue(valueLoader.call());
} catch (Exception ex) {
RuntimeException exception;
try {
Class<?> c = Class.forName("org.springframework.cache.Cache$ValueRetrievalException");
Constructor<?> constructor = c.getConstructor(Object.class, Callable.class, Throwable.class);
exception = (RuntimeException) constructor.newInstance(key, valueLoader, ex);
} catch (Exception e) {
throw new IllegalStateException(e);
}
throw exception;
}
put(key, value);
return value;
}
protected Object fromStoreValue(Object storeValue) {
if (storeValue instanceof NullValue) {
return null;

@ -65,7 +65,7 @@ public class RedissonSpringCacheManager implements CacheManager, ResourceLoaderA
* @param redisson object
*/
public RedissonSpringCacheManager(RedissonClient redisson) {
this(redisson, (String)null, null);
this(redisson, (String) null, null);
}
/**

@ -59,7 +59,7 @@ public class RedissonSessionRepository implements FindByIndexNameSessionReposito
private final MapSession delegate;
private RMap<String, Object> map;
public RedissonSession() {
RedissonSession() {
this.delegate = new MapSession();
map = redisson.getMap(keyPrefix + delegate.getId(), new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
principalName = resolvePrincipal(delegate);
@ -83,7 +83,7 @@ public class RedissonSessionRepository implements FindByIndexNameSessionReposito
}
}
public RedissonSession(String sessionId) {
RedissonSession(String sessionId) {
this.delegate = new MapSession(sessionId);
map = redisson.getMap(keyPrefix + sessionId, new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
principalName = resolvePrincipal(delegate);

@ -28,12 +28,9 @@ import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.core.Conventions;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
/**
*
@ -47,7 +44,7 @@ public final class RedissonDefinitionParser
private static final String REF_SUFFIX = "-ref";
private static final String REDISSON_REF = "redisson-ref";
static enum ConfigType {
enum ConfigType {
singleServer,
sentinelServers,
replicatedServers,
@ -64,7 +61,7 @@ public final class RedissonDefinitionParser
}
}
static enum AddressType {
enum AddressType {
slaveAddress,
sentinelAddress,
nodeAddress;
@ -93,9 +90,8 @@ public final class RedissonDefinitionParser
parserContext.pushContainingComponent(compositeDef);
List<Element> childElts = DomUtils.getChildElements(element);
for (Element elt : childElts) {
if(BeanDefinitionParserDelegate
.QUALIFIER_ELEMENT.equals(elt.getLocalName())) {
continue;//parsed elsewhere
if (BeanDefinitionParserDelegate.QUALIFIER_ELEMENT.equals(elt.getLocalName())) {
continue; //parsed elsewhere
}
String localName = parserContext.getDelegate().getLocalName(elt);
localName = Conventions.attributeNameToPropertyName(localName);

@ -32,12 +32,12 @@ import org.w3c.dom.Element;
public class RedissonGenericObjectDefinitionParser
extends AbstractRedissonNamespaceDefinitionParser {
private final static String KEY_ATTRIBUTE = "key";
private final static String TOPIC_ATTRIBUTE = "topic";
private final static String PATTERN_ATTRIBUTE = "pattern";
private final static String SERVICE_ATTRIBUTE = "service";
private final static String CODEC_REF_ATTRIBUTE = "codec-ref";
private final static String FAIL_LOCK = "fairLock";
private static final String KEY_ATTRIBUTE = "key";
private static final String TOPIC_ATTRIBUTE = "topic";
private static final String PATTERN_ATTRIBUTE = "pattern";
private static final String SERVICE_ATTRIBUTE = "service";
private static final String CODEC_REF_ATTRIBUTE = "codec-ref";
private static final String FAIL_LOCK = "fairLock";
RedissonGenericObjectDefinitionParser(RedissonNamespaceParserSupport helper) {
super(helper, RedissonNamespaceParserSupport.REDISSON_REF_ATTRIBUTE);
@ -78,10 +78,14 @@ public class RedissonGenericObjectDefinitionParser
= Conventions.attributeNameToPropertyName(
element.getLocalName());
try {
return Class.forName(RedissonNamespaceParserSupport.API_CLASS_PATH_PREFIX
+ (StringUtils.capitalize(FAIL_LOCK.equals(elementName)
? "lock"
: elementName)));
String name = RedissonNamespaceParserSupport.API_CLASS_PATH_PREFIX;
if (FAIL_LOCK.equals(elementName)) {
name += StringUtils.capitalize("lock");
} else {
name += StringUtils.capitalize(elementName);
}
return Class.forName(name);
} catch (ClassNotFoundException ex) {
throw new IllegalArgumentException(ex);
}

@ -49,7 +49,7 @@ public class RedissonMultiLockDefinitionParser
String localName = elt.getLocalName();
if (BeanDefinitionParserDelegate
.QUALIFIER_ELEMENT.equals(localName)) {
continue;//parsed elsewhere
continue; //parsed elsewhere
}
String id;
if (BeanDefinitionParserDelegate.REF_ELEMENT.equals(localName)){

@ -41,8 +41,7 @@ public class RedissonNamespaceHandlerSupport extends NamespaceHandlerSupport {
= new RedissonNestedElementAwareDecorator(
new String[]{
RedissonNamespaceParserSupport.READ_LOCK_ELEMENT,
RedissonNamespaceParserSupport.WRITE_LOCK_ELEMENT
},
RedissonNamespaceParserSupport.WRITE_LOCK_ELEMENT},
RedissonNamespaceParserSupport.READ_WRITE_LOCK_REF_ATTRIBUTE);
RedissonGenericObjectDefinitionParser readWriteLockParser
@ -53,8 +52,7 @@ public class RedissonNamespaceHandlerSupport extends NamespaceHandlerSupport {
= new RedissonNestedElementAwareDecorator(
new String[]{
RedissonNamespaceParserSupport.RPC_SERVER_ELEMENT,
RedissonNamespaceParserSupport.RPC_CLIENT_ELEMENT
},
RedissonNamespaceParserSupport.RPC_CLIENT_ELEMENT},
RedissonNamespaceParserSupport.REMOTE_SERVICE_REF_ATTRIBUTE);
RedissonGenericObjectDefinitionParser remoteServiceParser
@ -65,8 +63,7 @@ public class RedissonNamespaceHandlerSupport extends NamespaceHandlerSupport {
= new RedissonNestedElementAwareDecorator(
new String[]{
RedissonNamespaceParserSupport.LIVE_OBJECT_ELEMENT,
RedissonNamespaceParserSupport.LIVE_OBJECT_REGISTRATION_ELEMENT
},
RedissonNamespaceParserSupport.LIVE_OBJECT_REGISTRATION_ELEMENT},
RedissonNamespaceParserSupport.LIVE_OBJECT_SERVICE_REF_ATTRIBUTE);
RedissonGenericObjectDefinitionParser liveObjectServiceParser
@ -98,7 +95,7 @@ public class RedissonNamespaceHandlerSupport extends NamespaceHandlerSupport {
registerBeanDefinitionParser("permit-expirable-semaphore", defaultParser);
registerBeanDefinitionParser("lock", defaultParser);
registerBeanDefinitionParser("fair-lock", defaultParser);
registerBeanDefinitionParser("read-write-lock",readWriteLockParser);
registerBeanDefinitionParser("read-write-lock", readWriteLockParser);
registerBeanDefinitionParser("read-lock", readAndWriteLockParser);
registerBeanDefinitionParser("write-lock", readAndWriteLockParser);
registerBeanDefinitionParser("multi-lock", nestedParser);
@ -126,7 +123,7 @@ public class RedissonNamespaceHandlerSupport extends NamespaceHandlerSupport {
registerBeanDefinitionParser("bit-set", defaultParser);
registerBeanDefinitionParser("bloom-filter", defaultParser);
registerBeanDefinitionParser("script", defaultParser);
registerBeanDefinitionParser("executor-service", defaultParser);//nested unfinished
registerBeanDefinitionParser("executor-service", defaultParser); //nested unfinished
registerBeanDefinitionParser("remote-service", remoteServiceParser);
registerBeanDefinitionParser("rpc-server",
new RedissonRPCServerDefinitionParser(helper));

@ -38,7 +38,7 @@ import org.w3c.dom.Node;
*/
public class RedissonNamespaceParserSupport {
public final static String REDISSON_NAMESPACE
public static final String REDISSON_NAMESPACE
= "http://redisson.org/schema/redisson";
static final String REF_SUFFIX = "-ref";
@ -101,12 +101,10 @@ public class RedissonNamespaceParserSupport {
for (int x = 0; x < attributes.getLength(); x++) {
Attr attribute = (Attr) attributes.item(x);
if (isEligibleAttribute(attribute)) {
String propertyName
= attribute.getLocalName().endsWith(REF_SUFFIX)
? attribute.getLocalName()
.substring(0, attribute.getLocalName()
.length() - REF_SUFFIX.length())
: attribute.getLocalName();
String propertyName = attribute.getLocalName();
if (propertyName.endsWith(REF_SUFFIX)) {
propertyName = propertyName.substring(0, attribute.getLocalName().length() - REF_SUFFIX.length());
}
propertyName = Conventions
.attributeNameToPropertyName(propertyName);
Assert.state(StringUtils.hasText(propertyName),
@ -164,13 +162,13 @@ public class RedissonNamespaceParserSupport {
return componentDefinition;
}
public void addConstructorArgs(Element element, String attribute, Class type, BeanDefinition bd) {
public void addConstructorArgs(Element element, String attribute, Class<?> type, BeanDefinition bd) {
if (element.hasAttribute(attribute)) {
addConstructorArgs(element.getAttribute(attribute), type, bd);
}
}
public void addConstructorArgs(Object value, Class type, BeanDefinition bd) {
public void addConstructorArgs(Object value, Class<?> type, BeanDefinition bd) {
ConstructorArgumentValues.ValueHolder vHolder
= new ConstructorArgumentValues.ValueHolder(value, type.getName());
ConstructorArgumentValues args
@ -178,11 +176,11 @@ public class RedissonNamespaceParserSupport {
args.addIndexedArgumentValue(args.getArgumentCount(), vHolder);
}
public void addConstructorArgs(Element element, String attribute, Class type, BeanDefinitionBuilder builder) {
public void addConstructorArgs(Element element, String attribute, Class<?> type, BeanDefinitionBuilder builder) {
addConstructorArgs(element, attribute, type, builder.getRawBeanDefinition());
}
public void addConstructorArgs(Object value, Class type, BeanDefinitionBuilder builder) {
public void addConstructorArgs(Object value, Class<?> type, BeanDefinitionBuilder builder) {
addConstructorArgs(value, type, builder.getRawBeanDefinition());
}
@ -191,9 +189,10 @@ public class RedissonNamespaceParserSupport {
}
public String getId(Element element, BeanDefinitionBuilder builder, ParserContext parserContext) {
String id = element != null
? element.getAttribute(ID_ATTRIBUTE)
: null;
String id = null;
if (element != null) {
id = element.getAttribute(ID_ATTRIBUTE);
}
if (!StringUtils.hasText(id)) {
id = generateId(builder, parserContext);
}
@ -263,14 +262,16 @@ public class RedissonNamespaceParserSupport {
}
private BeanDefinitionBuilder preInvoke(Element element, Object obj, String method, Object[] args, ParserContext parserContext, boolean factory) {
Class<?> beanClass = BeanMethodInvoker.class;
if (factory) {
beanClass = MethodInvokingFactoryBean.class;
}
BeanDefinitionBuilder builder
= createBeanDefinitionBuilder(element, parserContext,
factory
? MethodInvokingFactoryBean.class
: BeanMethodInvoker.class);
= createBeanDefinitionBuilder(element, parserContext, beanClass);
if (obj instanceof Class) {
builder.addPropertyValue("staticMethod",
((Class) obj).getName() + "." + method);
((Class<?>) obj).getName() + "." + method);
} else {
builder.addPropertyValue("targetMethod", method);
}
@ -289,7 +290,7 @@ public class RedissonNamespaceParserSupport {
}
public boolean isEligibleAttribute(String attributeName) {
return !attributeName.equals("xmlns")
return !"xmlns".equals(attributeName)
&& !attributeName.startsWith("xmlns:")
&& !ID_ATTRIBUTE.equals(attributeName)
&& !NAME_ATTRIBUTE.equals(attributeName);

Loading…
Cancel
Save