Skip to content

Commit b17a6f9

Browse files
committed
Polishing
1 parent 4c05020 commit b17a6f9

File tree

4 files changed

+39
-27
lines changed

4 files changed

+39
-27
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,20 @@ private Callback[] getCallbacks(Class<?> rootClass) throws Exception {
292292
// unadvised but can return this). May be required to expose the proxy.
293293
Callback targetInterceptor;
294294
if (exposeProxy) {
295-
targetInterceptor = isStatic ?
295+
targetInterceptor = (isStatic ?
296296
new StaticUnadvisedExposedInterceptor(this.advised.getTargetSource().getTarget()) :
297-
new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource());
297+
new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource()));
298298
}
299299
else {
300-
targetInterceptor = isStatic ?
300+
targetInterceptor = (isStatic ?
301301
new StaticUnadvisedInterceptor(this.advised.getTargetSource().getTarget()) :
302-
new DynamicUnadvisedInterceptor(this.advised.getTargetSource());
302+
new DynamicUnadvisedInterceptor(this.advised.getTargetSource()));
303303
}
304304

305305
// Choose a "direct to target" dispatcher (used for
306306
// unadvised calls to static targets that cannot return this).
307-
Callback targetDispatcher = isStatic ?
308-
new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp();
307+
Callback targetDispatcher = (isStatic ?
308+
new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp());
309309

310310
Callback[] mainCallbacks = new Callback[] {
311311
aopInterceptor, // for normal advice
@@ -810,12 +810,16 @@ public int accept(Method method) {
810810
}
811811
// We must always proxy equals, to direct calls to this.
812812
if (AopUtils.isEqualsMethod(method)) {
813-
logger.debug("Found 'equals' method: " + method);
813+
if (logger.isDebugEnabled()) {
814+
logger.debug("Found 'equals' method: " + method);
815+
}
814816
return INVOKE_EQUALS;
815817
}
816818
// We must always calculate hashCode based on the proxy.
817819
if (AopUtils.isHashCodeMethod(method)) {
818-
logger.debug("Found 'hashCode' method: " + method);
820+
if (logger.isDebugEnabled()) {
821+
logger.debug("Found 'hashCode' method: " + method);
822+
}
819823
return INVOKE_HASHCODE;
820824
}
821825
Class<?> targetClass = this.advised.getTargetClass();

spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -147,16 +147,21 @@ else if (handlerOrClassName instanceof NamespaceHandler) {
147147
* Load the specified NamespaceHandler mappings lazily.
148148
*/
149149
private Map<String, Object> getHandlerMappings() {
150-
if (this.handlerMappings == null) {
150+
Map<String, Object> handlerMappings = this.handlerMappings;
151+
if (handlerMappings == null) {
151152
synchronized (this) {
152-
if (this.handlerMappings == null) {
153+
handlerMappings = this.handlerMappings;
154+
if (handlerMappings == null) {
155+
if (logger.isDebugEnabled()) {
156+
logger.debug("Loading NamespaceHandler mappings from [" + this.handlerMappingsLocation + "]");
157+
}
153158
try {
154159
Properties mappings =
155160
PropertiesLoaderUtils.loadAllProperties(this.handlerMappingsLocation, this.classLoader);
156161
if (logger.isDebugEnabled()) {
157162
logger.debug("Loaded NamespaceHandler mappings: " + mappings);
158163
}
159-
Map<String, Object> handlerMappings = new ConcurrentHashMap<String, Object>(mappings.size());
164+
handlerMappings = new ConcurrentHashMap<String, Object>(mappings.size());
160165
CollectionUtils.mergePropertiesIntoMap(mappings, handlerMappings);
161166
this.handlerMappings = handlerMappings;
162167
}
@@ -167,7 +172,7 @@ private Map<String, Object> getHandlerMappings() {
167172
}
168173
}
169174
}
170-
return this.handlerMappings;
175+
return handlerMappings;
171176
}
172177

173178

spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -122,7 +122,7 @@ public InputSource resolveEntity(String publicId, String systemId) throws IOExce
122122
}
123123
catch (FileNotFoundException ex) {
124124
if (logger.isDebugEnabled()) {
125-
logger.debug("Couldn't find XML schema [" + systemId + "]: " + resource, ex);
125+
logger.debug("Could not find XML schema [" + systemId + "]: " + resource, ex);
126126
}
127127
}
128128
}
@@ -134,9 +134,11 @@ public InputSource resolveEntity(String publicId, String systemId) throws IOExce
134134
* Load the specified schema mappings lazily.
135135
*/
136136
private Map<String, String> getSchemaMappings() {
137-
if (this.schemaMappings == null) {
137+
Map<String, String> schemaMappings = this.schemaMappings;
138+
if (schemaMappings == null) {
138139
synchronized (this) {
139-
if (this.schemaMappings == null) {
140+
schemaMappings = this.schemaMappings;
141+
if (schemaMappings == null) {
140142
if (logger.isDebugEnabled()) {
141143
logger.debug("Loading schema mappings from [" + this.schemaMappingsLocation + "]");
142144
}
@@ -146,7 +148,7 @@ private Map<String, String> getSchemaMappings() {
146148
if (logger.isDebugEnabled()) {
147149
logger.debug("Loaded schema mappings: " + mappings);
148150
}
149-
Map<String, String> schemaMappings = new ConcurrentHashMap<String, String>(mappings.size());
151+
schemaMappings = new ConcurrentHashMap<String, String>(mappings.size());
150152
CollectionUtils.mergePropertiesIntoMap(mappings, schemaMappings);
151153
this.schemaMappings = schemaMappings;
152154
}
@@ -157,7 +159,7 @@ private Map<String, String> getSchemaMappings() {
157159
}
158160
}
159161
}
160-
return this.schemaMappings;
162+
return schemaMappings;
161163
}
162164

163165

spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -314,7 +314,7 @@ public int loadBeanDefinitions(Resource resource) throws BeanDefinitionStoreExce
314314
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
315315
Assert.notNull(encodedResource, "EncodedResource must not be null");
316316
if (logger.isInfoEnabled()) {
317-
logger.info("Loading XML bean definitions from " + encodedResource.getResource());
317+
logger.info("Loading XML bean definitions from " + encodedResource);
318318
}
319319

320320
Set<EncodedResource> currentResources = this.resourcesCurrentlyBeingLoaded.get();
@@ -430,13 +430,13 @@ protected Document doLoadDocument(InputSource inputSource, Resource resource) th
430430
getValidationModeForResource(resource), isNamespaceAware());
431431
}
432432

433-
434433
/**
435-
* Gets the validation mode for the specified {@link Resource}. If no explicit
436-
* validation mode has been configured then the validation mode is
437-
* {@link #detectValidationMode detected}.
434+
* Determine the validation mode for the specified {@link Resource}.
435+
* If no explicit validation mode has been configured, then the validation
436+
* mode gets {@link #detectValidationMode detected} from the given resource.
438437
* <p>Override this method if you would like full control over the validation
439438
* mode, even when something other than {@link #VALIDATION_AUTO} was set.
439+
* @see #detectValidationMode
440440
*/
441441
protected int getValidationModeForResource(Resource resource) {
442442
int validationModeToUse = getValidationMode();
@@ -454,7 +454,7 @@ protected int getValidationModeForResource(Resource resource) {
454454
}
455455

456456
/**
457-
* Detects which kind of validation to perform on the XML file identified
457+
* Detect which kind of validation to perform on the XML file identified
458458
* by the supplied {@link Resource}. If the file has a {@code DOCTYPE}
459459
* definition then DTD validation is used otherwise XSD validation is assumed.
460460
* <p>Override this method if you would like to customize resolution
@@ -540,7 +540,8 @@ public NamespaceHandlerResolver getNamespaceHandlerResolver() {
540540

541541
/**
542542
* Create the default implementation of {@link NamespaceHandlerResolver} used if none is specified.
543-
* Default implementation returns an instance of {@link DefaultNamespaceHandlerResolver}.
543+
* <p>The default implementation returns an instance of {@link DefaultNamespaceHandlerResolver}.
544+
* @see DefaultNamespaceHandlerResolver#DefaultNamespaceHandlerResolver(ClassLoader)
544545
*/
545546
protected NamespaceHandlerResolver createDefaultNamespaceHandlerResolver() {
546547
return new DefaultNamespaceHandlerResolver(getResourceLoader().getClassLoader());

0 commit comments

Comments
 (0)