List of usage examples for org.springframework.aop.scope ScopedProxyUtils getTargetBeanName
public static String getTargetBeanName(String originalBeanName)
From source file:org.springframework.cloud.task.listener.annotation.TaskListenerExecutorFactoryBean.java
private void initializeExecutor() { ConfigurableListableBeanFactory factory = context.getBeanFactory(); for (String beanName : context.getBeanDefinitionNames()) { if (!ScopedProxyUtils.isScopedTarget(beanName)) { Class<?> type = null; try { type = AutoProxyUtils.determineTargetClass(factory, beanName); } catch (RuntimeException ex) { // An unresolvable bean type, probably from a lazy bean - let's ignore it. if (logger.isDebugEnabled()) { logger.debug("Could not resolve target class for bean with name '" + beanName + "'", ex); }/* w w w. ja v a 2 s . co m*/ } if (type != null) { if (ScopedObject.class.isAssignableFrom(type)) { try { type = AutoProxyUtils.determineTargetClass(factory, ScopedProxyUtils.getTargetBeanName(beanName)); } catch (RuntimeException ex) { // An invalid scoped proxy arrangement - let's ignore it. if (logger.isDebugEnabled()) { logger.debug("Could not resolve target bean for scoped proxy '" + beanName + "'", ex); } } } try { processBean(beanName, type); } catch (RuntimeException ex) { throw new BeanInitializationException("Failed to process @BeforeTask " + "annotation on bean with name '" + beanName + "'", ex); } } } } }
From source file:org.springframework.context.event.EventListenerMethodProcessor.java
@Override public void afterSingletonsInstantiated() { List<EventListenerFactory> factories = getEventListenerFactories(); ConfigurableApplicationContext context = getApplicationContext(); String[] beanNames = context.getBeanNamesForType(Object.class); for (String beanName : beanNames) { if (!ScopedProxyUtils.isScopedTarget(beanName)) { Class<?> type = null; try { type = AutoProxyUtils.determineTargetClass(context.getBeanFactory(), beanName); } catch (Throwable ex) { // An unresolvable bean type, probably from a lazy bean - let's ignore it. if (logger.isDebugEnabled()) { logger.debug("Could not resolve target class for bean with name '" + beanName + "'", ex); }/*w w w . j av a2s . c om*/ } if (type != null) { if (ScopedObject.class.isAssignableFrom(type)) { try { Class<?> targetClass = AutoProxyUtils.determineTargetClass(context.getBeanFactory(), ScopedProxyUtils.getTargetBeanName(beanName)); if (targetClass != null) { type = targetClass; } } catch (Throwable ex) { // An invalid scoped proxy arrangement - let's ignore it. if (logger.isDebugEnabled()) { logger.debug("Could not resolve target bean for scoped proxy '" + beanName + "'", ex); } } } try { processBean(factories, beanName, type); } catch (Throwable ex) { throw new BeanInitializationException("Failed to process @EventListener " + "annotation on bean with name '" + beanName + "'", ex); } } } } }
From source file:org.springframework.social.config.support.ProviderConfigSupport.java
public static BeanDefinition registerConnectionFactoryLocatorBean(BeanDefinitionRegistry registry) { if (logger.isDebugEnabled()) { logger.debug("Registering ConnectionFactoryLocator bean"); }/* w w w . ja v a 2 s .c o m*/ if (!registry.containsBeanDefinition(CONNECTION_FACTORY_LOCATOR_ID)) { BeanDefinitionHolder connFactoryLocatorBeanDefHolder = new BeanDefinitionHolder(BeanDefinitionBuilder .genericBeanDefinition(ConnectionFactoryRegistry.class).getBeanDefinition(), CONNECTION_FACTORY_LOCATOR_ID); BeanDefinitionHolder scopedProxy = ScopedProxyUtils.createScopedProxy(connFactoryLocatorBeanDefHolder, registry, false); registry.registerBeanDefinition(scopedProxy.getBeanName(), scopedProxy.getBeanDefinition()); } BeanDefinition connectionFactoryLocatorBD = registry .getBeanDefinition(ScopedProxyUtils.getTargetBeanName(CONNECTION_FACTORY_LOCATOR_ID)); return connectionFactoryLocatorBD; }
From source file:org.springframework.social.config.support.ProviderConfigurationSupport.java
private BeanDefinition registerConnectionFactoryLocatorBean(BeanDefinitionRegistry registry) { Class<?> connectionFactoryRegistryClass = isSocialSecurityAvailable() ? org.springframework.social.security.SocialAuthenticationServiceRegistry.class : ConnectionFactoryRegistry.class; if (!registry.containsBeanDefinition(CONNECTION_FACTORY_LOCATOR_ID)) { if (logger.isDebugEnabled()) { logger.debug("Registering ConnectionFactoryLocator bean (" + connectionFactoryRegistryClass.getName() + ")"); }/*from www .j ava2s.c o m*/ BeanDefinitionHolder connFactoryLocatorBeanDefHolder = new BeanDefinitionHolder( BeanDefinitionBuilder.genericBeanDefinition(connectionFactoryRegistryClass).getBeanDefinition(), CONNECTION_FACTORY_LOCATOR_ID); BeanDefinitionHolder scopedProxy = ScopedProxyUtils.createScopedProxy(connFactoryLocatorBeanDefHolder, registry, false); registry.registerBeanDefinition(scopedProxy.getBeanName(), scopedProxy.getBeanDefinition()); } BeanDefinition connectionFactoryLocatorBD = registry .getBeanDefinition(ScopedProxyUtils.getTargetBeanName(CONNECTION_FACTORY_LOCATOR_ID)); return connectionFactoryLocatorBD; }