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
9c666b67
Commit
9c666b67
authored
Jun 29, 2015
by
Johannes Stelzer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #85 from steve-oakey/master
Logfile endpoint available when not using spring.boot.admin.url
parents
5f1be530
460753af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
45 deletions
+56
-45
SpringBootAdminClientAutoConfiguration.java
.../admin/config/SpringBootAdminClientAutoConfiguration.java
+49
-45
SpringBootAdminClientAutoConfigurationTest.java
...in/config/SpringBootAdminClientAutoConfigurationTest.java
+7
-0
No files found.
spring-boot-admin-starter-client/src/main/java/de/codecentric/boot/admin/config/SpringBootAdminClientAutoConfiguration.java
View file @
9c666b67
...
...
@@ -34,63 +34,67 @@ import de.codecentric.boot.admin.services.RegistrationApplicationListener;
import
de.codecentric.boot.admin.web.BasicAuthHttpRequestInterceptor
;
/**
* This configuration adds a registrator bean to the spring context. This bean checks periodicaly, if the using
* application is registered at the spring-boot-admin application. If not, it registers itself.
* This configuration adds a registrator bean to the spring context. This bean
* checks periodicaly, if the using application is registered at the
* spring-boot-admin application. If not, it registers itself.
*/
@Configuration
@ConditionalOnProperty
(
"spring.boot.admin.url"
)
@EnableConfigurationProperties
({
AdminProperties
.
class
,
AdminClientProperties
.
class
})
public
class
SpringBootAdminClientAutoConfiguration
{
/**
* Task that registers the application at the spring-boot-admin application.
*/
@Bean
@ConditionalOnMissingBean
public
ApplicationRegistrator
registrator
(
AdminProperties
admin
,
AdminClientProperties
client
)
{
return
new
ApplicationRegistrator
(
createRestTemplate
(
admin
),
admin
,
client
);
}
@ConditionalOnProperty
(
"spring.boot.admin.url"
)
public
static
class
AdminClientRegistrationConfig
{
/**
* Task that registers the application at the spring-boot-admin
* application.
*/
@Bean
@ConditionalOnMissingBean
public
ApplicationRegistrator
registrator
(
AdminProperties
admin
,
AdminClientProperties
client
)
{
return
new
ApplicationRegistrator
(
createRestTemplate
(
admin
),
admin
,
client
);
}
protected
RestTemplate
createRestTemplate
(
AdminProperties
admin
)
{
RestTemplate
template
=
new
RestTemplate
();
template
.
getMessageConverters
().
add
(
new
MappingJackson2HttpMessageConverter
());
protected
RestTemplate
createRestTemplate
(
AdminProperties
admin
)
{
RestTemplate
template
=
new
RestTemplate
();
template
.
getMessageConverters
().
add
(
new
MappingJackson2HttpMessageConverter
());
if
(
admin
.
getUsername
()
!=
null
)
{
template
.
setInterceptors
(
Arrays
.<
ClientHttpRequestInterceptor
>
asList
(
new
BasicAuthHttpRequestInterceptor
(
admin
.
getUsername
(),
admin
.
getPassword
())));
}
if
(
admin
.
getUsername
()
!=
null
)
{
template
.
setInterceptors
(
Arrays
.<
ClientHttpRequestInterceptor
>
asList
(
new
BasicAuthHttpRequestInterceptor
(
admin
.
getUsername
(),
admin
.
getPassword
())));
}
return
template
;
}
return
template
;
}
/**
* TaskRegistrar that triggers the RegistratorTask every ten seconds.
*/
@Bean
public
ScheduledTaskRegistrar
taskRegistrar
(
final
ApplicationRegistrator
registrator
,
AdminProperties
admin
,
final
AdminClientProperties
client
)
{
ScheduledTaskRegistrar
registrar
=
new
ScheduledTaskRegistrar
();
Runnable
registratorTask
=
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
client
.
isServerInitialized
())
{
registrator
.
register
();
/**
* TaskRegistrar that triggers the RegistratorTask every ten seconds.
*/
@Bean
public
ScheduledTaskRegistrar
taskRegistrar
(
final
ApplicationRegistrator
registrator
,
AdminProperties
admin
,
final
AdminClientProperties
client
)
{
ScheduledTaskRegistrar
registrar
=
new
ScheduledTaskRegistrar
();
Runnable
registratorTask
=
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
client
.
isServerInitialized
())
{
registrator
.
register
();
}
}
}
};
};
registrar
.
addFixedRateTask
(
registratorTask
,
admin
.
getPeriod
());
return
registrar
;
}
registrar
.
addFixedRateTask
(
registratorTask
,
admin
.
getPeriod
());
return
registrar
;
}
/**
* ApplicationListener triggering registration after refresh/shutdown
*/
@Bean
public
RegistrationApplicationListener
registrationListener
(
final
ApplicationRegistrator
registrator
,
final
AdminProperties
admin
)
{
return
new
RegistrationApplicationListener
(
admin
,
registrator
);
}
/**
* ApplicationListener triggering registration after refresh/shutdown
*/
@Bean
public
RegistrationApplicationListener
registrationListener
(
final
ApplicationRegistrator
registrator
,
final
AdminProperties
admin
)
{
return
new
RegistrationApplicationListener
(
admin
,
registrator
);
}
@Configuration
...
...
spring-boot-admin-starter-client/src/test/java/de/codecentric/boot/admin/config/SpringBootAdminClientAutoConfigurationTest.java
View file @
9c666b67
...
...
@@ -27,6 +27,13 @@ public class SpringBootAdminClientAutoConfigurationTest {
public
void
not_active
()
{
load
();
assertTrue
(
context
.
getBeansOfType
(
ApplicationRegistrator
.
class
).
isEmpty
());
assertTrue
(
context
.
getBeansOfType
(
LogfileMvcEndpoint
.
class
).
isEmpty
());
}
public
void
not_active_logfile
()
{
load
();
assertTrue
(
context
.
getBeansOfType
(
ApplicationRegistrator
.
class
).
isEmpty
());
context
.
getBean
(
LogfileMvcEndpoint
.
class
);
}
@Test
...
...
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