44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
/*
|
|
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
|
* www.honyee.biz
|
|
* All rights reserved.
|
|
*
|
|
* This software is the confidential and proprietary information of
|
|
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
|
* You shall not disclose such Confidential Information and shall use
|
|
* it only in accordance with the terms of the license agreement you
|
|
* entered into with Honyee Industry Group Co., Ltd.
|
|
*/
|
|
package cc.wdcy.domain.shared;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
/**
|
|
* @author Shengzhao Li
|
|
*/
|
|
public abstract class BeanProvider {
|
|
|
|
private static ApplicationContext applicationContext;
|
|
|
|
|
|
public static void initialize(ApplicationContext applicationContext) {
|
|
BeanProvider.applicationContext = applicationContext;
|
|
}
|
|
|
|
/**
|
|
* Get Bean by clazz.
|
|
*
|
|
* @param clazz Class
|
|
* @param <T> class type
|
|
* @return Bean instance
|
|
*/
|
|
public static <T> T getBean(Class<T> clazz) {
|
|
return applicationContext.getBean(clazz);
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public static <T> T getBean(String beanId) {
|
|
return (T) applicationContext.getBean(beanId);
|
|
}
|
|
|
|
} |