Skip to content

Commit

Permalink
Confirm WebServerFactoryCustomizer's execution order
Browse files Browse the repository at this point in the history
This commit confirms WebServerFactoryCustomizer's execution precedes other bean creations.

See micrometer-metrics/micrometer#911
  • Loading branch information
izeye committed Oct 11, 2018
1 parent 831429d commit 414e50f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/main/java/com/izeye/sample/config/JettyConfig.java
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;
}

}

0 comments on commit 414e50f

Please sign in to comment.