서블릿 startup순서 변경

main
이범준 5 months ago
parent ddd422dcca
commit 9a5b45daa9

@ -0,0 +1,37 @@
package cokr.xit.custom.boot;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;
import cokr.xit.foundation.web.AccessFilter;
@Configuration
public class FilterConfig {
protected static String[] URL_PATTERNS = {"/", "*.do"};
/**CharacterEncodingFilter .
* @return FilterRegistrationBean
*/
@Bean
public FilterRegistrationBean<CharacterEncodingFilter> encodingFilter() {
FilterRegistrationBean<CharacterEncodingFilter> registration = new FilterRegistrationBean<>();
registration.setFilter(new CharacterEncodingFilter("utf-8"));
registration.addUrlPatterns(URL_PATTERNS);
registration.setOrder(-102);
return registration;
}
/**AccessFilter .
* @return FilterRegistrationBean
*/
@Bean
public FilterRegistrationBean<AccessFilter> accessFilter() {
FilterRegistrationBean<AccessFilter> registration = new FilterRegistrationBean<>();
registration.setFilter(new AccessFilter());
registration.addUrlPatterns(URL_PATTERNS);
registration.setOrder(-101);
return registration;
}
}

@ -8,70 +8,45 @@ import org.apache.catalina.webresources.ExtractingRoot;
import org.apache.cxf.transport.servlet.CXFServlet; import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean;
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.web.filter.CharacterEncodingFilter;
import cokr.xit.foundation.web.AccessFilter;
@Configuration @Configuration
public class ServletConfig { public class ServletConfig {
protected static String[] URL_PATTERNS = {"/", "*.do"};
@Bean
public ServletRegistrationBean<CXFServlet> cxfServletRegistrationBean() {
ServletRegistrationBean<CXFServlet> bean = new ServletRegistrationBean<>(
new CXFServlet(),
"/lvis/services/*"
);
bean.setLoadOnStartup(2);
return bean;
}
/**DefaultServlet . /**DefaultServlet .
* @return ServletRegistrationBean * @return ServletRegistrationBean
*/ */
@Bean @Bean
public ServletRegistrationBean<DefaultServlet> defaultServlet() { public ServletRegistrationBean<DefaultServlet> defaultServletRegistrationBean() {
ServletRegistrationBean<DefaultServlet> bean = new ServletRegistrationBean<>( ServletRegistrationBean<DefaultServlet> bean = new ServletRegistrationBean<>(
new DefaultServlet(), new DefaultServlet(),
"/resources/*","/webjars/*" "/resources/*","/webjars/*"
); );
bean.setLoadOnStartup(1); bean.setLoadOnStartup(3);
bean.setInitParameters(Map.of( bean.setInitParameters(Map.of(
"debug", "0", "debug", "0",
"listings", "false" "listings", "false"
)); ));
return bean;
}
@Bean
public ServletRegistrationBean<CXFServlet> cxfServlet() {
ServletRegistrationBean<CXFServlet> bean = new ServletRegistrationBean<>(
new CXFServlet(),
"/lvis/services/*"
);
bean.setLoadOnStartup(2);
return bean; return bean;
} }
/**CharacterEncodingFilter .
* @return FilterRegistrationBean
*/
@Bean
public FilterRegistrationBean<CharacterEncodingFilter> encodingFilter() {
FilterRegistrationBean<CharacterEncodingFilter> registration = new FilterRegistrationBean<>();
registration.setFilter(new CharacterEncodingFilter("utf-8"));
registration.addUrlPatterns(URL_PATTERNS);
registration.setOrder(-102);
return registration;
}
/**AccessFilter .
* @return FilterRegistrationBean
*/
@Bean
public FilterRegistrationBean<AccessFilter> accessFilter() {
FilterRegistrationBean<AccessFilter> registration = new FilterRegistrationBean<>();
registration.setFilter(new AccessFilter());
registration.addUrlPatterns(URL_PATTERNS);
registration.setOrder(-101);
return registration;
}
@Bean @Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> servletContainerCustomizer() { public WebServerFactoryCustomizer<TomcatServletWebServerFactory> servletContainerCustomizer() {

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package testserver.wsdlserver.lvisserver; package cokr.xit.custom.boot;
import javax.xml.ws.Endpoint; import javax.xml.ws.Endpoint;
@ -26,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired;
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 testserver.wsdlserver.lvisserver.CarRegBasicInfoImpl;
@Configuration @Configuration
public class WebServiceConfig { public class WebServiceConfig {
@ -37,7 +39,6 @@ public class WebServiceConfig {
@Bean @Bean
public Endpoint endpoint() { public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, new CarRegBasicInfoImpl()); EndpointImpl endpoint = new EndpointImpl(bus, new CarRegBasicInfoImpl());
endpoint.publish("/WsFrontController"); endpoint.publish("/WsFrontController");
return endpoint; return endpoint;
} }

@ -3,15 +3,14 @@ package cokr.xit.custom.boot;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import testserver.wsdlserver.lvisserver.WebServiceConfig;
@SpringBootApplication @SpringBootApplication
@ImportAutoConfiguration({ @ImportAutoConfiguration({
CommonConfig.class, CommonConfig.class,
ServletConfig.class, ServletConfig.class,
WebServiceConfig.class,
FilterConfig.class,
MvcConfig.class, MvcConfig.class,
DatasourceConfig.class, DatasourceConfig.class,
TransactionConfig.class, TransactionConfig.class
WebServiceConfig.class
}) })
public class XitApplication {} public class XitApplication {}

@ -33,7 +33,7 @@ import externalsystem.testpool.dao.TestPoolMapper;
@javax.jws.WebService(name = "CarRegBasicInfo", portName = "CarRegBasicInfoPort",serviceName = "CarRegBasicInfoImplService", @javax.jws.WebService(name = "CarRegBasicInfo", portName = "CarRegBasicInfoPort",serviceName = "CarRegBasicInfoImplService",
targetNamespace = "componentNs:carregbasicinfo.reg.service.lvis/service.reg.CarRegBasicInfo", targetNamespace = "componentNs:carregbasicinfo.reg.service.lvis/service.reg.CarRegBasicInfo",
endpointInterface = "testserver.wsdlserver.lvisserver.CarRegBasicInfo", endpointInterface = "testserver.wsdlserver.lvisserver.CarRegBasicInfo",
wsdlLocation = "/resources/lvis_service.wsdl" wsdlLocation = "classpath:lvis_service.wsdl"
) )
public class CarRegBasicInfoImpl implements CarRegBasicInfo { public class CarRegBasicInfoImpl implements CarRegBasicInfo {

Loading…
Cancel
Save