zoukankan      html  css  js  c++  java
  • spring静态工厂方法得到单例bean

    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.ApplicationContextAware;
    import org.springframework.stereotype.Repository;
    
    
    public final class TaskFactory {
    
        private static TaskFactory instance;
    
        private TaskFactory() {
    
        }
    
        public static TaskFactory getInstance() {
            if (instance == null) {
                instance = new TaskFactory();
            }
            return instance;
        }
    
        
    }
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
        <description></description>
        
        
        <bean id="taskFactory" class="com.yundaex.common.parent.threadpool.TaskFactory"
            factory-method="getInstance">
        </bean>
    </beans>
  • 相关阅读:
    [BJOI2019]排兵布阵
    关于DP题的状态定义转换和各种优化这档事
    容斥原理学习笔记
    莫比乌斯反演学习笔记
    每日进度
    每日进度
    每日进度
    每日进度
    每日进度
    每日进度
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/6844479.html
Copyright © 2011-2022 走看看