init
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package com.eactive.eai.common.b2bextractor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.eactive.eai.common.b2bextractor.loader.B2BExtractLoader;
|
||||
import com.eactive.eai.common.b2bextractor.mapper.B2BExtractMapper;
|
||||
import com.eactive.eai.common.dao.BaseDAO;
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.b2bextractor.B2BExtract;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class B2BExtractDAO extends BaseDAO {
|
||||
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private B2BExtractLoader b2bExtractEntityService;
|
||||
@Autowired
|
||||
private B2BExtractMapper b2bExtractMapper;
|
||||
|
||||
public Map<String, B2BExtractVO> getAllB2BExtracts() throws DAOException {
|
||||
|
||||
try {
|
||||
HashMap<String, B2BExtractVO> b2bMap = new HashMap<>();
|
||||
List<B2BExtract> b2bExtracts = b2bExtractEntityService.findAllOrderByEaisvcname();
|
||||
logger.info("[ @@ Load B2BExtract Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
for (B2BExtract b2bExtract : b2bExtracts) {
|
||||
B2BExtractVO vo = b2bExtractMapper.toVo(b2bExtract);
|
||||
b2bMap.put(b2bExtract.getId().getEaisvcname() + b2bExtract.getId().getSvcprcssno(), vo);
|
||||
}
|
||||
logger.info("[>>Load B2BExtract Configuration - ended ]");
|
||||
return b2bMap;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICBM101"));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, B2BExtractVO> getB2BExtract(String eaisvcname) throws DAOException {
|
||||
try {
|
||||
HashMap<String, B2BExtractVO> map = new HashMap<>();
|
||||
B2BExtract b2bExtract = b2bExtractEntityService.findByIdEaisvcname(eaisvcname);
|
||||
logger.info("[ @@ Load B2BExtract Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
if (b2bExtract != null) {
|
||||
B2BExtractVO vo = b2bExtractMapper.toVo(b2bExtract);
|
||||
String key = b2bExtract.getId().getEaisvcname() + b2bExtract.getId().getSvcprcssno();
|
||||
logger.info("@ " + vo.toString());
|
||||
map.put(key, vo);
|
||||
}
|
||||
|
||||
logger.info("[>>Load B2BExtract Configuration - ended ]");
|
||||
return map;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICBM205"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.eactive.eai.common.b2bextractor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.lifecycle.Lifecycle;
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.common.lifecycle.LifecycleListener;
|
||||
import com.eactive.eai.common.lifecycle.LifecycleSupport;
|
||||
import com.eactive.eai.common.util.ApplicationContextProvider;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
@Component
|
||||
public class B2BExtractManager implements Lifecycle {
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
private Map<String, B2BExtractVO> messages = new HashMap<>();
|
||||
|
||||
private boolean started;
|
||||
|
||||
@Autowired
|
||||
B2BExtractDAO b2bExtractDAO;
|
||||
|
||||
public static B2BExtractManager getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(B2BExtractManager.class);
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICKM201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICKM202"));
|
||||
}
|
||||
|
||||
started = true;
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
private void init() throws DAOException {
|
||||
messages = b2bExtractDAO.getAllB2BExtracts();
|
||||
}
|
||||
|
||||
public synchronized void reload() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload all Started ...");
|
||||
}
|
||||
init();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload(String eaiSvcCd) throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload Started ...");
|
||||
}
|
||||
Map<String, B2BExtractVO> map = b2bExtractDAO.getB2BExtract(eaiSvcCd);// eaiSvcCd
|
||||
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
String key = null;
|
||||
|
||||
while (it.hasNext()) {
|
||||
key = it.next();
|
||||
messages.put(key, map.get(key));
|
||||
}
|
||||
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICKM203");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
messages.clear();
|
||||
|
||||
started = false;
|
||||
lifecycle.fireLifecycleEvent(STOPPED_EVENT, this);
|
||||
}
|
||||
|
||||
public void addLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.addLifecycleListener(listener);
|
||||
}
|
||||
|
||||
public LifecycleListener[] findLifecycleListeners() {
|
||||
return lifecycle.findLifecycleListeners();
|
||||
}
|
||||
|
||||
public void removeLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.removeLifecycleListener(listener);
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return this.started;
|
||||
}
|
||||
|
||||
public B2BExtractVO getB2BExtract(String code) {
|
||||
return messages.get(code);
|
||||
}
|
||||
|
||||
public void setB2BExtract(String code, B2BExtractVO msg) {
|
||||
messages.put(code, msg);
|
||||
}
|
||||
|
||||
public void removeB2BExtract(String code) {
|
||||
messages.remove(code);
|
||||
}
|
||||
|
||||
public String[] getAllKeyNames() {
|
||||
Set<String> keySet = this.messages.keySet();
|
||||
String[] names = keySet.toArray(new String[keySet.size()]);
|
||||
Arrays.sort(names);
|
||||
return names;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.eactive.eai.common.b2bextractor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class B2BExtractVO implements Serializable {
|
||||
private String eaiSvcCd; // EAI 서비스명 : TSEAIFR06.EAISvcName
|
||||
private int svcPssSeq; // 서비스처리번호[TSEAIFR06.SvcPrcssNo]
|
||||
private String routeActionName; // RouteAction Class : TSEAIFR06.routeActionName
|
||||
private String adapterActionName; // AdapterAction Class : TSEAIFR06.adapterActionName
|
||||
|
||||
public B2BExtractVO(String eaiSvcCd, int svcPssSeq, String routeActionName, String adapterActionName) {
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
this.svcPssSeq = svcPssSeq;
|
||||
this.routeActionName = routeActionName;
|
||||
this.adapterActionName = adapterActionName;
|
||||
}
|
||||
|
||||
public void setEaiSvcCd(String eaiSvcCd) {
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
}
|
||||
|
||||
public String getEaiSvcCd() {
|
||||
return this.eaiSvcCd;
|
||||
}
|
||||
|
||||
public String getAdapterActionName() {
|
||||
return adapterActionName;
|
||||
}
|
||||
|
||||
public void setAdapterActionName(String adapterActionName) {
|
||||
this.adapterActionName = adapterActionName;
|
||||
}
|
||||
|
||||
public String getRouteActionName() {
|
||||
return routeActionName;
|
||||
}
|
||||
|
||||
public void setRouteActionName(String routeActionName) {
|
||||
this.routeActionName = routeActionName;
|
||||
}
|
||||
|
||||
public int getSvcPssSeq() {
|
||||
return svcPssSeq;
|
||||
}
|
||||
|
||||
public void setSvcPssSeq(int svcPssSeq) {
|
||||
this.svcPssSeq = svcPssSeq;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.eactive.eai.common.b2bextractor.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import com.eactive.eai.common.b2bextractor.B2BExtractVO;
|
||||
import com.eactive.eai.data.entity.onl.b2bextractor.B2BExtract;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface B2BExtractMapper extends GenericMapper<B2BExtractVO, B2BExtract> {
|
||||
|
||||
@Mapping(source = "id.eaisvcname", target = "eaiSvcCd")
|
||||
@Mapping(source = "id.svcprcssno", target = "svcPssSeq")
|
||||
@Mapping(source = "svcroutclsname", target = "routeActionName")
|
||||
@Mapping(source = "adptrroutclsname", target = "adapterActionName")
|
||||
@Override
|
||||
B2BExtractVO toVo(B2BExtract entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Override
|
||||
B2BExtract toEntity(B2BExtractVO vo);
|
||||
}
|
||||
Reference in New Issue
Block a user