diff --git a/src/main/java/cokr/xit/fims/framework/core/utils/XitRefreshableSqlSessionFactoryBean.java b/src/main/java/cokr/xit/fims/framework/core/utils/XitRefreshableSqlSessionFactoryBean.java deleted file mode 100644 index d0b24aeb..00000000 --- a/src/main/java/cokr/xit/fims/framework/core/utils/XitRefreshableSqlSessionFactoryBean.java +++ /dev/null @@ -1,239 +0,0 @@ -package cokr.xit.fims.framework.core.utils; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ibatis.session.SqlSessionFactory; -import org.mybatis.spring.SqlSessionFactoryBean; -import org.springframework.beans.factory.DisposableBean; -import org.springframework.core.io.Resource; - -import java.io.IOException; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.*; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - - -/** - * - * @업무그룹명: Mybatis mapper 자동 반영 - * @설명: mybatis mapper 자동 감지 후 서버 재시작 필요 없이 반영 된다. - * 사전조건은 JDK 1.5 이상, Spring, mybatis, spring-mybatis 라이브러리가 설치되어 있는 환경이어야 한다. - * - * 출처: https://sbcoba.tistory.com/16 [홍이의 개발 노트] - * - * - * [문제 발생] - * -.적용 후 질의문 파일을 수정 해도 반영되지 않는 다면 Tomcat의 경우 다음과 같이 처리 한다. - * -> Publising 옵션이 "Never publish automatically" 으로 되어 있는지 확인 - * -> Publising 옵션을 "Automatically publish when resources change " 또는 "Automatically publish after a build event" 으로 변경 - * @최초작성일: 2020. 10. 14. 오후 3:50:56 - * @최초작성자: 박민규 - * @author (주)엑스아이티 개발팀 - * @since 2002. 2. 2. - * @version 1.0 Copyright(c) XIT All rights reserved. - */ -public class XitRefreshableSqlSessionFactoryBean extends SqlSessionFactoryBean implements DisposableBean{ - private static final Log log = LogFactory.getLog(XitRefreshableSqlSessionFactoryBean.class); - - - private SqlSessionFactory proxy; - private int interval = 500; - - private Timer timer; - private TimerTask task; - - private Resource[] mapperLocations; - - - /** - * 파일 감시 쓰레드가 실행중인지 여부. - */ - private boolean running = false; - - - private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(); - private final Lock rl = rwl.readLock(); - private final Lock wl = rwl.writeLock(); - - - - - - public void setMapperLocations(Resource[] mapperLocations) { - super.setMapperLocations(mapperLocations); - this.mapperLocations = mapperLocations; - } - - - public void setInterval(int interval) { - this.interval = interval; - } - - - /** - * @throws Exception - */ - public void refresh() throws Exception { - if (log.isInfoEnabled()) { - log.info("refreshing sqlMapClient."); - } - - wl.lock(); - - try { - super.afterPropertiesSet(); - - } finally { - wl.unlock(); - } - } - - - /** - * 싱글톤 멤버로 SqlMapClient 원본 대신 프록시로 설정하도록 오버라이드. - */ - public void afterPropertiesSet() throws Exception { - super.afterPropertiesSet(); - setRefreshable(); - } - - - private void setRefreshable() { - proxy = (SqlSessionFactory) Proxy.newProxyInstance( - SqlSessionFactory.class.getClassLoader() - , new Class[]{SqlSessionFactory.class} - , new InvocationHandler() { - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - // log.debug("method.getName() : " + method.getName()); - return method.invoke(getParentObject(), args); - } - }); - - task = new TimerTask() { - private Map map = new HashMap(); - - public void run() { - if (isModified()) { - try { - refresh(); - } catch (Exception e) { - log.error("caught exception", e); - } - } - } - - - private boolean isModified() { - - boolean retVal = false; - - if (mapperLocations != null) { - for (int i = 0; i < mapperLocations.length; i++) { - Resource mappingLocation = mapperLocations[i]; - retVal |= findModifiedResource(mappingLocation); - } - } - - return retVal; - } - - - private boolean findModifiedResource(Resource resource) { - boolean retVal = false; - - List modifiedResources = new ArrayList(); - try { - long modified = resource.lastModified(); - if (map.containsKey(resource)) { - long lastModified = ((Long) map.get(resource)) .longValue(); - if (lastModified != modified) { - map.put(resource, new Long(modified)); - modifiedResources.add(resource.getDescription()); - retVal = true; - - } - } else { - map.put(resource, new Long(modified)); - } - } catch (IOException e) { - log.error("caught exception", e); - } - - - if (retVal) { - if (log.isInfoEnabled()) { - log.info("modified files : " + modifiedResources); - } - } - - - return retVal; - } - }; - - - timer = new Timer(true); - - resetInterval(); - - } - - - private Object getParentObject() throws Exception { - rl.lock(); - try { - return super.getObject(); - } finally { - rl.unlock(); - } - } - - - - public SqlSessionFactory getObject() { - return this.proxy; - } - - - - public Class getObjectType() { - return (this.proxy != null ? this.proxy.getClass() : SqlSessionFactory.class); - } - - - - public boolean isSingleton() { - return true; - } - - - public void setCheckInterval(int ms) { - interval = ms; - - if (timer != null) { - resetInterval(); - } - } - - - private void resetInterval() { - if (running) { - timer.cancel(); running = false; - } - - if (interval > 0) { - timer.schedule(task, 0, interval); running = true; - } - } - - - public void destroy() throws Exception { - timer.cancel(); - } - - - -} diff --git a/src/main/java/cokr/xit/fims/framework/core/utils/XitRequestWrapper.java b/src/main/java/cokr/xit/fims/framework/core/utils/XitRequestWrapper.java deleted file mode 100644 index 0f620085..00000000 --- a/src/main/java/cokr/xit/fims/framework/core/utils/XitRequestWrapper.java +++ /dev/null @@ -1,122 +0,0 @@ -package cokr.xit.fims.framework.core.utils; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - - -/* ************************************** -* request Wrapping을 이용한 forward 방법 -* @author 박민규 -************************************** */ -//RequestDispatcher rd = req.getRequestDispatcher("/example/CallUrl"); -//try { -// XitRequestWrapper reqWrap = new XitRequestWrapper(req); -// reqWrap.setParameter("param1", "abc"); -// reqWrap.setParameter("param2", "123"); -// rd.forward(reqWrap, resp); -//} catch (ServletException e1) { -// e1.printStackTrace(); -//} catch (IOException e1) { -// e1.printStackTrace(); -//} - - - - -/** - * - *
    - *
  • 업무 그룹명: HttpServletRequest Wrapper 클래스
  • - *
  • 설 명:
  • - *
  • 작성일: 2018. 9. 6. 오후 4:45:16 - *
- * - * @author 박민규 - * - */ -public class XitRequestWrapper extends HttpServletRequestWrapper{ - HashMap params; - - public XitRequestWrapper(HttpServletRequest request) { - super(request); - this.params = new HashMap(request.getParameterMap()); - } - - public String getParameter(String name){ - String returnValue = null; - String[] paramArray = getParameterValues(name); - if (paramArray != null && paramArray.length > 0){ - returnValue = paramArray[0]; - } - return returnValue; - } - - - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Map getParameterMap() { - return Collections.unmodifiableMap(params); - } - - - - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Enumeration getParameterNames() { - return Collections.enumeration(params.keySet()); - } - - - - public String[] getParameterValues(String name) { - String[] result = null; - String[] temp = (String[])params.get(name); - if (temp != null){ - result = new String[temp.length]; - System.arraycopy(temp, 0, result, 0, temp.length); - } - return result; - } - - - - - public void setParameter(String name, String value){ - String[] oneParam = {value}; - setParameter(name, oneParam); - } - - public void setParameter(String name, Map value){ - for(String key : value.keySet()) - setParameter(name, value.get(key)); - } - - public void setParameter(String name, String[] value){ - params.put(name, value); - } - - - - /** - *
메소드 설명: 요청경로로 포워딩 처리 한다.
- * @param url 포워딩 경로 - * @param response HttpServletResponse - * @throws ServletException - * @throws IOException void 요청처리 후 응답객체 - * @author: 박민규 - * @date: 2020. 9. 10. - */ - public void forward(String url, HttpServletResponse response) throws ServletException, IOException { - RequestDispatcher dispatcher = this.getRequestDispatcher(url); - dispatcher.forward(this, response); - } - -}