url 패턴, 트랜잭션 pointcut -> 설정으로 분리
parent
53e8138859
commit
93a77162b2
@ -0,0 +1,51 @@
|
|||||||
|
package cokr.xit.foundation.boot;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
|
import cokr.xit.foundation.AbstractComponent;
|
||||||
|
import cokr.xit.foundation.data.JSON;
|
||||||
|
|
||||||
|
public class Foundation extends AbstractComponent {
|
||||||
|
private static Foundation foundation;
|
||||||
|
static {
|
||||||
|
String path = "xit-foundation.conf";
|
||||||
|
try (InputStream input = new ClassPathResource(path).getInputStream()) {
|
||||||
|
foundation = new JSON().parse(input, Foundation.class);
|
||||||
|
log(Foundation.class).debug(path + " loaded");
|
||||||
|
} catch (Exception e) {
|
||||||
|
foundation = new Foundation();
|
||||||
|
log(Foundation.class).debug(path + " not found and default configuration is used");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] servletUrls() {
|
||||||
|
return foundation.servletUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] urlPatterns() {
|
||||||
|
return foundation.urlPatterns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String transactionPointcut() {
|
||||||
|
return foundation.transactionPointcut;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[]
|
||||||
|
servletUrls = {"/", "*.do"},
|
||||||
|
urlPatterns = {"/", "/**/*.do"};
|
||||||
|
private String transactionPointcut = "execution(* cokr.xit..service.bean.*ServiceBean.*(..))";
|
||||||
|
|
||||||
|
public void setServletUrls(String[] servletUrls) {
|
||||||
|
this.servletUrls = servletUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrlPatterns(String[] urlPatterns) {
|
||||||
|
this.urlPatterns = urlPatterns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransactionPointcut(String transactionPointcut) {
|
||||||
|
this.transactionPointcut = transactionPointcut;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"servletUrls": ["/", "*.do"], /* 서블릿 url 패턴 */
|
||||||
|
|
||||||
|
"urlPatterns": ["/", "/**/*.do"], /* 접근 url 패턴 */
|
||||||
|
|
||||||
|
"transactionPointcut": "execution(* cokr.xit..service.bean.*ServiceBean.*(..))" /* 트랜잭션 대상 클래스 및 메소드 */
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package cokr.xit.foundation.boot;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class FoundationTest {
|
||||||
|
@Test
|
||||||
|
void conf() {
|
||||||
|
System.out.println("servletUrls: " + List.of(Foundation.servletUrls()));
|
||||||
|
System.out.println("urlPatterns: " + List.of(Foundation.urlPatterns()));
|
||||||
|
System.out.println("transactionPointcut: " + Foundation.transactionPointcut());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue