๐ก ๊น์ํ๋์ ์คํ๋ง ํต์ฌ ์๋ฆฌ ๊ณ ๊ธํธ ๊ฐ์๋ฅผ ๋ฃ๊ณ ์ ๋ฆฌํ ๋ด์ฉ์ ๋๋ค.
ํฌ์ธํธ์ปท, ์ด๋๋ฐ์ด์ค, ์ด๋๋ฐ์ด์
- ํฌ์ธํธ์ปท( Pointcut ): ์ด๋์ ๋ถ๊ฐ ๊ธฐ๋ฅ์ ์ ์ฉํ ์ง, ์ด๋์ ๋ถ๊ฐ ๊ธฐ๋ฅ์ ์ ์ฉํ์ง ์์์ง ํ๋จํ๋ ํํฐ๋ง ๋ก์ง์ด๋ค. ์ฃผ๋ก ํด๋์ค์ ๋ฉ์๋ ์ด๋ฆ์ผ๋ก ํํฐ๋ง ํ๋ค. ์ด๋ฆ ๊ทธ๋๋ก ์ด๋ค ํฌ์ธํธ(Point)์ ๊ธฐ๋ฅ์ ์ ์ฉํ ์ง ํ์ง ์์์ง ์๋ผ์(cut) ๊ตฌ๋ถํ๋ ๊ฒ์ด๋ค
- ์ด๋๋ฐ์ด์ค( Advice ): ์ด์ ์ ๋ณธ ๊ฒ ์ฒ๋ผ ํ๋ก์๊ฐ ํธ์ถํ๋ ๋ถ๊ฐ ๊ธฐ๋ฅ์ด๋ค. ๋จ์ํ๊ฒ ํ๋ก์ ๋ก์ง์ด๋ผ ์๊ฐํ๋ฉด ๋๋ค.
- ์ด๋๋ฐ์ด์ ( Advisor ): ๋จ์ํ๊ฒ ํ๋์ ํฌ์ธํธ์ปท๊ณผ ํ๋์ ์ด๋๋ฐ์ด์ค๋ฅผ ๊ฐ์ง๊ณ ์๋ ๊ฒ์ด๋ค. ์ฝ๊ฒ ์ด์ผ๊ธฐํด์ ํฌ์ธํธ์ปท1 + ์ด๋๋ฐ์ด์ค1์ด๋ค.
์ ๋ฆฌํ๋ฉด ๋ถ๊ฐ ๊ธฐ๋ฅ ๋ก์ง์ ์ ์ฉํด์ผ ํ๋๋ฐ, ํฌ์ธํธ์ปท์ผ๋ก ์ด๋์? ์ ์ฉํ ์ง ์ ํํ๊ณ , ์ด๋๋ฐ์ด์ค๋ก ์ด๋ค ๋ก์ง์ ์ ์ฉํ ์ง ์ ํํ๋ ๊ฒ์ด๋ค. ๊ทธ๋ฆฌ๊ณ ์ด๋์? ์ด๋ค ๋ก์ง?์ ๋ชจ๋ ์๊ณ ์๋ ๊ฒ์ด ์ด๋๋ฐ์ด์ ์ด๋ค.
์ ๋ฆฌ
์กฐ์ธ( Advice )์ ์ด๋( Pointcut )์ ํ ๊ฒ์ธ๊ฐ?
์กฐ์ธ์( Advisor )๋ ์ด๋( Pointcut )์ ์กฐ์ธ( Advice )์ ํด์ผํ ์ง ์๊ณ ์๋ค.
์ญํ ๊ณผ ์ฑ ์
์ด๋ ๊ฒ ๊ตฌ๋ถํ ๊ฒ์ ์ญํ ๊ณผ ์ฑ ์์ ๋ช ํํ๊ฒ ๋ถ๋ฆฌํ ๊ฒ์ด๋ค.
ํฌ์ธํธ์ปท์ ๋์ ์ฌ๋ถ๋ฅผ ํ์ธํ๋ ํํฐ ์ญํ ๋ง ๋ด๋นํ๋ค.
์ด๋๋ฐ์ด์ค๋ ๊น๋ํ๊ฒ ๋ถ๊ฐ ๊ธฐ๋ฅ ๋ก์ง๋ง ๋ด๋นํ๋ค.
๋์ ํฉ์น๋ฉด ์ด๋๋ฐ์ด์ ๊ฐ ๋๋ค.
์คํ๋ง์ ์ด๋๋ฐ์ด์ ๋ ํ๋์ ํฌ์ธํธ์ปท + ํ๋์ ์ด๋๋ฐ์ด์ค๋ก ๊ตฌ์ฑ๋๋ค.

์ด๋๋ฐ์ด์
์ด๋๋ฐ์ด์ ๋ ํ๋์ ํฌ์ธํธ์ปท๊ณผ ํ๋์ ์ด๋๋ฐ์ด์ค๋ฅผ ๊ฐ์ง๊ณ ์๋ค.
ํ๋ก์ ํฉํ ๋ฆฌ๋ฅผ ํตํด ํ๋ก์๋ฅผ ์์ฑํ ๋ ์ด๋๋ฐ์ด์ ๋ฅผ ์ ๊ณตํ๋ฉด ์ด๋์ ์ด๋ค ๊ธฐ๋ฅ์ ์ ๊ณตํ ์ง ์ ์ ์๋ค.
AdvisorTest
@Slf4j
public class AdvisorTest {
@Test
void advisorTest1() {
ServiceInterface target = new ServiceImpl();
ProxyFactory proxyFactory = new ProxyFactory(target);
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(Pointcut.TRUE, new TimeAdvice());
proxyFactory.addAdvisor(advisor);
ServiceInterface proxy = (ServiceInterface) proxyFactory.getProxy();
proxy.save();
proxy.find();
}
}
new DefaultPointcutAdvisor
Advisor ์ธํฐํ์ด์ค์ ๊ฐ์ฅ ์ผ๋ฐ์ ์ธ ๊ตฌํ์ฒด์ด๋ค.
์์ฑ์๋ฅผ ํตํด ํ๋์ ํฌ์ธํธ์ปท๊ณผ ํ๋์ ์ด๋๋ฐ์ด์ค๋ฅผ ๋ฃ์ด์ฃผ๋ฉด ๋๋ค.
์ด๋๋ฐ์ด์ ๋ ํ๋์ ํฌ์ธํธ์ปท๊ณผ ํ๋์ ์ด๋๋ฐ์ด์ค๋ก ๊ตฌ์ฑ ๋๋ค
new TimeAdvice()
์์ ๊ฐ๋ฐํ TimeAdvice ์ด๋๋ฐ์ด์ค๋ฅผ ์ ๊ณตํ๋ค.
proxyFactory.addAdvisor(advisor)
ํ๋ก์ ํฉํ ๋ฆฌ์ ์ ์ฉํ ์ด๋๋ฐ์ด์ ๋ฅผ ์ง์ ํ๋ค.
์ด๋๋ฐ์ด์ ๋ ๋ด๋ถ์ ํฌ์ธํธ์ปท๊ณผ ์ด๋๋ฐ์ด์ค๋ฅผ ๋ชจ๋ ๊ฐ์ง๊ณ ์๋ค.
๋ฐ๋ผ์ ์ด๋์ ์ด๋ค ๋ถ๊ฐ ๊ธฐ๋ฅ์ ์ ์ฉํด์ผ ํ ์ง ์ด๋๋ฐ์ด์ ํ๋๋ก ์ ์ ์๋ค.
ํ๋ก์ ํฉํ ๋ฆฌ๋ฅผ ์ฌ์ฉํ ๋ ์ด๋๋ฐ์ด์ ๋ ํ์์ด๋ค.

์คํ๊ฒฐ๊ณผ
ํฌ์ธํธ์ปท ์ง์ ๋ง๋ค๊ธฐ
์ด๋ฒ์๋ save() ๋ฉ์๋์๋ ์ด๋๋ฐ์ด์ค ๋ก์ง์ ์ ์ฉํ์ง๋ง, find() ๋ฉ์๋์๋ ์ด๋๋ฐ์ด์ค ๋ก์ง์ ์ ์ฉํ์ง ์๋๋ก ํด๋ณด์.
Pointcut ๊ด๋ จ ์ธํฐํ์ด์ค - ์คํ๋ง ์ ๊ณต
public interface Pointcut {
ClassFilter getClassFilter();
MethodMatcher getMethodMatcher();
}
public interface ClassFilter {
boolean matches(Class<?> clazz);
}
public interface MethodMatcher {
boolean matches(Method method, Class<?> targetClass);
//..
}
ํฌ์ธํธ์ปท์ ํฌ๊ฒ ClassFilter์ MethodMatcher ๋๋ก ์ด๋ฃจ์ด์ง๋ค.
์ด๋ฆ ๊ทธ๋๋ก ํ๋๋ ํด๋์ค๊ฐ ๋ง๋์ง, ํ๋๋ ๋ฉ์๋๊ฐ ๋ง๋์ง ํ์ธํ ๋ ์ฌ์ฉํ๋ค.
๋๋ค true๋ก ๋ฐํํด์ผ ์ด๋๋ฐ์ด์ค๋ฅผ ์ ์ฉํ ์ ์๋ค.
์ผ๋ฐ์ ์ผ๋ก ์คํ๋ง์ด ์ด๋ฏธ ๋ง๋ค์ด๋ ๊ตฌํ์ฒด๋ฅผ ์ฌ์ฉํ์ง๋ง ๊ฐ๋ ํ์ต ์ฐจ์์์ ๊ฐ๋จํ ์ง์ ๊ตฌํํด๋ณด์.
AdvisorTest - advisorTest2() ์ถ๊ฐ
@Test
@DisplayName("์ง์ ๋ง๋ ํฌ์ธํธ์ปท")
void advisorTest2() {
ServiceInterface target = new ServiceImpl();
ProxyFactory proxyFactory = new ProxyFactory(target);
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(new MyPointcut(), new TimeAdvice());
proxyFactory.addAdvisor(advisor);
ServiceInterface proxy = (ServiceInterface) proxyFactory.getProxy();
proxy.save();
proxy.find();
}
static class MyPointcut implements Pointcut {
@Override
public ClassFilter getClassFilter() {
return ClassFilter.TRUE;
}
@Override
public MethodMatcher getMethodMatcher() {
return new MyMethodMatcher();
}
}
static class MyMethodMatcher implements MethodMatcher {
private String matchName = "save";
@Override
public boolean matches(Method method, Class<?> targetClass) {
boolean result = method.getName().equals(matchName);
log.info("ํฌ์ธํธ์ปท ํธ์ถ method={} targetClass={}", method.getName(), targetClass);
log.info("ํฌ์ธํธ์ปท ๊ฒฐ๊ณผ result={}", result);
return result;
}
@Override
public boolean isRuntime() {
return false;
}
@Override
public boolean matches(Method method, Class<?> targetClass, Object... args) {
return false;
}
}
์คํ ํ๋ฆ ์ ๋ฆฌ
save() ํธ์ถ
- ํด๋ผ์ด์ธํธ๊ฐ ํ๋ก์์ save()๋ฅผ ํธ์ถํ๋ค.
- ํฌ์ธํธ์ปท์ Service ํด๋์ค์ save() ๋ฉ์๋์ ์ด๋๋ฐ์ด์ค๋ฅผ ์ ์ฉํด๋ ๋ ์ง ๋ฌผ์ด๋ณธ๋ค.
- ํฌ์ธํธ์ปท์ด true๋ฅผ ๋ฐํํ๋ค. ๋ฐ๋ผ์ ์ด๋๋ฐ์ด์ค๋ฅผ ํธ์ถํด์ ๋ถ๊ฐ ๊ธฐ๋ฅ์ ์ ์ฉํ๋ค.
- ์ดํ ์ค์ ์ธ์คํด์ค์ save()๋ฅผ ํธ์ถํ๋ค.
find() ํธ์ถ

- ํด๋ผ์ด์ธํธ๊ฐ ํ๋ก์์ find()๋ฅผ ํธ์ถํ๋ค.
- ํฌ์ธํธ์ปท์ Service ํด๋์ค์ find() ๋ฉ์๋์ ์ด๋๋ฐ์ด์ค๋ฅผ ์ ์ฉํด๋ ๋ ์ง ๋ฌผ์ด๋ณธ๋ค.
- ํฌ์ธํธ์ปท์ด false๋ฅผ ๋ฐํํ๋ค. ๋ฐ๋ผ์ ์ด๋๋ฐ์ด์ค๋ฅผ ํธ์ถํ์ง ์๊ณ , ๋ถ๊ฐ ๊ธฐ๋ฅ๋ ์ ์ฉ๋์ง ์๋๋ค.
- ์ค์ ์ธ์คํด์ค๋ฅผ ํธ์ถํ๋ค.
์คํ๋ง์ด ์ ๊ณตํ๋ ํฌ์ธํธ์ปท ์ฌ์ฉํ๊ธฐ
์คํ๋ง์ ์ฐ๋ฆฌ๊ฐ ํ์ํ ํฌ์ธํธ์ปท์ ์ด๋ฏธ ๋๋ถ๋ถ ์ ๊ณตํ๋ค.
์ด๋ฒ์๋ ์คํ๋ง์ด ์ ๊ณตํ๋ NameMatchMethodPointcut๋ฅผ ์ฌ์ฉํด์ ๊ตฌํํด๋ณด์.
@Test
@DisplayName("์คํ๋ง์ด ์ ๊ณตํ๋ ํฌ์ธํธ์ปท")
void advisorTest3() {
ServiceInterface target = new ServiceImpl();
ProxyFactory proxyFactory = new ProxyFactory(target);
NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut();
pointcut.setMappedNames("save");
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(pointcut, new TimeAdvice());
proxyFactory.addAdvisor(advisor);
ServiceInterface proxy = (ServiceInterface) proxyFactory.getProxy();
proxy.save();
proxy.find();
}
NameMatchMethodPointcut ์ฌ์ฉ ์ฝ๋
NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut();
pointcut.setMappedNames("save");
NameMatchMethodPointcut์ ์์ฑํ๊ณ setMappedNames(...)์ผ๋ก ๋ฉ์๋ ์ด๋ฆ์ ์ง์ ํ๋ฉด ํฌ์ธํธ์ปท์ด ์์ฑ๋๋ค.
์คํ๋ง์ด ์ ๊ณตํ๋ ํฌ์ธํธ์ปท
AspectJExpressionPointcut: aspectJ ํํ์์ผ๋ก ๋งค์นญํ๋ค.
๊ฐ์ฅ ์ค์ํ ๊ฒ์ aspectJ ํํ์์ด๊ณ ๋ค๋ฅธ ๊ฒ์ ์ค์ํ์ง ์๋ค.
์ค๋ฌด์์๋ ์ฌ์ฉํ๊ธฐ๋ ํธ๋ฆฌํ๊ณ ๊ธฐ๋ฅ๋ ๊ฐ์ฅ ๋ง์ aspectJ ํํ์์ ๊ธฐ๋ฐ์ผ๋ก ์ฌ์ฉํ๋ AspectJExpressionPointcut์ ์ฌ์ฉํ๊ฒ ๋๋ค.
์ฌ๋ฌ ์ด๋๋ฐ์ด์ ํจ๊ป ์ ์ฉ
์ด๋๋ฐ์ด์ ๋ ํ๋์ ํฌ์ธํธ์ปท๊ณผ ํ๋์ ์ด๋๋ฐ์ด์ค๋ฅผ ๊ฐ์ง๊ณ ์๋ค.
๋ง์ฝ ์ฌ๋ฌ ์ด๋๋ฐ์ด์ ๋ฅผ ํ๋์ target์ ์ ์ฉํ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผํ ๊น?
์ฝ๊ฒ ์ด์ผ๊ธฐํด์ ํ๋์ target์ ์ฌ๋ฌ ์ด๋๋ฐ์ด์ค๋ฅผ ์ ์ฉํ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผํ ๊น?
์ฌ๋ฌ ํ๋ก์
MultiAdvisorTest
@Test
@DisplayName("์ฌ๋ฌ ํ๋ก์")
void multiAdvisorTest1() {
//client -> proxy2(advisor2) -> proxy1(advisor1) -> target
//ํ๋ก์1 ์์ฑ
ServiceInterface target = new ServiceImpl();
ProxyFactory proxyFactory1 = new ProxyFactory(target);
DefaultPointcutAdvisor advisor1 = new DefaultPointcutAdvisor(Pointcut.TRUE, new Advice1());
proxyFactory1.addAdvisor(advisor1);
ServiceInterface proxy1 = (ServiceInterface) proxyFactory1.getProxy();
//ํ๋ก์2 ์์ฑ, target -> proxy1 ์
๋ ฅ
ProxyFactory proxyFactory2 = new ProxyFactory(proxy1);
DefaultPointcutAdvisor advisor2 = new DefaultPointcutAdvisor(Pointcut.TRUE, new Advice2());
proxyFactory2.addAdvisor(advisor2);
ServiceInterface proxy2 = (ServiceInterface) proxyFactory2.getProxy();
//์คํ
proxy2.save();
}
@Slf4j
static class Advice1 implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
log.info("advice1 ํธ์ถ");
return invocation.proceed();
}
}
@Slf4j
static class Advice2 implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
log.info("advice2 ํธ์ถ");
return invocation.proceed();
}
}
์ด ์ฝ๋๋ ๋ฐํ์์ ๋ค์๊ณผ ๊ฐ์ด ๋์ํ๋ค.
์ฌ๋ฌ ํ๋ก์์ ๋ฌธ์
์ด ๋ฐฉ๋ฒ์ด ์๋ชป๋ ๊ฒ์ ์๋์ง๋ง, ํ๋ก์๋ฅผ 2๋ฒ ์์ฑํด์ผ ํ๋ค๋ ๋ฌธ์ ๊ฐ ์๋ค.
๋ง์ฝ ์ ์ฉํด์ผ ํ๋ ์ด๋๋ฐ์ด์ ๊ฐ 10๊ฐ ๋ผ๋ฉด 10๊ฐ์ ํ๋ก์๋ฅผ ์์ฑํด์ผํ๋ค.
ํ๋์ ํ๋ก์, ์ฌ๋ฌ ์ด๋๋ฐ์ด์
์คํ๋ง์ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ํ๋์ ํ๋ก์์ ์ฌ๋ฌ ์ด๋๋ฐ์ด์ ๋ฅผ ์ ์ฉํ ์ ์๊ฒ ๋ง๋ค์ด๋์๋ค.
@Test
@DisplayName("ํ๋์ ํ๋ก์, ์ฌ๋ฌ ์ด๋๋ฐ์ด์ ")
void multiAdvisorTest2() {
//client -> proxy -> advisor2 -> advisor1 -> target
DefaultPointcutAdvisor advisor1 = new DefaultPointcutAdvisor(Pointcut.TRUE, new Advice1());
DefaultPointcutAdvisor advisor2 = new DefaultPointcutAdvisor(Pointcut.TRUE, new Advice2());
//ํ๋ก์1 ์์ฑ
ServiceInterface target = new ServiceImpl();
ProxyFactory proxyFactory1 = new ProxyFactory(target);
proxyFactory1.addAdvisor(advisor2);
proxyFactory1.addAdvisor(advisor1);
ServiceInterface proxy = (ServiceInterface) proxyFactory1.getProxy();
//์คํ
proxy.save();
}
ํ๋ก์ ํฉํ ๋ฆฌ์ ์ํ๋ ๋งํผ addAdvisor()๋ฅผ ํตํด์ ์ด๋๋ฐ์ด์ ๋ฅผ ๋ฑ๋กํ๋ฉด ๋๋ค.
๋ฑ๋กํ๋ ์์๋๋ก advisor๊ฐ ํธ์ถ๋๋ค. ์ฌ๊ธฐ์๋ advisor2, advisor1 ์์๋ก ๋ฑ๋กํ๋ค.

์ ๋ฆฌ
๊ฒฐ๊ณผ์ ์ผ๋ก ์ฌ๋ฌ ํ๋ก์๋ฅผ ์ฌ์ฉํ ๋์ ๋น๊ตํด์ ๊ฒฐ๊ณผ๋ ๊ฐ๊ณ , ์ฑ๋ฅ์ ๋ ์ข๋ค.
์คํ๋ง์ AOP๋ฅผ ์ฒ์ ๊ณต๋ถํ๊ฑฐ๋ ์ฌ์ฉํ๋ฉด, AOP ์ ์ฉ ์ ๋งํผ ํ๋ก์๊ฐ ์์ฑ๋๋ค๊ณ ์ฐฉ๊ฐํ๊ฒ ๋๋ค. ์คํ๋ง์ AOP๋ฅผ ์ ์ฉํ ๋, ์ต์ ํ๋ฅผ ์งํํด์ ์ง๊ธ์ฒ๋ผ ํ๋ก์๋ ํ๋๋ง ๋ง๋ค๊ณ , ํ๋์ ํ๋ก์์ ์ฌ๋ฌ ์ด๋๋ฐ์ด์ ๋ฅผ ์ ์ฉํ๋ค.
์ ๋ฆฌํ๋ฉด ํ๋์ target์ ์ฌ๋ฌ AOP๊ฐ ๋์์ ์ ์ฉ๋์ด๋, ์คํ๋ง์ AOP๋ target ๋ง๋ค ํ๋์ ํ๋ก์๋ง ์์ฑํ๋ค.
์ด๋ถ๋ถ์ ๊ผญ ๊ธฐ์ตํด๋์.
์ ๋ฆฌ
ํ๋ก์ ํฉํ ๋ฆฌ ๋๋ถ์ ๊ฐ๋ฐ์๋ ๋งค์ฐ ํธ๋ฆฌํ๊ฒ ํ๋ก์๋ฅผ ์์ฑํ ์ ์๊ฒ ๋์๋ค.
์ถ๊ฐ๋ก ์ด๋๋ฐ์ด์ , ์ด๋๋ฐ์ด์ค, ํฌ์ธํธ์ปท ์ด๋ผ๋ ๊ฐ๋
๋๋ถ์ ์ด๋ค ๋ถ๊ฐ ๊ธฐ๋ฅ์ ์ด๋์ ์ ์ฉํ ์ง ๋ช
ํํ๊ฒ ์ดํดํ ์ ์์๋ค.
๋จ์ ๋ฌธ์
ํ๋ก์ ํฉํ ๋ฆฌ์ ์ด๋๋ฐ์ด์ ๊ฐ์ ๊ฐ๋ ๋๋ถ์ ์ง๊ธ๊น์ง ๊ณ ๋ฏผํ๋ ๋ฌธ์ ๋ค์ ํด๊ฒฐ๋์๋ค.
ํ๋ก์๋ ๊น๋ํ๊ฒ ์ ์ฉํ๊ณ ํฌ์ธํธ์ปท์ผ๋ก ์ด๋์ ๋ถ๊ฐ ๊ธฐ๋ฅ์ ์ ์ฉํ ์ง๋ ๋ช ํํ๊ฒ ์ ์ํ ์ ์๋ค.
์๋ณธ ์ฝ๋๋ฅผ ์ ํ ์๋์ง ์๊ณ ํ๋ก์๋ฅผ ํตํด ๋ถ๊ฐ ๊ธฐ๋ฅ๋ ์ ์ฉํ ์ ์์๋ค.
๊ทธ๋ฐ๋ฐ ์์ง ํด๊ฒฐ๋์ง ์๋ ๋ฌธ์ ๊ฐ ์๋ค.
๋ฌธ์ 1 - ๋๋ฌด ๋ง์ ์ค์
๋ฐ๋ก ProxyFactoryConfigV1, ProxyFactoryConfigV2์ ๊ฐ์ ์ค์ ํ์ผ์ด ์ง๋์น๊ฒ ๋ง๋ค๋ ์ ์ด๋ค.
์๋ฅผ ๋ค์ด์ ์ ํ๋ฆฌ์ผ์ด์
์ ์คํ๋ง ๋น์ด 100๊ฐ๊ฐ ์๋ค๋ฉด ์ฌ๊ธฐ์ ํ๋ก์๋ฅผ ํตํด ๋ถ๊ฐ ๊ธฐ๋ฅ์ ์ ์ฉํ๋ ค๋ฉด 100๊ฐ์ ๋ ์ ํ๋ก์ ์์ฑ ์ฝ๋๋ฅผ ๋ง๋ค์ด์ผ ํ๋ค! ๋ฌด์ํ ๋ง์ ์ค์ ํ์ผ ๋๋ฌธ์ ์ค์ ์ง์ฅ์ ๊ฒฝํํ๊ฒ ๋ ๊ฒ์ด๋ค. ์ต๊ทผ์๋ ์คํ๋ง ๋น์ ๋ฑ๋กํ๊ธฐ ๊ท์ฐฎ์์ ์ปดํฌ๋ํธ ์ค์บ๊น์ง ์ฌ์ฉํ๋๋ฐ, ์ด๋ ๊ฒ ์ง์ ๋ฑ๋กํ๋ ๊ฒ๋ ๋ชจ์๋ผ์, ํ๋ก์ ๋ฅผ ์ ์ฉํ๋ ์ฝ๋๊น์ง ๋น ์์ฑ ์ฝ๋์ ๋ฃ์ด์ผ ํ๋ค.
๋ฌธ์ 2 - ์ปดํฌ๋ํธ ์ค์บ
์ ํ๋ฆฌ์ผ์ด์ V3์ฒ๋ผ ์ปดํฌ๋ํธ ์ค์บ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ง๊ธ๊น์ง ํ์ตํ ๋ฐฉ๋ฒ์ผ๋ก๋ ํ๋ก์ ์ ์ฉ์ด ๋ถ๊ฐ๋ฅํ๋ค.
์๋ํ๋ฉด ์ค์ ๊ฐ์ฒด๋ฅผ ์ปดํฌ๋ํธ ์ค์บ์ผ๋ก ์คํ๋ง ์ปจํ ์ด๋์ ์คํ๋ง ๋น์ผ๋ก ๋ฑ๋ก์ ๋ค ํด๋ฒ๋ฆฐ ์ํ์ด๊ธฐ ๋๋ฌธ์ด๋ค.
์ง๊ธ๊น์ง ํ์ตํ ํ๋ก์๋ฅผ ์ ์ฉํ๋ ค๋ฉด, ์ค์ ๊ฐ์ฒด๋ฅผ ์คํ๋ง ์ปจํ ์ด๋์ ๋น์ผ๋ก ๋ฑ๋กํ๋ ๊ฒ์ด ์๋๋ผ ProxyFactoryConfigV1์์ ํ ๊ฒ ์ฒ๋ผ, ๋ถ๊ฐ ๊ธฐ๋ฅ์ด ์๋ ํ๋ก์๋ฅผ ์ค์ ๊ฐ์ฒด ๋์ ์คํ๋ง ์ปจํ ์ด๋์ ๋น์ผ๋ก ๋ฑ ๋กํด์ผ ํ๋ค.
๋ ๊ฐ์ง ๋ฌธ์ ๋ฅผ ํ๋ฒ์ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ์ด ๋ฐ๋ก ๋ค์์ ์ค๋ช ํ ๋น ํ์ฒ๋ฆฌ๊ธฐ์ด๋ค.
'Spring > AOP' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
@Aspect AOP (0) | 2024.11.12 |
---|---|
๋น ํ์ฒ๋ฆฌ๊ธฐ (0) | 2024.11.12 |
ํ๋ก์ ํฉํ ๋ฆฌ (0) | 2024.11.11 |
CGLIB (0) | 2024.11.11 |
JDK ๋์ ํ๋ก์ (0) | 2024.11.11 |