Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
Overview
Details
Activity
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
openSource
spring-boot-admin
Commits
9a80b625
Commit
9a80b625
authored
Apr 05, 2018
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to Spring Boot 2.0.1
parent
db8b2a7d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
216 deletions
+25
-216
pom.xml
pom.xml
+1
-1
SpringBootAdminApplication.java
...de/codecentric/boot/admin/SpringBootAdminApplication.java
+3
-30
AdminServerUiAutoConfiguration.java
...dmin/server/ui/config/AdminServerUiAutoConfiguration.java
+9
-16
InstanceExchangeFilterFunctions.java
...in/server/web/client/InstanceExchangeFilterFunctions.java
+10
-167
AbstractAdminApplicationTest.java
...ntric/boot/admin/server/AbstractAdminApplicationTest.java
+1
-1
InstancesControllerIntegrationTest.java
.../admin/server/web/InstancesControllerIntegrationTest.java
+1
-1
No files found.
pom.xml
View file @
9a80b625
...
...
@@ -27,7 +27,7 @@
<url>
https://github.com/codecentric/spring-boot-admin/
</url>
<properties>
<revision>
2.0.0-SNAPSHOT
</revision>
<spring-boot.version>
2.0.
0
.RELEASE
</spring-boot.version>
<spring-boot.version>
2.0.
1
.RELEASE
</spring-boot.version>
<spring-cloud.version>
Finchley.M9
</spring-cloud.version>
<hazelcast-tests.version>
3.9.2
</hazelcast-tests.version>
<java.version>
1.8
</java.version>
...
...
spring-boot-admin-samples/spring-boot-admin-sample-reactive/src/main/java/de/codecentric/boot/admin/SpringBootAdminApplication.java
View file @
9a80b625
...
...
@@ -20,15 +20,11 @@ import de.codecentric.boot.admin.server.config.AdminServerProperties;
import
de.codecentric.boot.admin.server.config.EnableAdminServer
;
import
de.codecentric.boot.admin.server.domain.entities.InstanceRepository
;
import
de.codecentric.boot.admin.server.notify.LoggingNotifier
;
import
de.codecentric.boot.admin.server.notify.RemindingNotifier
;
import
de.codecentric.boot.admin.server.notify.filter.FilteringNotifier
;
import
java.time.Duration
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.security.config.web.server.ServerHttpSecurity
;
import
org.springframework.security.web.server.SecurityWebFilterChain
;
...
...
@@ -72,31 +68,8 @@ public class SpringBootAdminApplication {
// @formatter:on
}
@Configuration
public
static
class
NotifierConfig
{
private
final
InstanceRepository
repository
;
public
NotifierConfig
(
InstanceRepository
repository
)
{
this
.
repository
=
repository
;
}
@Primary
@Bean
(
initMethod
=
"start"
,
destroyMethod
=
"stop"
)
public
RemindingNotifier
remindingNotifier
()
{
RemindingNotifier
notifier
=
new
RemindingNotifier
(
filteringNotifier
(),
repository
);
notifier
.
setReminderPeriod
(
Duration
.
ofMinutes
(
10
));
notifier
.
setCheckReminderInverval
(
Duration
.
ofSeconds
(
10
));
return
notifier
;
}
@Bean
public
FilteringNotifier
filteringNotifier
()
{
return
new
FilteringNotifier
(
loggerNotifier
(),
repository
);
}
@Bean
public
LoggingNotifier
loggerNotifier
()
{
return
new
LoggingNotifier
(
repository
);
}
@Bean
public
LoggingNotifier
loggerNotifier
(
InstanceRepository
repository
)
{
return
new
LoggingNotifier
(
repository
);
}
}
spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/config/AdminServerUiAutoConfiguration.java
View file @
9a80b625
...
...
@@ -22,6 +22,7 @@ import de.codecentric.boot.admin.server.config.AdminServerWebConfiguration;
import
de.codecentric.boot.admin.server.ui.web.UiController
;
import
java.nio.charset.StandardCharsets
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
...
...
@@ -75,14 +76,10 @@ public class AdminServerUiAutoConfiguration {
@ConditionalOnWebApplication
(
type
=
ConditionalOnWebApplication
.
Type
.
REACTIVE
)
@Configuration
public
static
class
ReactiveUiConfiguration
implements
WebFluxConfigurer
{
private
final
AdminServerUiProperties
uiProperties
;
private
final
AdminServerProperties
adminServerProperties
;
public
ReactiveUiConfiguration
(
AdminServerUiProperties
uiProperties
,
AdminServerProperties
adminServerProperties
)
{
this
.
uiProperties
=
uiProperties
;
this
.
adminServerProperties
=
adminServerProperties
;
}
@Autowired
private
AdminServerUiProperties
uiProperties
;
@Autowired
private
AdminServerProperties
adminServerProperties
;
@Override
public
void
addResourceHandlers
(
org
.
springframework
.
web
.
reactive
.
config
.
ResourceHandlerRegistry
registry
)
{
...
...
@@ -95,14 +92,10 @@ public class AdminServerUiAutoConfiguration {
@ConditionalOnWebApplication
(
type
=
ConditionalOnWebApplication
.
Type
.
SERVLET
)
@Configuration
public
static
class
ServletUiConfiguration
implements
WebMvcConfigurer
{
private
final
AdminServerUiProperties
uiProperties
;
private
final
AdminServerProperties
adminServerProperties
;
public
ServletUiConfiguration
(
AdminServerUiProperties
uiProperties
,
AdminServerProperties
adminServerProperties
)
{
this
.
uiProperties
=
uiProperties
;
this
.
adminServerProperties
=
adminServerProperties
;
}
@Autowired
private
AdminServerUiProperties
uiProperties
;
@Autowired
private
AdminServerProperties
adminServerProperties
;
@Override
public
void
addResourceHandlers
(
org
.
springframework
.
web
.
servlet
.
config
.
annotation
.
ResourceHandlerRegistry
registry
)
{
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/client/InstanceExchangeFilterFunctions.java
View file @
9a80b625
...
...
@@ -22,22 +22,11 @@ import reactor.core.publisher.Flux;
import
reactor.core.publisher.Mono
;
import
java.net.URI
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.OptionalLong
;
import
java.util.function.Function
;
import
org.springframework.core.ParameterizedTypeReference
;
import
org.springframework.core.io.buffer.DataBuffer
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseCookie
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.client.reactive.ClientHttpResponse
;
import
org.springframework.http.client.reactive.ClientHttpResponseDecorator
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.reactive.function.BodyExtractor
;
import
org.springframework.web.reactive.function.BodyExtractors
;
import
org.springframework.web.reactive.function.client.ClientRequest
;
import
org.springframework.web.reactive.function.client.ClientResponse
;
import
org.springframework.web.reactive.function.client.ExchangeFilterFunction
;
...
...
@@ -47,7 +36,6 @@ import org.springframework.web.util.UriComponentsBuilder;
import
static
de
.
codecentric
.
boot
.
admin
.
server
.
utils
.
MediaType
.
ACTUATOR_V1_MEDIATYPE
;
import
static
de
.
codecentric
.
boot
.
admin
.
server
.
utils
.
MediaType
.
ACTUATOR_V2_MEDIATYPE
;
import
static
java
.
util
.
Collections
.
emptyList
;
import
static
java
.
util
.
Collections
.
singletonList
;
public
final
class
InstanceExchangeFilterFunctions
{
...
...
@@ -64,9 +52,8 @@ public final class InstanceExchangeFilterFunctions {
public
static
ExchangeFilterFunction
setInstance
(
Mono
<
Instance
>
instance
)
{
return
(
request
,
next
)
->
instance
.
map
(
i
->
ClientRequest
.
from
(
request
).
attribute
(
ATTRIBUTE_INSTANCE
,
i
).
build
())
.
switchIfEmpty
(
request
.
url
().
isAbsolute
()
?
Mono
.
just
(
request
)
:
Mono
.
error
(
new
InstanceWebClientException
(
"Instance not found"
)))
.
switchIfEmpty
(
request
.
url
().
isAbsolute
()
?
Mono
.
just
(
request
)
:
Mono
.
error
(
new
InstanceWebClientException
(
"Instance not found"
)))
.
flatMap
(
next:
:
exchange
);
}
...
...
@@ -143,157 +130,13 @@ public final class InstanceExchangeFilterFunctions {
};
}
private
static
Function
<
ClientResponse
,
Mono
<
ClientResponse
>>
convertClientResponse
(
Function
<
Flux
<
DataBuffer
>,
Flux
<
DataBuffer
>>
bodConverter
,
MediaType
contentType
)
{
return
response
->
Mono
.
just
(
new
ConvertedBodyResponse
(
response
,
bodConverter
,
contentType
));
}
private
static
class
ConvertedBodyResponse
implements
ClientResponse
{
private
final
ClientResponse
response
;
private
final
Function
<
Flux
<
DataBuffer
>,
Flux
<
DataBuffer
>>
converter
;
private
final
Headers
headers
;
private
ConvertedBodyResponse
(
ClientResponse
response
,
Function
<
Flux
<
DataBuffer
>,
Flux
<
DataBuffer
>>
converter
,
MediaType
contentType
)
{
this
.
response
=
response
;
this
.
converter
=
converter
;
this
.
headers
=
new
Headers
()
{
@Override
public
OptionalLong
contentLength
()
{
return
OptionalLong
.
empty
();
}
@Override
public
Optional
<
MediaType
>
contentType
()
{
return
Optional
.
ofNullable
(
contentType
);
}
@Override
public
List
<
String
>
header
(
String
headerName
)
{
if
(
headerName
.
equals
(
HttpHeaders
.
CONTENT_TYPE
))
{
return
singletonList
(
contentType
.
toString
());
}
if
(
headerName
.
equals
(
HttpHeaders
.
CONTENT_LENGTH
))
{
return
emptyList
();
}
return
response
.
headers
().
header
(
headerName
);
}
@Override
public
HttpHeaders
asHttpHeaders
()
{
HttpHeaders
newHeaders
=
new
HttpHeaders
();
newHeaders
.
putAll
(
response
.
headers
().
asHttpHeaders
());
newHeaders
.
replace
(
HttpHeaders
.
CONTENT_TYPE
,
singletonList
(
contentType
.
toString
()));
newHeaders
.
remove
(
HttpHeaders
.
CONTENT_LENGTH
);
return
HttpHeaders
.
readOnlyHttpHeaders
(
newHeaders
);
}
};
}
@Override
public
HttpStatus
statusCode
()
{
return
response
.
statusCode
();
}
@Override
public
Headers
headers
()
{
return
headers
;
}
@Override
public
MultiValueMap
<
String
,
ResponseCookie
>
cookies
()
{
return
response
.
cookies
();
}
@Override
public
<
T
>
T
body
(
BodyExtractor
<
T
,
?
super
ClientHttpResponse
>
extractor
)
{
return
response
.
body
((
inputMessage
,
context
)
->
{
ClientHttpResponse
convertedMessage
=
new
ClientHttpResponseDecorator
(
inputMessage
)
{
@Override
public
Flux
<
DataBuffer
>
getBody
()
{
return
super
.
getBody
().
transform
(
ConvertedBodyResponse
.
this
.
converter
);
}
};
return
extractor
.
extract
(
convertedMessage
,
context
);
});
}
@Override
public
<
T
>
Mono
<
T
>
bodyToMono
(
Class
<?
extends
T
>
elementClass
)
{
if
(
Void
.
class
.
isAssignableFrom
(
elementClass
))
{
return
response
.
bodyToMono
(
elementClass
);
}
else
{
return
body
(
BodyExtractors
.
toMono
(
elementClass
));
}
}
@Override
public
<
T
>
Mono
<
T
>
bodyToMono
(
ParameterizedTypeReference
<
T
>
typeReference
)
{
if
(
Void
.
class
.
isAssignableFrom
(
typeReference
.
getType
().
getClass
()))
{
return
response
.
bodyToMono
(
typeReference
);
}
else
{
return
body
(
BodyExtractors
.
toMono
(
typeReference
));
}
}
@Override
public
<
T
>
Flux
<
T
>
bodyToFlux
(
Class
<?
extends
T
>
elementClass
)
{
if
(
Void
.
class
.
isAssignableFrom
(
elementClass
))
{
return
response
.
bodyToFlux
(
elementClass
);
}
else
{
return
body
(
BodyExtractors
.
toFlux
(
elementClass
));
}
}
@Override
public
<
T
>
Flux
<
T
>
bodyToFlux
(
ParameterizedTypeReference
<
T
>
typeReference
)
{
if
(
Void
.
class
.
isAssignableFrom
(
typeReference
.
getType
().
getClass
()))
{
return
response
.
bodyToFlux
(
typeReference
);
}
else
{
return
body
(
BodyExtractors
.
toFlux
(
typeReference
));
}
}
@Override
public
<
T
>
Mono
<
ResponseEntity
<
T
>>
toEntity
(
Class
<
T
>
bodyType
)
{
if
(
Void
.
class
.
isAssignableFrom
(
bodyType
))
{
return
response
.
toEntity
(
bodyType
);
}
else
{
return
toEntityInternal
(
bodyToMono
(
bodyType
));
}
}
@Override
public
<
T
>
Mono
<
ResponseEntity
<
T
>>
toEntity
(
ParameterizedTypeReference
<
T
>
typeReference
)
{
if
(
Void
.
class
.
isAssignableFrom
(
typeReference
.
getType
().
getClass
()))
{
return
response
.
toEntity
(
typeReference
);
}
else
{
return
toEntityInternal
(
bodyToMono
(
typeReference
));
}
}
private
<
T
>
Mono
<
ResponseEntity
<
T
>>
toEntityInternal
(
Mono
<
T
>
bodyMono
)
{
HttpHeaders
headers
=
headers
().
asHttpHeaders
();
HttpStatus
statusCode
=
statusCode
();
return
bodyMono
.
map
(
body
->
new
ResponseEntity
<>(
body
,
headers
,
statusCode
))
.
switchIfEmpty
(
Mono
.
defer
(()
->
Mono
.
just
(
new
ResponseEntity
<>(
headers
,
statusCode
))));
}
@Override
public
<
T
>
Mono
<
ResponseEntity
<
List
<
T
>>>
toEntityList
(
Class
<
T
>
responseType
)
{
return
toEntityListInternal
(
bodyToFlux
(
responseType
));
}
@Override
public
<
T
>
Mono
<
ResponseEntity
<
List
<
T
>>>
toEntityList
(
ParameterizedTypeReference
<
T
>
typeReference
)
{
return
toEntityListInternal
(
bodyToFlux
(
typeReference
));
}
private
<
T
>
Mono
<
ResponseEntity
<
List
<
T
>>>
toEntityListInternal
(
Flux
<
T
>
bodyFlux
)
{
HttpHeaders
headers
=
headers
().
asHttpHeaders
();
HttpStatus
statusCode
=
statusCode
();
return
bodyFlux
.
collectList
().
map
(
body
->
new
ResponseEntity
<>(
body
,
headers
,
statusCode
));
}
private
static
Function
<
ClientResponse
,
Mono
<
ClientResponse
>>
convertClientResponse
(
Function
<
Flux
<
DataBuffer
>,
Flux
<
DataBuffer
>>
bodConverter
,
MediaType
contentType
)
{
return
response
->
{
ClientResponse
convertedResponse
=
ClientResponse
.
from
(
response
).
headers
(
headers
->
{
headers
.
replace
(
HttpHeaders
.
CONTENT_TYPE
,
singletonList
(
contentType
.
toString
()));
headers
.
remove
(
HttpHeaders
.
CONTENT_LENGTH
);
}).
body
(
response
.
bodyToFlux
(
DataBuffer
.
class
).
transform
(
bodConverter
)).
build
();
return
Mono
.
just
(
convertedResponse
);
};
}
}
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/AbstractAdminApplicationTest.java
View file @
9a80b625
...
...
@@ -76,7 +76,7 @@ public abstract class AbstractAdminApplicationTest {
return
webClient
.
get
().
uri
(
"/instances/events"
).
accept
(
MediaType
.
TEXT_EVENT_STREAM
)
.
exchange
()
.
expectStatus
().
isOk
()
.
expectHeader
().
contentType
(
MediaType
.
TEXT_EVENT_STREAM
)
.
expectHeader
().
contentType
CompatibleWith
(
MediaType
.
TEXT_EVENT_STREAM
)
.
returnResult
(
JSONObject
.
class
).
getResponseBody
();
//@formatter:on
}
...
...
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/web/InstancesControllerIntegrationTest.java
View file @
9a80b625
...
...
@@ -255,7 +255,7 @@ public class InstancesControllerIntegrationTest {
return
this
.
client
.
get
().
uri
(
"/instances/events"
).
accept
(
MediaType
.
TEXT_EVENT_STREAM
)
.
exchange
()
.
expectStatus
().
isOk
()
.
expectHeader
().
contentType
(
MediaType
.
TEXT_EVENT_STREAM
)
.
expectHeader
().
contentType
CompatibleWith
(
MediaType
.
TEXT_EVENT_STREAM
)
.
returnResult
(
RESPONSE_TYPE
).
getResponseBody
();
//@formatter:on
}
...
...
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