diff --git a/src/main/java/nlib/cmm/service/NlibProperty.java b/src/main/java/nlib/cmm/service/NlibProperty.java new file mode 100644 index 00000000..0d73e205 --- /dev/null +++ b/src/main/java/nlib/cmm/service/NlibProperty.java @@ -0,0 +1,112 @@ +package nlib.cmm.service; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +/** + *
+ * @Class Name : NlibProperty.java + * + * @Description : NLIB용 프로퍼티 파일을 읽어서 메모리에 로딩하고 관리하는 클래스 + * + * + * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) + * + *+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 7. 16. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 7. 16. + * @version 1.0 + * + */ +@Service("nlibProperty") +public class NlibProperty { + + private static final Logger log = LoggerFactory.getLogger(NlibProperty.class); + + /** + * 메모리에 로딩될 프로퍼티 객체 선언 + */ + public static Properties properties = null; + + /** + * nlib.properties 파일로 부터 속성을 읽어 들인다. + * + * @return 정상적으로 로딩한 건수를 리턴한다. 오류 발생 시, 음수값이 리턴된다. + */ + public static int loadProperties() { + + String nlibPropPath = null; + int propCount = -1; + + try { + + if(properties == null) properties = new Properties(); + else properties.clear(); + + nlibPropPath = NlibProperty.class.getResource("").getPath(); + nlibPropPath = nlibPropPath.substring(0, nlibPropPath.lastIndexOf("/nlib/") + 6) + "nlib.properties"; + + log.debug("NLIB Properties File Path : " + nlibPropPath); + + try (InputStream input = new FileInputStream(nlibPropPath)) { + + properties.load(input); + + Enumeration