본문 바로가기

IT-Consultant

Spring AOP 구조 분석

메인 메소드에서 호출했을때 refresh 메소스에서 처리하게 된다.

 public static void main(String[] args) {
  String[] configLocations = new String[] { "applicationContext.xml",
    "commonConcern.xml" };
  ApplicationContext context = new ClassPathXmlApplicationContext(
    configLocations);
  WriteArticleService articleService = (WriteArticleService) context
    .getBean("writeArticleService");
  articleService.write(new Article());
 }



    public void refresh()
        throws BeansException, IllegalStateException
    {
        synchronized(startupShutdownMonitor)
        {
            prepareRefresh();
            ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();
            prepareBeanFactory(beanFactory);
            try
            {
                postProcessBeanFactory(beanFactory);
                invokeBeanFactoryPostProcessors(beanFactory);
                registerBeanPostProcessors(beanFactory);
                initMessageSource();
                initApplicationEventMulticaster();
                initLifecycleDependentBeans();
                onRefresh();
                registerListeners();
                finishBeanFactoryInitialization(beanFactory);
                finishRefresh();
            }
            catch(BeansException ex)
            {
                beanFactory.destroySingletons();
                cancelRefresh(ex);
                throw ex;
            }
        }
    }