-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Confirm WebServerFactoryCustomizer's execution order
This commit confirms WebServerFactoryCustomizer's execution precedes other bean creations. See micrometer-metrics/micrometer#911
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.izeye.sample.config; | ||
|
||
import org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory; | ||
import org.springframework.boot.web.server.WebServerFactoryCustomizer; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import org.eclipse.jetty.server.Server; | ||
import org.eclipse.jetty.util.thread.ThreadPool; | ||
|
||
/** | ||
* Configuration for Jetty. | ||
* | ||
* @author Johnny Lim | ||
*/ | ||
@Configuration | ||
public class JettyConfig { | ||
|
||
private volatile Server server; | ||
|
||
@Bean | ||
public WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> jettyCustomizer() { | ||
return (jetty) -> { | ||
jetty.addServerCustomizers(this::setServer); | ||
}; | ||
} | ||
|
||
@Bean | ||
public ThreadPool jettyThreadPool() { | ||
return this.server.getThreadPool(); | ||
} | ||
|
||
private void setServer(Server server) { | ||
this.server = server; | ||
} | ||
|
||
} |