码迷,mamicode.com
首页 > 编程语言 > 详细

spring静态工厂方法得到单例bean

时间:2017-05-12 11:45:38      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:factory   comm   read   com   encoding   repo   stat   actor   instance   

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>

 

spring静态工厂方法得到单例bean

标签:factory   comm   read   com   encoding   repo   stat   actor   instance   

原文地址:http://www.cnblogs.com/tonggc1668/p/6844479.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!