Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
685babc8
Commit
685babc8
authored
Apr 05, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Use lambdas for map entry iteration where possible"
Closes gh-12626
parent
69bc19e0
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
207 additions
and
174 deletions
+207
-174
ConditionsReportEndpoint.java
...ate/autoconfigure/condition/ConditionsReportEndpoint.java
+10
-18
CompositeHealthIndicatorConfiguration.java
...nfigure/health/CompositeHealthIndicatorConfiguration.java
+3
-2
CompositeReactiveHealthIndicatorConfiguration.java
...health/CompositeReactiveHealthIndicatorConfiguration.java
+3
-2
DataSourceHealthIndicatorAutoConfiguration.java
...gure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java
+4
-4
EnvironmentEndpoint.java
...springframework/boot/actuate/env/EnvironmentEndpoint.java
+7
-4
AutoConfigurationSorter.java
...framework/boot/autoconfigure/AutoConfigurationSorter.java
+6
-6
ImportAutoConfigurationImportSelector.java
.../autoconfigure/ImportAutoConfigurationImportSelector.java
+3
-4
CacheConfigurations.java
...amework/boot/autoconfigure/cache/CacheConfigurations.java
+7
-4
AbstractNestedCondition.java
...boot/autoconfigure/condition/AbstractNestedCondition.java
+3
-2
BeanTypeRegistry.java
...mework/boot/autoconfigure/condition/BeanTypeRegistry.java
+10
-6
ConditionEvaluationReport.java
...ot/autoconfigure/condition/ConditionEvaluationReport.java
+13
-12
OnBeanCondition.java
...amework/boot/autoconfigure/condition/OnBeanCondition.java
+1
-2
NoSuchBeanDefinitionFailureAnalyzer.java
...nostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java
+20
-13
SessionStoreMappings.java
...work/boot/autoconfigure/session/SessionStoreMappings.java
+48
-41
WebServicesAutoConfiguration.java
...toconfigure/webservices/WebServicesAutoConfiguration.java
+1
-1
ProjectGenerationRequest.java
...ework/boot/cli/command/init/ProjectGenerationRequest.java
+3
-2
AnnotatedNodeASTTransformation.java
...ork/boot/cli/compiler/AnnotatedNodeASTTransformation.java
+5
-3
DevToolsSettings.java
...ingframework/boot/devtools/settings/DevToolsSettings.java
+1
-1
AutoConfigureAnnotationProcessor.java
...oconfigureprocessor/AutoConfigureAnnotationProcessor.java
+22
-15
SimpleConfigurationMetadataRepository.java
...rationmetadata/SimpleConfigurationMetadataRepository.java
+5
-3
ConfigurationMetadataAnnotationProcessor.java
...onprocessor/ConfigurationMetadataAnnotationProcessor.java
+2
-2
TypeElementMembers.java
...ework/boot/configurationprocessor/TypeElementMembers.java
+3
-3
TypeUtils.java
...pringframework/boot/configurationprocessor/TypeUtils.java
+2
-1
BuildPropertiesWriter.java
...ingframework/boot/loader/tools/BuildPropertiesWriter.java
+4
-3
PropertiesMergingResourceTransformer.java
...work/boot/maven/PropertiesMergingResourceTransformer.java
+10
-11
Verify.java
.../src/test/java/org/springframework/boot/maven/Verify.java
+5
-4
LoggingSystem.java
.../java/org/springframework/boot/logging/LoggingSystem.java
+6
-5
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java
View file @
685babc8
...
...
@@ -123,29 +123,21 @@ public class ConditionsReportEndpoint {
this
.
negativeMatches
=
new
LinkedHashMap
<>();
this
.
exclusions
=
report
.
getExclusions
();
this
.
unconditionalClasses
=
report
.
getUnconditionalClasses
();
report
.
getConditionAndOutcomesBySource
().
forEach
((
key
,
value
)
->
{
if
(
value
.
isFullMatch
())
{
add
(
this
.
positiveMatches
,
key
,
value
);
}
else
{
add
(
this
.
negativeMatches
,
key
,
value
);
}
});
report
.
getConditionAndOutcomesBySource
().
forEach
(
(
source
,
conditionAndOutcomes
)
->
add
(
source
,
conditionAndOutcomes
));
this
.
parentId
=
context
.
getParent
()
==
null
?
null
:
context
.
getParent
().
getId
();
}
private
void
add
(
Map
<
String
,
MessageAndConditions
>
map
,
String
source
,
ConditionAndOutcomes
conditionAndOutcomes
)
{
private
void
add
(
String
source
,
ConditionAndOutcomes
conditionAndOutcomes
)
{
String
name
=
ClassUtils
.
getShortName
(
source
);
map
.
put
(
name
,
new
MessageAndConditions
(
conditionAndOutcomes
));
}
private
void
add
(
MultiValueMap
<
String
,
MessageAndCondition
>
map
,
String
source
,
ConditionAndOutcomes
conditionAndOutcomes
)
{
String
name
=
ClassUtils
.
getShortName
(
source
);
for
(
ConditionAndOutcome
conditionAndOutcome
:
conditionAndOutcomes
)
{
map
.
add
(
name
,
new
MessageAndCondition
(
conditionAndOutcome
));
if
(
conditionAndOutcomes
.
isFullMatch
())
{
conditionAndOutcomes
.
forEach
((
conditionAndOutcome
)
->
this
.
positiveMatches
.
add
(
name
,
new
MessageAndCondition
(
conditionAndOutcome
)));
}
else
{
this
.
negativeMatches
.
put
(
name
,
new
MessageAndConditions
(
conditionAndOutcomes
));
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeHealthIndicatorConfiguration.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -44,7 +44,8 @@ public abstract class CompositeHealthIndicatorConfiguration<H extends HealthIndi
}
CompositeHealthIndicator
composite
=
new
CompositeHealthIndicator
(
this
.
healthAggregator
);
beans
.
forEach
((
key
,
value
)
->
composite
.
addHealthIndicator
(
key
,
createHealthIndicator
(
value
)));
beans
.
forEach
((
name
,
source
)
->
composite
.
addHealthIndicator
(
name
,
createHealthIndicator
(
source
)));
return
composite
;
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthIndicatorConfiguration.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -43,7 +43,8 @@ public abstract class CompositeReactiveHealthIndicatorConfiguration<H extends Re
}
CompositeReactiveHealthIndicator
composite
=
new
CompositeReactiveHealthIndicator
(
this
.
healthAggregator
);
beans
.
forEach
((
key
,
value
)
->
composite
.
addHealthIndicator
(
key
,
createHealthIndicator
(
value
)));
beans
.
forEach
((
name
,
source
)
->
composite
.
addHealthIndicator
(
name
,
createHealthIndicator
(
source
)));
return
composite
;
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -84,9 +84,9 @@ public class DataSourceHealthIndicatorAutoConfiguration extends
return
null
;
}
Map
<
String
,
DataSource
>
dataSources
=
new
LinkedHashMap
<>();
candidates
.
forEach
((
key
,
valu
e
)
->
{
if
(!(
valu
e
instanceof
AbstractRoutingDataSource
))
{
dataSources
.
put
(
key
,
valu
e
);
candidates
.
forEach
((
name
,
dataSourc
e
)
->
{
if
(!(
dataSourc
e
instanceof
AbstractRoutingDataSource
))
{
dataSources
.
put
(
name
,
dataSourc
e
);
}
});
return
dataSources
;
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java
View file @
685babc8
...
...
@@ -120,10 +120,13 @@ public class EnvironmentEndpoint {
private
PropertySummaryDescriptor
getPropertySummaryDescriptor
(
Map
<
String
,
PropertyValueDescriptor
>
descriptors
)
{
return
descriptors
.
entrySet
().
stream
().
filter
((
entry
)
->
entry
.
getValue
()
!=
null
).
map
((
entry
)
->
new
PropertySummaryDescriptor
(
entry
.
getKey
(),
entry
.
getValue
().
getValue
())).
findFirst
().
orElse
(
null
);
for
(
Map
.
Entry
<
String
,
PropertyValueDescriptor
>
entry
:
descriptors
.
entrySet
())
{
if
(
entry
.
getValue
()
!=
null
)
{
return
new
PropertySummaryDescriptor
(
entry
.
getKey
(),
entry
.
getValue
().
getValue
());
}
}
return
null
;
}
private
Map
<
String
,
PropertyValueDescriptor
>
getPropertySourceDescriptors
(
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java
View file @
685babc8
...
...
@@ -140,14 +140,14 @@ class AutoConfigurationSorter {
}
public
Set
<
String
>
getClassesRequestedAfter
(
String
className
)
{
Set
<
String
>
rtn
=
new
LinkedHashSet
<>();
rtn
.
addAll
(
get
(
className
).
getAfter
());
this
.
classes
.
forEach
((
key
,
value
)
->
{
if
(
value
.
getBefore
().
contains
(
className
))
{
rtn
.
add
(
key
);
Set
<
String
>
classesRequestedAfter
=
new
LinkedHashSet
<>();
classesRequestedAfter
.
addAll
(
get
(
className
).
getAfter
());
this
.
classes
.
forEach
((
name
,
autoConfigurationClass
)
->
{
if
(
autoConfigurationClass
.
getBefore
().
contains
(
className
))
{
classesRequestedAfter
.
add
(
name
);
}
});
return
rtn
;
return
classesRequestedAfter
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -74,9 +74,8 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec
AnnotationAttributes
attributes
)
{
List
<
String
>
candidates
=
new
ArrayList
<>();
Map
<
Class
<?>,
List
<
Annotation
>>
annotations
=
getAnnotations
(
metadata
);
annotations
.
forEach
((
key
,
value
)
->
{
collectCandidateConfigurations
(
key
,
value
,
candidates
);
});
annotations
.
forEach
((
source
,
sourceAnnotations
)
->
collectCandidateConfigurations
(
source
,
sourceAnnotations
,
candidates
));
return
candidates
;
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheConfigurations.java
View file @
685babc8
...
...
@@ -57,10 +57,13 @@ final class CacheConfigurations {
}
public
static
CacheType
getType
(
String
configurationClassName
)
{
return
MAPPINGS
.
entrySet
().
stream
().
filter
((
entry
)
->
entry
.
getValue
().
getName
().
equals
(
configurationClassName
)).
map
(
Map
.
Entry
::
getKey
).
findFirst
().
orElseThrow
(()
->
new
IllegalStateException
(
"Unknown configuration class "
+
configurationClassName
));
for
(
Map
.
Entry
<
CacheType
,
Class
<?>>
entry
:
MAPPINGS
.
entrySet
())
{
if
(
entry
.
getValue
().
getName
().
equals
(
configurationClassName
))
{
return
entry
.
getKey
();
}
}
throw
new
IllegalStateException
(
"Unknown configuration class "
+
configurationClassName
);
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java
View file @
685babc8
...
...
@@ -159,8 +159,9 @@ public abstract class AbstractNestedCondition extends SpringBootCondition
public
List
<
ConditionOutcome
>
getMatchOutcomes
()
{
List
<
ConditionOutcome
>
outcomes
=
new
ArrayList
<>();
this
.
memberConditions
.
forEach
((
metadata
,
conditions
)
->
outcomes
.
add
(
new
MemberOutcomes
(
this
.
context
,
metadata
,
conditions
).
getUltimateOutcome
()));
this
.
memberConditions
.
forEach
((
metadata
,
conditions
)
->
outcomes
.
add
(
new
MemberOutcomes
(
this
.
context
,
metadata
,
conditions
)
.
getUltimateOutcome
()));
return
Collections
.
unmodifiableList
(
outcomes
);
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java
View file @
685babc8
...
...
@@ -113,9 +113,11 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
*/
Set
<
String
>
getNamesForType
(
Class
<?>
type
)
{
updateTypesIfNecessary
();
return
this
.
beanTypes
.
entrySet
().
stream
().
filter
((
entry
)
->
entry
.
getValue
()
!=
null
&&
type
.
isAssignableFrom
(
entry
.
getValue
())).
map
(
Map
.
Entry
::
getKey
).
collect
(
Collectors
.
toCollection
(
LinkedHashSet:
:
new
));
return
this
.
beanTypes
.
entrySet
().
stream
()
.
filter
((
entry
)
->
entry
.
getValue
()
!=
null
&&
type
.
isAssignableFrom
(
entry
.
getValue
()))
.
map
(
Map
.
Entry
::
getKey
)
.
collect
(
Collectors
.
toCollection
(
LinkedHashSet:
:
new
));
}
/**
...
...
@@ -129,9 +131,11 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
*/
Set
<
String
>
getNamesForAnnotation
(
Class
<?
extends
Annotation
>
annotation
)
{
updateTypesIfNecessary
();
return
this
.
beanTypes
.
entrySet
().
stream
().
filter
((
entry
)
->
entry
.
getValue
()
!=
null
&&
AnnotationUtils
.
findAnnotation
(
entry
.
getValue
(),
annotation
)
!=
null
).
map
(
Map
.
Entry
::
getKey
).
collect
(
Collectors
.
toCollection
(
LinkedHashSet:
:
new
));
return
this
.
beanTypes
.
entrySet
().
stream
()
.
filter
((
entry
)
->
entry
.
getValue
()
!=
null
&&
AnnotationUtils
.
findAnnotation
(
entry
.
getValue
(),
annotation
)
!=
null
)
.
map
(
Map
.
Entry
::
getKey
)
.
collect
(
Collectors
.
toCollection
(
LinkedHashSet:
:
new
));
}
@Override
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReport.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -111,9 +111,9 @@ public final class ConditionEvaluationReport {
*/
public
Map
<
String
,
ConditionAndOutcomes
>
getConditionAndOutcomesBySource
()
{
if
(!
this
.
addedAncestorOutcomes
)
{
this
.
outcomes
.
forEach
((
key
,
value
)
->
{
if
(!
value
.
isFullMatch
())
{
addNoMatchOutcomeToAncestors
(
key
);
this
.
outcomes
.
forEach
((
source
,
sourceOutcomes
)
->
{
if
(!
sourceOutcomes
.
isFullMatch
())
{
addNoMatchOutcomeToAncestors
(
source
);
}
});
this
.
addedAncestorOutcomes
=
true
;
...
...
@@ -123,11 +123,11 @@ public final class ConditionEvaluationReport {
private
void
addNoMatchOutcomeToAncestors
(
String
source
)
{
String
prefix
=
source
+
"$"
;
this
.
outcomes
.
forEach
((
key
,
value
)
->
{
if
(
key
.
startsWith
(
prefix
))
{
this
.
outcomes
.
forEach
((
candidateSource
,
sourceOutcomes
)
->
{
if
(
candidateSource
.
startsWith
(
prefix
))
{
ConditionOutcome
outcome
=
ConditionOutcome
.
noMatch
(
ConditionMessage
.
forCondition
(
"Ancestor "
+
source
).
because
(
"did not match"
));
value
.
add
(
ANCESTOR_CONDITION
,
outcome
);
sourceOutcomes
.
add
(
ANCESTOR_CONDITION
,
outcome
);
}
});
}
...
...
@@ -188,12 +188,13 @@ public final class ConditionEvaluationReport {
public
ConditionEvaluationReport
getDelta
(
ConditionEvaluationReport
previousReport
)
{
ConditionEvaluationReport
delta
=
new
ConditionEvaluationReport
();
this
.
outcomes
.
forEach
((
key
,
value
)
->
{
ConditionAndOutcomes
previous
=
previousReport
.
outcomes
.
get
(
key
);
this
.
outcomes
.
forEach
((
source
,
sourceOutcomes
)
->
{
ConditionAndOutcomes
previous
=
previousReport
.
outcomes
.
get
(
source
);
if
(
previous
==
null
||
previous
.
isFullMatch
()
!=
value
.
isFullMatch
())
{
value
.
forEach
((
conditionAndOutcome
)
->
delta
.
recordConditionEvaluation
(
key
,
conditionAndOutcome
.
getCondition
(),
||
previous
.
isFullMatch
()
!=
sourceOutcomes
.
isFullMatch
())
{
sourceOutcomes
.
forEach
(
(
conditionAndOutcome
)
->
delta
.
recordConditionEvaluation
(
source
,
conditionAndOutcome
.
getCondition
(),
conditionAndOutcome
.
getOutcome
()));
}
});
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java
View file @
685babc8
...
...
@@ -175,8 +175,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
reason
.
append
(
" '"
);
reason
.
append
(
key
);
reason
.
append
(
"' "
);
reason
.
append
(
StringUtils
.
collectionToDelimitedString
(
value
,
", "
));
reason
.
append
(
StringUtils
.
collectionToDelimitedString
(
value
,
", "
));
});
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -30,6 +30,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport
;
import
org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcome
;
import
org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcomes
;
import
org.springframework.boot.autoconfigure.condition.ConditionOutcome
;
import
org.springframework.boot.diagnostics.FailureAnalysis
;
import
org.springframework.boot.diagnostics.analyzer.AbstractInjectionFailureAnalyzer
;
...
...
@@ -123,20 +124,26 @@ class NoSuchBeanDefinitionFailureAnalyzer
private
void
collectReportedConditionOutcomes
(
NoSuchBeanDefinitionException
cause
,
List
<
AutoConfigurationResult
>
results
)
{
this
.
report
.
getConditionAndOutcomesBySource
().
forEach
((
key
,
conditionAndOutcomes
)
->
{
Source
source
=
new
Source
(
key
);
if
(!
conditionAndOutcomes
.
isFullMatch
())
{
BeanMethods
methods
=
new
BeanMethods
(
source
,
cause
);
for
(
ConditionAndOutcome
conditionAndOutcome
:
conditionAndOutcomes
)
{
if
(!
conditionAndOutcome
.
getOutcome
().
isMatch
())
{
for
(
MethodMetadata
method
:
methods
)
{
results
.
add
(
new
AutoConfigurationResult
(
method
,
conditionAndOutcome
.
getOutcome
(),
source
.
isMethod
()));
}
}
this
.
report
.
getConditionAndOutcomesBySource
().
forEach
(
(
source
,
sourceOutcomes
)
->
collectReportedConditionOutcomes
(
cause
,
new
Source
(
source
),
sourceOutcomes
,
results
));
}
private
void
collectReportedConditionOutcomes
(
NoSuchBeanDefinitionException
cause
,
Source
source
,
ConditionAndOutcomes
sourceOutcomes
,
List
<
AutoConfigurationResult
>
results
)
{
if
(
sourceOutcomes
.
isFullMatch
())
{
return
;
}
BeanMethods
methods
=
new
BeanMethods
(
source
,
cause
);
for
(
ConditionAndOutcome
conditionAndOutcome
:
sourceOutcomes
)
{
if
(!
conditionAndOutcome
.
getOutcome
().
isMatch
())
{
for
(
MethodMetadata
method
:
methods
)
{
results
.
add
(
new
AutoConfigurationResult
(
method
,
conditionAndOutcome
.
getOutcome
(),
source
.
isMethod
()));
}
}
}
);
}
}
private
void
collectExcludedAutoConfiguration
(
NoSuchBeanDefinitionException
cause
,
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java
View file @
685babc8
...
...
@@ -19,10 +19,10 @@ package org.springframework.boot.autoconfigure.session;
import
java.util.Collections
;
import
java.util.EnumMap
;
import
java.util.Map
;
import
java.util.Objects
;
import
org.springframework.boot.WebApplicationType
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
/**
* Mappings between {@link StoreType} and {@code @Configuration}.
...
...
@@ -32,63 +32,70 @@ import org.springframework.util.Assert;
*/
final
class
SessionStoreMappings
{
private
static
final
Map
<
StoreType
,
Map
<
WebApplicationType
,
Class
<?>>
>
MAPPINGS
;
private
static
final
Map
<
StoreType
,
Configurations
>
MAPPINGS
;
static
{
Map
<
StoreType
,
Map
<
WebApplicationType
,
Class
<?>>>
mappings
=
new
EnumMap
<>(
StoreType
.
class
);
mappings
.
put
(
StoreType
.
REDIS
,
createMapping
(
RedisSessionConfiguration
.
class
,
Map
<
StoreType
,
Configurations
>
mappings
=
new
EnumMap
<>(
StoreType
.
class
);
mappings
.
put
(
StoreType
.
REDIS
,
new
Configurations
(
RedisSessionConfiguration
.
class
,
RedisReactiveSessionConfiguration
.
class
));
mappings
.
put
(
StoreType
.
MONGODB
,
createMapping
(
MongoSessionConfiguration
.
class
,
MongoReactiveSessionConfiguration
.
class
));
mappings
.
put
(
StoreType
.
JDBC
,
createMapping
(
JdbcSessionConfiguration
.
class
));
mappings
.
put
(
StoreType
.
MONGODB
,
new
Configurations
(
MongoSessionConfiguration
.
class
,
MongoReactiveSessionConfiguration
.
class
));
mappings
.
put
(
StoreType
.
JDBC
,
new
Configurations
(
JdbcSessionConfiguration
.
class
,
null
));
mappings
.
put
(
StoreType
.
HAZELCAST
,
createMapping
(
HazelcastSessionConfiguration
.
class
));
mappings
.
put
(
StoreType
.
NONE
,
createMapping
(
NoOpSessionConfiguration
.
class
,
new
Configurations
(
HazelcastSessionConfiguration
.
class
,
null
));
mappings
.
put
(
StoreType
.
NONE
,
new
Configurations
(
NoOpSessionConfiguration
.
class
,
NoOpReactiveSessionConfiguration
.
class
));
MAPPINGS
=
Collections
.
unmodifiableMap
(
mappings
);
}
static
Map
<
WebApplicationType
,
Class
<?>>
createMapping
(
Class
<?>
servletConfiguration
)
{
return
createMapping
(
servletConfiguration
,
null
);
private
SessionStoreMappings
()
{
}
static
Map
<
WebApplicationType
,
Class
<?>>
createMapping
(
Class
<?>
servletConfiguration
,
Class
<?>
reactiveConfiguration
)
{
Map
<
WebApplicationType
,
Class
<?>>
mapping
=
new
EnumMap
<>(
WebApplicationType
.
class
);
mapping
.
put
(
WebApplicationType
.
SERVLET
,
servletConfiguration
);
if
(
reactiveConfiguration
!=
null
)
{
mapping
.
put
(
WebApplicationType
.
REACTIVE
,
reactiveConfiguration
);
}
return
mapping
;
public
static
String
getConfigurationClass
(
WebApplicationType
webApplicationType
,
StoreType
sessionStoreType
)
{
Configurations
configurations
=
MAPPINGS
.
get
(
sessionStoreType
);
Assert
.
state
(
configurations
!=
null
,
()
->
"Unknown session store type "
+
sessionStoreType
);
return
configurations
.
getConfiguration
(
webApplicationType
);
}
private
SessionStoreMappings
()
{
public
static
StoreType
getType
(
WebApplicationType
webApplicationType
,
String
configurationClass
)
{
return
MAPPINGS
.
entrySet
().
stream
()
.
filter
((
entry
)
->
ObjectUtils
.
nullSafeEquals
(
configurationClass
,
entry
.
getValue
().
getConfiguration
(
webApplicationType
)))
.
map
(
Map
.
Entry
::
getKey
).
findFirst
()
.
orElseThrow
(()
->
new
IllegalStateException
(
"Unknown configuration class "
+
configurationClass
));
}
static
String
getConfigurationClass
(
WebApplicationType
webApplicationType
,
StoreType
sessionStoreType
)
{
Map
<
WebApplicationType
,
Class
<?>>
configurationClasses
=
MAPPINGS
.
get
(
sessionStoreType
);
Assert
.
state
(
configurationClasses
!=
null
,
()
->
"Unknown session store type "
+
sessionStoreType
);
Class
<?>
configurationClass
=
configurationClasses
.
get
(
webApplicationType
);
if
(
configurationClass
==
null
)
{
private
static
class
Configurations
{
private
final
Class
<?>
servletConfiguration
;
private
final
Class
<?>
reactiveConfiguration
;
Configurations
(
Class
<?>
servletConfiguration
,
Class
<?>
reactiveConfiguration
)
{
this
.
servletConfiguration
=
servletConfiguration
;
this
.
reactiveConfiguration
=
reactiveConfiguration
;
}
public
String
getConfiguration
(
WebApplicationType
webApplicationType
)
{
switch
(
webApplicationType
)
{
case
SERVLET:
return
getName
(
this
.
servletConfiguration
);
case
REACTIVE:
return
getName
(
this
.
reactiveConfiguration
);
}
return
null
;
}
return
configurationClass
.
getName
();
}
static
StoreType
getType
(
WebApplicationType
webApplicationType
,
String
configurationClassName
)
{
return
MAPPINGS
.
entrySet
().
stream
().
map
(
entry
->
entry
.
getValue
().
entrySet
().
stream
().
filter
(
webAppEntry
->
webAppEntry
.
getKey
()
==
webApplicationType
&&
webAppEntry
.
getValue
().
getName
().
equals
(
configurationClassName
)).
map
(
webAppEntry
->
entry
.
getKey
()).
findFirst
().
orElse
(
null
)).
filter
(
Objects:
:
nonNull
).
findFirst
().
orElseThrow
(()
->
new
IllegalStateException
(
"Unknown configuration class "
+
configurationClassName
));
private
String
getName
(
Class
<?>
configuration
)
{
return
(
configuration
==
null
?
null
:
configuration
.
getName
());
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -422,7 +422,8 @@ class ProjectGenerationRequest {
private
static
void
filter
(
Map
<
String
,
ProjectType
>
projects
,
String
tag
,
String
tagValue
)
{
projects
.
entrySet
().
removeIf
((
entry
)
->
!
tagValue
.
equals
(
entry
.
getValue
().
getTags
().
get
(
tag
)));
projects
.
entrySet
().
removeIf
(
(
entry
)
->
!
tagValue
.
equals
(
entry
.
getValue
().
getTags
().
get
(
tag
)));
}
}
spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/AnnotatedNodeASTTransformation.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -67,8 +67,10 @@ public abstract class AnnotatedNodeASTTransformation implements ASTTransformatio
for
(
ImportNode
importNode
:
module
.
getStarImports
())
{
visitAnnotatedNode
(
importNode
,
annotationNodes
);
}
module
.
getStaticImports
().
forEach
((
key
,
value
)
->
visitAnnotatedNode
(
value
,
annotationNodes
));
module
.
getStaticStarImports
().
forEach
((
key
,
value
)
->
visitAnnotatedNode
(
value
,
annotationNodes
));
module
.
getStaticImports
().
forEach
((
name
,
importNode
)
->
visitAnnotatedNode
(
importNode
,
annotationNodes
));
module
.
getStaticStarImports
().
forEach
((
name
,
importNode
)
->
visitAnnotatedNode
(
importNode
,
annotationNodes
));
for
(
ClassNode
classNode
:
module
.
getClasses
())
{
visitAnnotatedNode
(
classNode
,
annotationNodes
);
classNode
.
visitContents
(
classVisitor
);
...
...
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/settings/DevToolsSettings.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -22,9 +22,11 @@ import java.util.Collections;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
javax.annotation.processing.AbstractProcessor
;
import
javax.annotation.processing.RoundEnvironment
;
...
...
@@ -34,6 +36,7 @@ import javax.lang.model.element.AnnotationMirror;
import
javax.lang.model.element.AnnotationValue
;
import
javax.lang.model.element.Element
;
import
javax.lang.model.element.ElementKind
;
import
javax.lang.model.element.ExecutableElement
;
import
javax.lang.model.element.TypeElement
;
import
javax.lang.model.type.DeclaredType
;
import
javax.lang.model.type.TypeMirror
;
...
...
@@ -155,21 +158,25 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
return
result
.
toString
();
}
@SuppressWarnings
(
"unchecked"
)
private
List
<
Object
>
getValues
(
AnnotationMirror
annotation
)
{
return
annotation
.
getElementValues
().
entrySet
().
stream
().
filter
(
entry
->
{
String
attributeName
=
entry
.
getKey
().
getSimpleName
().
toString
();
return
"name"
.
equals
(
attributeName
)
||
"value"
.
equals
(
attributeName
);
}).
map
((
entry
)
->
{
Object
value
=
entry
.
getValue
().
getValue
();
if
(
value
instanceof
List
)
{
return
((
List
<
AnnotationValue
>)
value
).
stream
().
map
(
annotationValue
->
processValue
(
annotationValue
.
getValue
())).
collect
(
Collectors
.
toList
());
}
else
{
return
Collections
.
singletonList
(
processValue
(
value
));
}
}).
flatMap
(
List:
:
stream
).
collect
(
Collectors
.
toList
());
return
annotation
.
getElementValues
().
entrySet
().
stream
()
.
filter
(
this
::
isNameOrValueAttribute
).
flatMap
(
this
::
getValues
)
.
collect
(
Collectors
.
toList
());
}
private
boolean
isNameOrValueAttribute
(
Entry
<?
extends
ExecutableElement
,
?>
entry
)
{
String
attributeName
=
entry
.
getKey
().
getSimpleName
().
toString
();
return
"name"
.
equals
(
attributeName
)
||
"value"
.
equals
(
attributeName
);
}
@SuppressWarnings
(
"unchecked"
)
private
Stream
<
Object
>
getValues
(
Entry
<?,
?
extends
AnnotationValue
>
entry
)
{
Object
value
=
entry
.
getValue
().
getValue
();
if
(
value
instanceof
List
)
{
return
((
List
<
AnnotationValue
>)
value
).
stream
()
.
map
((
annotation
)
->
processValue
(
annotation
.
getValue
()));
}
return
Stream
.
of
(
processValue
(
value
));
}
private
Object
processValue
(
Object
value
)
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/SimpleConfigurationMetadataRepository.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -93,9 +93,11 @@ public class SimpleConfigurationMetadataRepository
}
else
{
// Merge properties
group
.
getProperties
().
forEach
((
key
,
value
)
->
putIfAbsent
(
existingGroup
.
getProperties
(),
key
,
value
));
group
.
getProperties
().
forEach
((
name
,
value
)
->
putIfAbsent
(
existingGroup
.
getProperties
(),
name
,
value
));
// Merge sources
group
.
getSources
().
forEach
((
key
,
value
)
->
putIfAbsent
(
existingGroup
.
getSources
(),
key
,
value
));
group
.
getSources
().
forEach
((
name
,
value
)
->
putIfAbsent
(
existingGroup
.
getSources
(),
name
,
value
));
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java
View file @
685babc8
...
...
@@ -533,8 +533,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private
Map
<
String
,
Object
>
getAnnotationElementValues
(
AnnotationMirror
annotation
)
{
Map
<
String
,
Object
>
values
=
new
LinkedHashMap
<>();
annotation
.
getElementValues
().
forEach
((
key
,
value
)
->
values
.
put
(
key
.
getSimpleName
().
toString
(),
value
.
getValue
()));
annotation
.
getElementValues
().
forEach
((
name
,
value
)
->
values
.
put
(
name
.
getSimpleName
().
toString
(),
value
.
getValue
()));
return
values
;
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java
View file @
685babc8
...
...
@@ -78,9 +78,9 @@ class TypeElementMembers {
processField
(
field
);
}
try
{
this
.
fieldValuesParser
.
getFieldValues
(
element
).
forEach
((
key
,
value
)
->
{
if
(!
this
.
fieldValues
.
containsKey
(
key
))
{
this
.
fieldValues
.
put
(
key
,
value
);
this
.
fieldValuesParser
.
getFieldValues
(
element
).
forEach
((
name
,
value
)
->
{
if
(!
this
.
fieldValues
.
containsKey
(
name
))
{
this
.
fieldValues
.
put
(
name
,
value
);
}
});
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java
View file @
685babc8
...
...
@@ -62,7 +62,8 @@ class TypeUtils {
static
{
Map
<
String
,
TypeKind
>
primitives
=
new
HashMap
<>();
PRIMITIVE_WRAPPERS
.
forEach
((
key
,
value
)
->
primitives
.
put
(
value
.
getName
(),
key
));
PRIMITIVE_WRAPPERS
.
forEach
(
(
kind
,
wrapperClass
)
->
primitives
.
put
(
wrapperClass
.
getName
(),
kind
));
WRAPPER_TO_PRIMITIVE
=
primitives
;
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/BuildPropertiesWriter.java
View file @
685babc8
...
...
@@ -78,7 +78,8 @@ public final class BuildPropertiesWriter {
DateTimeFormatter
.
ISO_INSTANT
.
format
(
project
.
getTime
()));
}
if
(
project
.
getAdditionalProperties
()
!=
null
)
{
project
.
getAdditionalProperties
().
forEach
((
key
,
value
)
->
properties
.
put
(
"build."
+
key
,
value
));
project
.
getAdditionalProperties
()
.
forEach
((
name
,
value
)
->
properties
.
put
(
"build."
+
name
,
value
));
}
return
properties
;
}
...
...
@@ -114,9 +115,9 @@ public final class BuildPropertiesWriter {
private
static
void
validateAdditionalProperties
(
Map
<
String
,
String
>
additionalProperties
)
{
if
(
additionalProperties
!=
null
)
{
additionalProperties
.
forEach
((
key
,
value
)
->
{
additionalProperties
.
forEach
((
name
,
value
)
->
{
if
(
value
==
null
)
{
throw
new
NullAdditionalPropertyValueException
(
key
);
throw
new
NullAdditionalPropertyValueException
(
name
);
}
});
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -58,18 +58,17 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer
}
@Override
public
void
processResource
(
String
resource
,
InputStream
i
s
,
public
void
processResource
(
String
resource
,
InputStream
i
nputStream
,
List
<
Relocator
>
relocators
)
throws
IOException
{
Properties
properties
=
new
Properties
();
properties
.
load
(
is
);
is
.
close
();
properties
.
forEach
((
key
,
valueObject
)
->
{
String
name
=
(
String
)
key
;
String
value
=
(
String
)
valueObject
;
String
existing
=
this
.
data
.
getProperty
(
name
);
this
.
data
.
setProperty
(
name
,
existing
==
null
?
value
:
existing
+
","
+
value
);
});
properties
.
load
(
inputStream
);
inputStream
.
close
();
properties
.
forEach
((
name
,
value
)
->
process
((
String
)
name
,
(
String
)
value
));
}
private
void
process
(
String
name
,
String
value
)
{
String
existing
=
this
.
data
.
getProperty
(
name
);
this
.
data
.
setProperty
(
name
,
(
existing
==
null
?
value
:
existing
+
","
+
value
));
}
@Override
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/Verify.java
View file @
685babc8
...
...
@@ -140,10 +140,11 @@ public final class Verify {
}
private
ZipEntry
getEntryStartingWith
(
String
entryName
)
{
return
this
.
content
.
entrySet
().
stream
().
filter
(
entry
->
entry
.
getKey
().
startsWith
(
entryName
)).
map
(
Map
.
Entry
::
getValue
).
findFirst
().
orElseThrow
(()
->
new
IllegalStateException
(
"Unable to find entry starting with "
+
entryName
));
return
this
.
content
.
entrySet
().
stream
()
.
filter
(
entry
->
entry
.
getKey
().
startsWith
(
entryName
))
.
map
(
Map
.
Entry
::
getValue
).
findFirst
()
.
orElseThrow
(()
->
new
IllegalStateException
(
"Unable to find entry starting with "
+
entryName
));
}
public
boolean
hasEntry
(
String
entry
)
{
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java
View file @
685babc8
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -156,10 +156,11 @@ public abstract class LoggingSystem {
}
return
get
(
classLoader
,
loggingSystem
);
}
return
SYSTEMS
.
entrySet
().
stream
().
filter
((
entry
)
->
ClassUtils
.
isPresent
(
entry
.
getKey
(),
classLoader
)).
map
(
entry
->
get
(
classLoader
,
entry
.
getValue
())).
findFirst
().
orElseThrow
(()
->
new
IllegalStateException
(
"No suitable logging system located"
));
return
SYSTEMS
.
entrySet
().
stream
()
.
filter
((
entry
)
->
ClassUtils
.
isPresent
(
entry
.
getKey
(),
classLoader
))
.
map
((
entry
)
->
get
(
classLoader
,
entry
.
getValue
())).
findFirst
()
.
orElseThrow
(()
->
new
IllegalStateException
(
"No suitable logging system located"
));
}
private
static
LoggingSystem
get
(
ClassLoader
classLoader
,
String
loggingSystemClass
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment