1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      SpringBean的后處理器操作

      本篇文章給大家分享的是有關(guān)SpringBean的后處理器操作,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

      成都創(chuàng)新互聯(lián)公司是一家專業(yè)提供汨羅企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計、成都網(wǎng)站制作、HTML5建站、小程序制作等業(yè)務(wù)。10年已為汨羅眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)絡(luò)公司優(yōu)惠進行中。

      一 配置文件

      
      
         
         
         
         
         
      

      二 接口

      Axe

      package org.crazyit.app.service;
      public interface Axe
      {
         public String chop();
      }

      Person

      package org.crazyit.app.service;
      public interface Person
      {
         public void useAxe();
      }

      三 Bean

      Chinese

      package org.crazyit.app.service.impl;
      import org.springframework.beans.factory.InitializingBean;
      import org.springframework.beans.BeansException;
      import org.springframework.beans.factory.config.BeanPostProcessor;
      import org.springframework.context.ApplicationContext;
      import org.springframework.context.support.ClassPathXmlApplicationContext;
      import org.crazyit.app.service.*;
      public class Chinese
        implements Person,InitializingBean
      {
        private Axe axe;
        private String name;
        public Chinese()
        {
          System.out.println("Spring實例化主調(diào)bean:Chinese實例...");
        }
        public void setAxe(Axe axe)
        {
          this.axe = axe;
        }
        public void setName(String name)
        {
          System.out.println("Spring執(zhí)行setName()方法注入依賴關(guān)系...");
          this.name = name;
        }
        public void useAxe()
        {
          System.out.println(name + axe.chop());
        }
        // 下面是兩個生命周期方法
        public void init()
        {
          System.out.println("正在執(zhí)行初始化方法 init...");
        }
        public void afterPropertiesSet() throws Exception
        {
          System.out.println("正在執(zhí)行初始化方法 afterPropertiesSet...");
        }
      }

      SteelAxe

      package org.crazyit.app.service.impl;
      import org.crazyit.app.service.*;
      public class SteelAxe
         implements Axe
      {
         public SteelAxe()
         {
            System.out.println("Spring實例化依賴bean:SteelAxe實例...");
         }
         public String chop()
         {
            return "鋼斧砍柴真快";
         }
      }

      四 Bean后處理器

      package org.crazyit.app.util;
      import org.springframework.beans.BeansException;
      import org.springframework.beans.factory.config.BeanPostProcessor;
      import org.crazyit.app.service.*;
      import org.crazyit.app.service.impl.*;
      public class MyBeanPostProcessor
        implements BeanPostProcessor
      {
        /**
         * 對容器中的Bean實例進行后處理
         * @param bean 需要進行后處理的原Bean實例
         * @param beanName 需要進行后處理的Bean的配置id
         * @return 返回后處理完成后的Bean
         */
        public Object postProcessBeforeInitialization
          (Object bean , String beanName)
        {
          System.out.println("Bean后處理器在初始化之前對"
            + beanName + "進行增強處理...");
          // 返回的處理后的Bean實例,該實例就是容器中實際使用的Bean
          // 該Bean實例甚至可與原Bean截然不同
          return bean;
        }
        public Object postProcessAfterInitialization
          (Object bean , String beanName)
        {
          System.out.println("Bean后處理器在初始化之后對"
            + beanName + "進行增強處理...");
          // 如果該Bean是Chinese類的實例
          if (bean instanceof Chinese)
          {
            // 修改其name成員變量
            Chinese c = (Chinese)bean;
            c.setName("瘋狂iOS講義");
          }
          return bean;
        }
      }

      五 測試結(jié)果

      Spring實例化主調(diào)bean:Chinese實例...
      Spring實例化依賴bean:SteelAxe實例...
      Bean后處理器在初始化之前對steelAxe進行增強處理...
      Bean后處理器在初始化之后對steelAxe進行增強處理...
      Spring執(zhí)行setName()方法注入依賴關(guān)系...
      Bean后處理器在初始化之前對chinese進行增強處理...
      正在執(zhí)行初始化方法 afterPropertiesSet...
      正在執(zhí)行初始化方法 init...
      Bean后處理器在初始化之后對chinese進行增強處理...
      Spring執(zhí)行setName()方法注入依賴關(guān)系...
      瘋狂iOS講義鋼斧砍柴真快

      以上就是SpringBean的后處理器操作,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降摹OM隳芡ㄟ^這篇文章學到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。


      分享文章:SpringBean的后處理器操作
      網(wǎng)頁地址:http://ef60e0e.cn/article/jsgiip.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        南康市| 惠安县| 鹿泉市| 承德市| 杭锦后旗| 广河县| 连平县| 舞钢市| 栖霞市| 上虞市| 颍上县| 汤原县| 临汾市| 织金县| 尤溪县| 重庆市| 海伦市| 岚皋县| 扎囊县| 泗洪县| 无极县| 太湖县| 荔浦县| 胶南市| 白山市| 亳州市| 武冈市| 调兵山市| 萨迦县| 绥江县| 曲水县| 河曲县| 漠河县| 屯留县| 禄劝| 广南县| 上思县| 蓝田县| 胶南市| 嘉禾县| 合川市|