本文整理匯總了Java中org.springframework.beans.factory.config.BeanDefinition.setDependsOn方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanDefinition.setDependsOn方法的具體用法?Java BeanDefinition.setDependsOn怎麽用?Java BeanDefinition.setDependsOn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.beans.factory.config.BeanDefinition
的用法示例。
在下文中一共展示了BeanDefinition.setDependsOn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addSyntheticDependsOn
import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
private void addSyntheticDependsOn(BeanDefinition definition, String beanName) {
if (StringUtils.hasText(beanName)) {
String[] dependsOn = definition.getDependsOn();
if (dependsOn != null && dependsOn.length > 0) {
for (String dependOn : dependsOn) {
if (beanName.equals(dependOn)) {
return;
}
}
}
// add depends on
dependsOn = (String[]) ObjectUtils.addObjectToArray(dependsOn, beanName);
definition.setDependsOn(dependsOn);
Collection<String> markers = (Collection<String>) definition.getAttribute(SYNTHETIC_DEPENDS_ON);
if (markers == null) {
markers = new ArrayList<String>(2);
definition.setAttribute(SYNTHETIC_DEPENDS_ON, markers);
}
markers.add(beanName);
}
}
示例2: postProcessBeanFactory
import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
String[] autoInitBeanNames = beanFactory.getBeanNamesForType(AbstractCacheAutoInit.class, false, false);
if (autoInitBeanNames != null) {
BeanDefinition bd = beanFactory.getBeanDefinition(JetCacheAutoConfiguration.GLOBAL_CACHE_CONFIG_NAME);
String[] dependsOn = bd.getDependsOn();
if (dependsOn == null) {
dependsOn = new String[0];
}
int oldLen = dependsOn.length;
dependsOn = Arrays.copyOf(dependsOn, dependsOn.length + autoInitBeanNames.length);
System.arraycopy(autoInitBeanNames,0, dependsOn, oldLen, autoInitBeanNames.length);
bd.setDependsOn(dependsOn);
}
}