zoukankan      html  css  js  c++  java
  • flying中的AOP和IOC

    注入属性:
    private synchronized void injectReferenceServices() {
     if(this.injectReferenceServicesInitialized) return;
     PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(this.serviceClass);
     if(pds == null) return;
     for(PropertyDescriptor pd: pds) {
      Class<?> type = pd.getPropertyType();
      if(type == null) continue;
      if(type.getName().startsWith("java") || type.getName().startsWith("org"))  continue;
      if(module.getModuleConfig().getServiceConfigs().containsKey(type.getName())) {
       try {
        pd.getWriteMethod().invoke(this.serviceObject, new Object[]{module.getService(type)});
        logger.debug(this.serviceClass.getName()+" injectReferenceService ‘"+pd.getName()+"’success!");
       } catch (Exception e) {
        logger.error(this.serviceClass.getName()+" injectReferenceService ‘"+pd.getName()+"’失败,可能导致部分功能无法正常使用!", e);
       }
      }
     }
     this.injectReferenceServicesInitialized = true;
    }

    服务调用拦截:
    public Object intercept(Object service, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
      。。。。。。。。。。。
       //
       if(!injectReferenceServicesInitialized) {
        this.injectReferenceServices();
       }
                        。。。。。。。
    }
    如似乎,一个不太完美的IOC实现了。

  • 相关阅读:
    Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)
    Codeforces Round #592 (Div. 2)
    日常杂谈
    vc_redist x64 或者x86下载地址
    windows terminal编译实录
    刷机,twrp,安装xposed
    博客迁移公告
    tcpdump实用笔记
    分享一篇企鹅的暑期实习生技术面经验
    visudo使用笔记
  • 原文地址:https://www.cnblogs.com/hifong/p/5831796.html
Copyright © 2011-2022 走看看