From 9a5b45daa93f7db10436380ebe8394aaade45863 Mon Sep 17 00:00:00 2001 From: leebj Date: Thu, 27 Jun 2024 14:57:47 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=9C=EB=B8=94=EB=A6=BF=20startup=EC=88=9C?= =?UTF-8?q?=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cokr/xit/custom/boot/FilterConfig.java | 37 ++++++++++++++ .../cokr/xit/custom/boot/ServletConfig.java | 51 +++++-------------- .../xit/custom/boot}/WebServiceConfig.java | 5 +- .../cokr/xit/custom/boot/XitApplication.java | 7 ++- .../lvisserver/CarRegBasicInfoImpl.java | 2 +- .../{webapp => }/resources/lvis_service.wsdl | 0 6 files changed, 57 insertions(+), 45 deletions(-) create mode 100644 src/main/java/cokr/xit/custom/boot/FilterConfig.java rename src/main/java/{testserver/wsdlserver/lvisserver => cokr/xit/custom/boot}/WebServiceConfig.java (93%) rename src/main/{webapp => }/resources/lvis_service.wsdl (100%) diff --git a/src/main/java/cokr/xit/custom/boot/FilterConfig.java b/src/main/java/cokr/xit/custom/boot/FilterConfig.java new file mode 100644 index 00000000..3a40cb25 --- /dev/null +++ b/src/main/java/cokr/xit/custom/boot/FilterConfig.java @@ -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 encodingFilter() { + FilterRegistrationBean 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() { + FilterRegistrationBean registration = new FilterRegistrationBean<>(); + registration.setFilter(new AccessFilter()); + registration.addUrlPatterns(URL_PATTERNS); + registration.setOrder(-101); + return registration; + } +} diff --git a/src/main/java/cokr/xit/custom/boot/ServletConfig.java b/src/main/java/cokr/xit/custom/boot/ServletConfig.java index 2407199a..33554c77 100644 --- a/src/main/java/cokr/xit/custom/boot/ServletConfig.java +++ b/src/main/java/cokr/xit/custom/boot/ServletConfig.java @@ -8,70 +8,45 @@ import org.apache.catalina.webresources.ExtractingRoot; import org.apache.cxf.transport.servlet.CXFServlet; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.server.WebServerFactoryCustomizer; -import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean; 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 ServletConfig { - protected static String[] URL_PATTERNS = {"/", "*.do"}; + + + @Bean + public ServletRegistrationBean cxfServletRegistrationBean() { + ServletRegistrationBean bean = new ServletRegistrationBean<>( + new CXFServlet(), + "/lvis/services/*" + ); + bean.setLoadOnStartup(2); + return bean; + } /**DefaultServlet를 등록한다. * @return ServletRegistrationBean */ @Bean - public ServletRegistrationBean defaultServlet() { + public ServletRegistrationBean defaultServletRegistrationBean() { ServletRegistrationBean bean = new ServletRegistrationBean<>( new DefaultServlet(), "/resources/*","/webjars/*" ); - bean.setLoadOnStartup(1); + bean.setLoadOnStartup(3); bean.setInitParameters(Map.of( "debug", "0", "listings", "false" )); - return bean; - } - @Bean - public ServletRegistrationBean cxfServlet() { - ServletRegistrationBean bean = new ServletRegistrationBean<>( - new CXFServlet(), - "/lvis/services/*" - ); - bean.setLoadOnStartup(2); return bean; } - /**CharacterEncodingFilter를 등록한다. - * @return FilterRegistrationBean - */ - @Bean - public FilterRegistrationBean encodingFilter() { - FilterRegistrationBean 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() { - FilterRegistrationBean registration = new FilterRegistrationBean<>(); - registration.setFilter(new AccessFilter()); - registration.addUrlPatterns(URL_PATTERNS); - registration.setOrder(-101); - return registration; - } @Bean public WebServerFactoryCustomizer servletContainerCustomizer() { diff --git a/src/main/java/testserver/wsdlserver/lvisserver/WebServiceConfig.java b/src/main/java/cokr/xit/custom/boot/WebServiceConfig.java similarity index 93% rename from src/main/java/testserver/wsdlserver/lvisserver/WebServiceConfig.java rename to src/main/java/cokr/xit/custom/boot/WebServiceConfig.java index af1c0254..c29c478f 100644 --- a/src/main/java/testserver/wsdlserver/lvisserver/WebServiceConfig.java +++ b/src/main/java/cokr/xit/custom/boot/WebServiceConfig.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package testserver.wsdlserver.lvisserver; +package cokr.xit.custom.boot; 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.Configuration; +import testserver.wsdlserver.lvisserver.CarRegBasicInfoImpl; + @Configuration public class WebServiceConfig { @@ -37,7 +39,6 @@ public class WebServiceConfig { @Bean public Endpoint endpoint() { EndpointImpl endpoint = new EndpointImpl(bus, new CarRegBasicInfoImpl()); - endpoint.publish("/WsFrontController"); return endpoint; } diff --git a/src/main/java/cokr/xit/custom/boot/XitApplication.java b/src/main/java/cokr/xit/custom/boot/XitApplication.java index 02a3ddf2..5c91d936 100644 --- a/src/main/java/cokr/xit/custom/boot/XitApplication.java +++ b/src/main/java/cokr/xit/custom/boot/XitApplication.java @@ -3,15 +3,14 @@ package cokr.xit.custom.boot; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; -import testserver.wsdlserver.lvisserver.WebServiceConfig; - @SpringBootApplication @ImportAutoConfiguration({ CommonConfig.class, ServletConfig.class, + WebServiceConfig.class, + FilterConfig.class, MvcConfig.class, DatasourceConfig.class, - TransactionConfig.class, - WebServiceConfig.class + TransactionConfig.class }) public class XitApplication {} diff --git a/src/main/java/testserver/wsdlserver/lvisserver/CarRegBasicInfoImpl.java b/src/main/java/testserver/wsdlserver/lvisserver/CarRegBasicInfoImpl.java index b971da9e..b3309ad3 100644 --- a/src/main/java/testserver/wsdlserver/lvisserver/CarRegBasicInfoImpl.java +++ b/src/main/java/testserver/wsdlserver/lvisserver/CarRegBasicInfoImpl.java @@ -33,7 +33,7 @@ import externalsystem.testpool.dao.TestPoolMapper; @javax.jws.WebService(name = "CarRegBasicInfo", portName = "CarRegBasicInfoPort",serviceName = "CarRegBasicInfoImplService", targetNamespace = "componentNs:carregbasicinfo.reg.service.lvis/service.reg.CarRegBasicInfo", endpointInterface = "testserver.wsdlserver.lvisserver.CarRegBasicInfo", - wsdlLocation = "/resources/lvis_service.wsdl" + wsdlLocation = "classpath:lvis_service.wsdl" ) public class CarRegBasicInfoImpl implements CarRegBasicInfo { diff --git a/src/main/webapp/resources/lvis_service.wsdl b/src/main/resources/lvis_service.wsdl similarity index 100% rename from src/main/webapp/resources/lvis_service.wsdl rename to src/main/resources/lvis_service.wsdl