本文整理匯總了Java中org.springframework.beans.factory.BeanFactory.FACTORY_BEAN_PREFIX屬性的典型用法代碼示例。如果您正苦於以下問題:Java BeanFactory.FACTORY_BEAN_PREFIX屬性的具體用法?Java BeanFactory.FACTORY_BEAN_PREFIX怎麽用?Java BeanFactory.FACTORY_BEAN_PREFIX使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.springframework.beans.factory.BeanFactory
的用法示例。
在下文中一共展示了BeanFactory.FACTORY_BEAN_PREFIX屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: postProcessBeforeInitialization
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
// disable publication until all the dependencies have been fulfilled
// ignore inner beans
if (bean instanceof OsgiServiceFactoryBean && beanFactory.containsLocalBean(beanName)) {
String exporterName = beanName;
if (beanFactory.isFactoryBean(beanName)) {
exporterName = BeanFactory.FACTORY_BEAN_PREFIX + beanName;
}
// if it's a singleton, then disable publication, otherwise ignore it
if (beanFactory.isSingleton(exporterName)) {
// get controller
ExporterInternalActions controller = ExporterControllerUtils.getControllerFor(bean);
controller.registerServiceAtStartup(false);
}
}
return bean;
}
示例2: getLifecycleBeans
/**
* Retrieve all applicable Lifecycle beans: all singletons that have already been created,
* as well as all SmartLifecycle beans (even if they are marked as lazy-init).
* @return the Map of applicable beans, with bean names as keys and bean instances as values
*/
protected Map<String, Lifecycle> getLifecycleBeans() {
Map<String, Lifecycle> beans = new LinkedHashMap<String, Lifecycle>();
String[] beanNames = this.beanFactory.getBeanNamesForType(Lifecycle.class, false, false);
for (String beanName : beanNames) {
String beanNameToRegister = BeanFactoryUtils.transformedBeanName(beanName);
boolean isFactoryBean = this.beanFactory.isFactoryBean(beanNameToRegister);
String beanNameToCheck = (isFactoryBean ? BeanFactory.FACTORY_BEAN_PREFIX + beanName : beanName);
if ((this.beanFactory.containsSingleton(beanNameToRegister) &&
(!isFactoryBean || Lifecycle.class.isAssignableFrom(this.beanFactory.getType(beanNameToCheck)))) ||
SmartLifecycle.class.isAssignableFrom(this.beanFactory.getType(beanNameToCheck))) {
Lifecycle bean = this.beanFactory.getBean(beanNameToCheck, Lifecycle.class);
if (bean != this) {
beans.put(beanNameToRegister, bean);
}
}
}
return beans;
}
示例3: postProcessBeanFactory
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
if (isLogEnabled()) {
String[] beanNames = beanFactory.getBeanDefinitionNames();
for (String beanName : beanNames) {
String nameToLookup = beanName;
if (beanFactory.isFactoryBean(beanName)) {
nameToLookup = BeanFactory.FACTORY_BEAN_PREFIX + beanName;
}
Class<?> beanType = ClassUtils.getUserClass(beanFactory.getType(nameToLookup));
if (beanType != null && beanType.isAnnotationPresent(Deprecated.class)) {
BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
logDeprecatedBean(beanName, beanType, beanDefinition);
}
}
}
}
示例4: addServiceExporter
public void addServiceExporter(Object exporter, String exporterBeanName) {
Assert.hasText(exporterBeanName);
if (exportersSeen.putIfAbsent(exporterBeanName, VALUE) == null) {
String beanName = exporterBeanName;
if (beanFactory.isFactoryBean(exporterBeanName))
beanName = BeanFactory.FACTORY_BEAN_PREFIX + exporterBeanName;
// check if it's factory bean (no need to check for abstract
// definition since we're called by a BPP)
if (!beanFactory.isSingleton(beanName)) {
log.info("Exporter [" + beanName + "] is not singleton and will not be tracked");
}
else {
if (log.isDebugEnabled())
log.debug("Exporter [" + beanName + "] is being tracked for dependencies");
exporterToName.put(exporter, exporterBeanName);
// retrieve associated controller
ExporterInternalActions controller = ExporterControllerUtils.getControllerFor(exporter);
// disable publication at startup
controller.registerServiceAtStartup(false);
// populate the dependency maps
discoverDependentImporterFor(exporterBeanName, exporter);
}
}
}
示例5: obtainFreshBean
/**
* Obtain a fresh target object, retrieving a FactoryBean if necessary.
*/
@Override
protected Object obtainFreshBean(BeanFactory beanFactory, String beanName) {
return super.obtainFreshBean(beanFactory,
(this.isFactoryBean ? BeanFactory.FACTORY_BEAN_PREFIX + beanName : beanName));
}
示例6: postProcessBeforeInstantiation
@Override
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) {
// We only apply special treatment to ScriptFactory implementations here.
if (!ScriptFactory.class.isAssignableFrom(beanClass)) {
return null;
}
BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);
String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName;
String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);
ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
boolean isFactoryBean = false;
try {
Class<?> scriptedObjectType = scriptFactory.getScriptedObjectType(scriptSource);
// Returned type may be null if the factory is unable to determine the type.
if (scriptedObjectType != null) {
isFactoryBean = FactoryBean.class.isAssignableFrom(scriptedObjectType);
}
}
catch (Exception ex) {
throw new BeanCreationException(beanName,
"Could not determine scripted object type for " + scriptFactory, ex);
}
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
RefreshableScriptTargetSource ts = new RefreshableScriptTargetSource(this.scriptBeanFactory,
scriptedObjectBeanName, scriptFactory, scriptSource, isFactoryBean);
boolean proxyTargetClass = resolveProxyTargetClass(bd);
String language = (String) bd.getAttribute(LANGUAGE_ATTRIBUTE);
if (proxyTargetClass && (language == null || !language.equals("groovy"))) {
throw new BeanDefinitionValidationException(
"Cannot use proxyTargetClass=true with script beans where language is not 'groovy': '" +
language + "'");
}
ts.setRefreshCheckDelay(refreshCheckDelay);
return createRefreshableProxy(ts, interfaces, proxyTargetClass);
}
if (isFactoryBean) {
scriptedObjectBeanName = BeanFactory.FACTORY_BEAN_PREFIX + scriptedObjectBeanName;
}
return this.scriptBeanFactory.getBean(scriptedObjectBeanName);
}
示例7: SerializedEntityManagerFactoryBeanReference
public SerializedEntityManagerFactoryBeanReference(BeanFactory beanFactory, String beanName) {
this.beanFactory = beanFactory;
this.lookupName = BeanFactory.FACTORY_BEAN_PREFIX + beanName;
}