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
0db4fe16
Commit
0db4fe16
authored
Nov 11, 2015
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce duplicated ZuulConfiguration by inheriting
parent
8a6cdfa9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
62 deletions
+21
-62
RevereseZuulProxyConfiguration.java
...ric/boot/admin/config/RevereseZuulProxyConfiguration.java
+21
-62
No files found.
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/config/RevereseZuulProxyConfiguration.java
View file @
0db4fe16
...
@@ -15,26 +15,18 @@
...
@@ -15,26 +15,18 @@
*/
*/
package
de
.
codecentric
.
boot
.
admin
.
config
;
package
de
.
codecentric
.
boot
.
admin
.
config
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.trace.TraceRepository
;
import
org.springframework.boot.actuate.trace.TraceRepository
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.cloud.netflix.zuul.Zuul
FilterInitializer
;
import
org.springframework.cloud.netflix.zuul.Zuul
Configuration
;
import
org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper
;
import
org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper
;
import
org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter
;
import
org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter
;
import
org.springframework.cloud.netflix.zuul.filters.pre.DebugFilter
;
import
org.springframework.cloud.netflix.zuul.filters.pre.FormBodyWrapperFilter
;
import
org.springframework.cloud.netflix.zuul.filters.pre.Servlet30WrapperFilter
;
import
org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter
;
import
org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter
;
import
org.springframework.cloud.netflix.zuul.web.ZuulController
;
import
org.springframework.cloud.netflix.zuul.web.ZuulHandlerMapping
;
import
org.springframework.cloud.netflix.zuul.web.ZuulHandlerMapping
;
import
org.springframework.context.ApplicationEvent
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.PayloadApplicationEvent
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.event.EventListener
;
import
com.netflix.zuul.ZuulFilter
;
import
de.codecentric.boot.admin.controller.RegistryController
;
import
de.codecentric.boot.admin.controller.RegistryController
;
import
de.codecentric.boot.admin.event.RoutesOutdatedEvent
;
import
de.codecentric.boot.admin.event.RoutesOutdatedEvent
;
...
@@ -43,7 +35,7 @@ import de.codecentric.boot.admin.zuul.ApplicationRouteLocator;
...
@@ -43,7 +35,7 @@ import de.codecentric.boot.admin.zuul.ApplicationRouteLocator;
import
de.codecentric.boot.admin.zuul.PreDecorationFilter
;
import
de.codecentric.boot.admin.zuul.PreDecorationFilter
;
@Configuration
@Configuration
public
class
RevereseZuulProxyConfiguration
{
public
class
RevereseZuulProxyConfiguration
extends
ZuulConfiguration
{
@Autowired
(
required
=
false
)
@Autowired
(
required
=
false
)
private
TraceRepository
traces
;
private
TraceRepository
traces
;
...
@@ -55,6 +47,7 @@ public class RevereseZuulProxyConfiguration {
...
@@ -55,6 +47,7 @@ public class RevereseZuulProxyConfiguration {
private
ApplicationRegistry
registry
;
private
ApplicationRegistry
registry
;
@Bean
@Bean
@Override
public
ApplicationRouteLocator
routeLocator
()
{
public
ApplicationRouteLocator
routeLocator
()
{
return
new
ApplicationRouteLocator
(
this
.
server
.
getServletPrefix
(),
registry
,
return
new
ApplicationRouteLocator
(
this
.
server
.
getServletPrefix
(),
registry
,
RegistryController
.
PATH
);
RegistryController
.
PATH
);
...
@@ -75,59 +68,25 @@ public class RevereseZuulProxyConfiguration {
...
@@ -75,59 +68,25 @@ public class RevereseZuulProxyConfiguration {
}
}
@Bean
@Bean
public
ZuulController
zuulController
()
{
@Override
return
new
ZuulController
();
public
ApplicationListener
<
ApplicationEvent
>
zuulRefreshRoutesListener
()
{
}
return
new
ZuulRefreshListener
();
@Bean
public
ZuulHandlerMapping
zuulHandlerMapping
()
{
return
new
ZuulHandlerMapping
(
routeLocator
(),
zuulController
());
}
// pre filters
@Bean
public
FormBodyWrapperFilter
formBodyWrapperFilter
()
{
return
new
FormBodyWrapperFilter
();
}
@Bean
public
DebugFilter
debugFilter
()
{
return
new
DebugFilter
();
}
@Bean
public
Servlet30WrapperFilter
servlet30WrapperFilter
()
{
return
new
Servlet30WrapperFilter
();
}
}
// post filters
private
static
class
ZuulRefreshListener
implements
ApplicationListener
<
ApplicationEvent
>
{
@Bean
public
SendResponseFilter
sendResponseFilter
()
{
return
new
SendResponseFilter
();
}
@Bean
public
SendErrorFilter
sendErrorFilter
()
{
return
new
SendErrorFilter
();
}
@Configuration
protected
static
class
ZuulFilterConfiguration
{
@Autowired
@Autowired
private
Map
<
String
,
ZuulFilter
>
filters
;
private
ZuulHandlerMapping
zuulHandlerMapping
;
@Bean
@Autowired
public
ZuulFilterInitializer
zuulFilterInitializer
()
{
private
ApplicationRouteLocator
routeLocator
;
return
new
ZuulFilterInitializer
(
this
.
filters
);
@Override
public
void
onApplicationEvent
(
ApplicationEvent
event
)
{
if
(
event
instanceof
PayloadApplicationEvent
&&
((
PayloadApplicationEvent
<?>)
event
)
.
getPayload
()
instanceof
RoutesOutdatedEvent
)
{
routeLocator
.
resetRoutes
();
zuulHandlerMapping
.
registerHandlers
();
}
}
}
}
}
@EventListener
public
void
onRoutesOutdatedEvent
(
RoutesOutdatedEvent
event
)
{
routeLocator
().
resetRoutes
();
zuulHandlerMapping
().
registerHandlers
();
}
}
}
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