<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    hk2000c技術專欄

    技術源于哲學,哲學來源于生活 關心生活,關注健康,關心他人

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      111 隨筆 :: 1 文章 :: 28 評論 :: 0 Trackbacks
    BaseCommandController extends AbstractController extends WebContentGenerator WebContentGenerator extends WebApplicationObjectSupport extends ApplicationObjectSupport implements ApplicationContextAware 

    /**
      * Subclasses can override this for custom initialization behavior.
      * Gets called by <code>setApplicationContext</code> after setting the context instance.
      * <p>Note: Does </i>not</i> get called on reinitialization of the context
      * but rather just on first initialization of this object's context reference.
      * @throws ApplicationContextException in case of initialization errors
      * @throws BeansException if thrown by ApplicationContext methods
      * @see #setApplicationContext
      */
     protected void initApplicationContext() throws BeansException {
     }

    愿意為子類可以把初始化bean 動作放入此方法,可以自定義一些動作。

    我們再來看看調用
    public final void setApplicationContext(ApplicationContext context) throws BeansException {
      if (context == null && !isContextRequired()) {
       // Reset internal context state.
       this.applicationContext = null;
       this.messageSourceAccessor = null;
      }
      else if (this.applicationContext == null) {
       // Initialize with passed-in context.
       if (!requiredContextClass().isInstance(context)) {
        throw new ApplicationContextException(
          "Invalid application context: needs to be of type [" + requiredContextClass().getName() + "]");
       }
       this.applicationContext = context;
       this.messageSourceAccessor = new MessageSourceAccessor(context);
       initApplicationContext();
      }
      else {
       // Ignore reinitialization if same context passed in.
       if (this.applicationContext != context) {
        throw new ApplicationContextException(
          "Cannot reinitialize with different application context: current one is [" +
          this.applicationContext + "], passed-in one is [" + context + "]");
       }
      }
     }

    可以看到由 ApplicationObjectSupport  的 setApplicationContext 方法調用
    而此方法為 ApplicationContextAware 的唯一接口方法,

    public interface ApplicationContextAware {
     
     /**
      * Set the ApplicationContext that this object runs in.
      * Normally this call will be used to initialize the object.
      * <p>Invoked after population of normal bean properties but before an init callback such
      * as {@link org.springframework.beans.factory.InitializingBean#afterPropertiesSet()}
      * or a custom init-method. Invoked after {@link ResourceLoaderAware#setResourceLoader},
      * {@link ApplicationEventPublisherAware#setApplicationEventPublisher} and
      * {@link MessageSourceAware}, if applicable.
      * @param applicationContext the ApplicationContext object to be used by this object
      * @throws ApplicationContextException in case of context initialization errors
      * @throws BeansException if thrown by application context methods
      * @see org.springframework.beans.factory.BeanInitializationException
      */
     void setApplicationContext(ApplicationContext applicationContext) throws BeansException;

    }

    此方法被 ApplicationContextAwareProcessor 的 postProcessBeforeInitialization  調用
    ApplicationContextAwareProcessor implements BeanPostProcessor 
     public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
      if (bean instanceof ResourceLoaderAware) {
       ((ResourceLoaderAware) bean).setResourceLoader(this.applicationContext);
      }
      if (bean instanceof ApplicationEventPublisherAware) {
       ((ApplicationEventPublisherAware) bean).setApplicationEventPublisher(this.applicationContext);
      }
      if (bean instanceof MessageSourceAware) {
       ((MessageSourceAware) bean).setMessageSource(this.applicationContext);
      }
      if (bean instanceof ApplicationContextAware) {
       ((ApplicationContextAware) bean).setApplicationContext(this.applicationContext);
      }
      return bean;
     }



    posted on 2007-10-26 01:12 hk2000c 閱讀(620) 評論(0)  編輯  收藏 所屬分類: CMS項目開發
    主站蜘蛛池模板: 中文日韩亚洲欧美制服| 亚洲小视频在线播放| 三级片免费观看久久| 一级毛片直播亚洲| 美女视频黄a视频全免费网站色 | 成人免费一区二区无码视频| 亚洲成a人片毛片在线| 国产成人午夜精品免费视频| 亚洲国产精品专区| 成人无遮挡裸免费视频在线观看| 亚洲AV无码专区国产乱码不卡| 精品国产精品久久一区免费式| 国产成人综合亚洲一区| 亚洲爽爽一区二区三区| a毛片在线免费观看| 亚洲黄色网址大全| 免费看片免费播放| 免费看一级一级人妻片| 亚洲小说区图片区另类春色| 一级毛片不卡片免费观看| 亚洲一区中文字幕在线电影网| 在线A级毛片无码免费真人| 特黄特色的大片观看免费视频| 亚洲男同帅GAY片在线观看| 18女人腿打开无遮掩免费| 亚洲精品无码高潮喷水A片软| 亚洲日韩在线观看| 最近的中文字幕大全免费8| 亚洲日本va一区二区三区| 亚洲人成色77777在线观看大 | 精品国产日韩久久亚洲| 亚洲国产人成精品| 91久久青青草原线免费| 欧美亚洲精品一区二区| 久久精品国产亚洲AV网站| 亚洲免费综合色在线视频| 一级毛片免费在线| 亚洲人成在线精品| 区久久AAA片69亚洲| 国产精品69白浆在线观看免费| eeuss影院ss奇兵免费com|