moon 5 rokov pred
rodič
commit
e22498738c

+ 19 - 0
src/main/java/com/style24/core/support/annotation/CjDs.java

@@ -0,0 +1,19 @@
+package com.style24.core.support.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * DataSource를 여러 개로 구성 시 DAO를 구성하는 interface를 명시적으로 지정하기 위해 만든 Custom Annotation
+ * jdbc/wmsDs JNDI DataSource와 매핑
+ * 
+ * @author moon
+ * @since 2021. 04. 09
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface CjDs{
+
+}

+ 43 - 0
src/main/java/com/style24/core/support/config/TscJndiCjConfig.java

@@ -0,0 +1,43 @@
+package com.style24.core.support.config;
+
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import com.gagaframework.web.core.config.GagaJndiBaseConfig;
+
+/**
+ * Cj Transaction Manager 설정
+ * 
+ * @author moon
+ * @since 2021. 04. 09
+ */
+@Configuration
+@Lazy
+@EnableTransactionManagement
+public class TscJndiCjConfig extends GagaJndiBaseConfig {
+
+	/**
+	 * destroyMethod = "close" 속성은 apache commons DBCP와 BasicDataSource 등에서
+	 * 즉시 DataSource를 종료하고자 할 때에 사용하는 것으로 DriverManagerDataSource에서는 필요하지 않다.
+	 */
+	@Override
+	//	@Bean(name = "defaultDataSource", destroyMethod = "close")
+	@Bean(name = "cjDataSource")
+	public DataSource dataSource() throws IllegalArgumentException, NamingException {
+		return super.getDataSource("jdbc/cjDs");
+	}
+
+	@Override
+	@Bean(name = "cjTxnManager")
+	public PlatformTransactionManager transactionManager(@Qualifier("cjDataSource") DataSource dataSource) throws NamingException {
+		return super.getTransactionManager(dataSource);
+	}
+
+}