Commit 2e5d8dce by 房斌

1解决dubbo tomcat 加载类的判断。没有使用不加载 2执行顺序 tomcat优先dubbo 停机

parent bcec9771
package com.secoo.mall.dubbo.service;
import com.secoo.mall.dubbo.service.impl.TomcatConnectShoutDownHock;
import org.apache.catalina.connector.Connector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.core.Ordered;
public class TomcatGracefullyShutDown implements TomcatConnectorCustomizer , ApplicationContextAware, Ordered , ApplicationListener<ContextClosedEvent> {
private ApplicationContext context;
TomcatConnectShoutDownHock tomcatConnectShoutDownHock;
private final Logger logger = LoggerFactory.getLogger(this.getClass());
public TomcatGracefullyShutDown(TomcatConnectShoutDownHock tomcatConnectShoutDownHock) {
this.tomcatConnectShoutDownHock = tomcatConnectShoutDownHock;
}
@Override
public void customize(Connector connector) {
tomcatConnectShoutDownHock.setConnector(connector);
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.context = applicationContext;
logger.info("11111111111111111111 setContext");
}
public TomcatConnectShoutDownHock getTomcatConnectShoutDownHock() {
return tomcatConnectShoutDownHock;
}
public void setTomcatConnectShoutDownHock(TomcatConnectShoutDownHock tomcatConnectShoutDownHock) {
this.tomcatConnectShoutDownHock = tomcatConnectShoutDownHock;
}
@Override
public int getOrder() {
return 1;
}
@Override
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
logger.info("11111111111111111111 ");
tomcatConnectShoutDownHock.stop();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment