List of usage examples for org.springframework.beans.factory.config BeanDefinitionHolder getBeanDefinition
public BeanDefinition getBeanDefinition()
From source file:org.jboss.windup.config.spring.namespace.java.SpringNamespaceHandlerUtil.java
public static BeanDefinition resolveBeanDefinition(BeanDefinition beanDef, Element element, ParserContext context) {/* w w w .j a v a 2 s .c o m*/ BeanDefinitionParserDelegate delegate = context.getDelegate(); String namespace = element.getNamespaceURI(); // check to see whether it is the default Spring bean decorator... if (StringUtils.equals(namespace, BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI)) { BeanDefinitionHolder holder = delegate.parseBeanDefinitionElement(element, beanDef); return holder.getBeanDefinition(); } // otherwise, see if it is supported based on our namespace resolver... NamespaceHandler namespaceHandler = delegate.getReaderContext().getNamespaceHandlerResolver() .resolve(namespace); if (namespaceHandler == null) { throw new FatalBeanException("Unable to find parser for bean with namespace: " + namespace); } return namespaceHandler.parse(element, new ParserContext(delegate.getReaderContext(), delegate, beanDef)); }
From source file:org.activiti.spring.components.aop.util.Scopifier.java
public static BeanDefinitionHolder createScopedProxy(String beanName, BeanDefinition definition, BeanDefinitionRegistry registry, boolean proxyTargetClass) { BeanDefinitionHolder proxyHolder = ScopedProxyUtils .createScopedProxy(new BeanDefinitionHolder(definition, beanName), registry, proxyTargetClass); registry.registerBeanDefinition(beanName, proxyHolder.getBeanDefinition()); return proxyHolder; }
From source file:org.jdal.aop.SerializableProxyUtils.java
public static BeanDefinitionHolder createSerializableProxy(BeanDefinitionHolder definition, BeanDefinitionRegistry registry, boolean proxyTargetClass) { String originalBeanName = definition.getBeanName(); BeanDefinition targetDefinition = definition.getBeanDefinition(); // Create a scoped proxy definition for the original bean name, // "hiding" the target bean in an internal target definition. RootBeanDefinition proxyDefinition = new RootBeanDefinition(SerializableProxyFactoryBean.class); proxyDefinition.setOriginatingBeanDefinition(definition.getBeanDefinition()); proxyDefinition.setSource(definition.getSource()); proxyDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); String targetBeanName = getTargetBeanName(originalBeanName); proxyDefinition.getPropertyValues().add("targetBeanName", targetBeanName); if (proxyTargetClass) { targetDefinition.setAttribute(AutoProxyUtils.PRESERVE_TARGET_CLASS_ATTRIBUTE, Boolean.TRUE); } else {/* ww w . j av a 2s. c o m*/ proxyDefinition.getPropertyValues().add("proxyTargetClass", Boolean.FALSE); } // Copy autowire settings from original bean definition. proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate()); proxyDefinition.setPrimary(targetDefinition.isPrimary()); if (targetDefinition instanceof AbstractBeanDefinition) { proxyDefinition.copyQualifiersFrom((AbstractBeanDefinition) targetDefinition); } // Set singleton property of FactoryBean proxyDefinition.getPropertyValues().add("singleton", !targetDefinition.isPrototype()); // The target bean should be ignored in favor of the scoped proxy. targetDefinition.setAutowireCandidate(false); targetDefinition.setPrimary(false); // Register the target bean as separate bean in the factory. registry.registerBeanDefinition(targetBeanName, targetDefinition); // Return the scoped proxy definition as primary bean definition // (potentially an inner bean). return new BeanDefinitionHolder(proxyDefinition, originalBeanName, definition.getAliases()); }
From source file:uk.org.ponder.rsac.support.BeanDefUtil.java
public static Object propertyValueToBeanName(Object value, BeanDefConverter converter) { Object beanspec = null;// w w w . ja v a2 s.co m if (value instanceof BeanDefinitionHolder) { // Resolve BeanDefinitionHolder: contains BeanDefinition with name and // aliases. BeanDefinitionHolder bdHolder = (BeanDefinitionHolder) value; String beanname = bdHolder.getBeanName(); converter.convertBeanDef(bdHolder.getBeanDefinition(), beanname, true); beanspec = beanname; } else if (value instanceof BeanDefinition) { throw new IllegalArgumentException("No idea what to do with bean definition!"); } else if (value instanceof RuntimeBeanReference) { RuntimeBeanReference ref = (RuntimeBeanReference) value; beanspec = ref.getBeanName(); } else if (value instanceof ManagedList) { List valuelist = (List) value; StringList togo = new StringList(); for (int i = 0; i < valuelist.size(); ++i) { String thisbeanname = (String) propertyValueToBeanName(valuelist.get(i), converter); togo.add(thisbeanname); } beanspec = togo; } else if (value instanceof String) { beanspec = new ValueHolder((String) value); } else if (value instanceof TypedStringValue) { beanspec = new ValueHolder(((TypedStringValue) value).getValue()); } else { Logger.log.warn( "RSACBeanLocator Got value " + value + " of unknown type " + value.getClass() + ": ignoring"); } return beanspec; }
From source file:me.springframework.di.spring.SpringConfigurationLoader.java
/** * Constructs a {@link MutableSource} from a source providing an anonymous * bean./*from w w w .j a v a 2 s . co m*/ * * @param sink * The {@link Sink} configured to receive the value produced by * the source. * @param value * The actually value constructed. * @return The {@link Source} representation of the object producing that * anonymous bean. */ private static MutableSource load(Sink sink, BeanDefinitionHolder value, MutableContext context) { MutableInstance instance = new MutableInstance(sink, value.getBeanName()); load(instance, value.getBeanDefinition(), context); return instance; }
From source file:org.constretto.spring.internal.ConstrettoAutowireCandidateResolver.java
@SuppressWarnings("unchecked") public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { if (bdHolder.getBeanDefinition() .getAttribute(EnvironmentAnnotationConfigurer.INCLUDE_IN_COLLECTIONS) != null && descriptor.getCollectionType() != null) { Class[] interfaces = (Class[]) bdHolder.getBeanDefinition() .getAttribute(EnvironmentAnnotationConfigurer.INCLUDE_IN_COLLECTIONS); for (Class anInterface : interfaces) { if (descriptor.getCollectionType().isAssignableFrom(anInterface)) { return true; }/* w ww . j a va 2s . c o m*/ } } if (descriptor.getDependencyType().isInterface()) { return super.isAutowireCandidate(bdHolder, descriptor); } else { return findEnvironmentAnnotation(descriptor.getDependencyType()) == null || super.isAutowireCandidate(bdHolder, descriptor); } }
From source file:org.bigtester.ate.xmlschema.TestDatabaseInitializerBeanDefinitionParser.java
/** * {@inheritDoc}// w w w .j a v a 2 s .c o m */ @Override protected AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) { // Here we parse the Spring elements such as < property> if (parserContext == null || element == null) throw GlobalUtils.createNotInitializedException("element and parserContext"); // Here we parse the Spring elements such as < property> BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element); BeanDefinition bDef = holder.getBeanDefinition(); bDef.setBeanClassName(TestDatabaseInitializer.class.getName()); parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), bDef); return (AbstractBeanDefinition) bDef; }
From source file:org.bigtester.ate.xmlschema.BaseElementActionBeanDefinitionParser.java
/** * {@inheritDoc}//from w w w . j a v a2s.com */ @Override protected AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) { // Here we parse the Spring elements such as < property> if (parserContext == null || element == null) throw new IllegalStateException("Incorrect xsd xml parsing."); BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element); BeanDefinition bDef = holder.getBeanDefinition(); bDef.setBeanClassName(BaseElementAction.class.getName()); parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), bDef); return (AbstractBeanDefinition) bDef; }
From source file:org.activiti.spring.components.aop.util.Scopifier.java
@Override protected Object resolveValue(Object value) { BeanDefinition definition = null;/*from ww w .j a v a 2 s. c om*/ String beanName = null; if (value instanceof BeanDefinition) { definition = (BeanDefinition) value; beanName = BeanDefinitionReaderUtils.generateBeanName(definition, registry); } else if (value instanceof BeanDefinitionHolder) { BeanDefinitionHolder holder = (BeanDefinitionHolder) value; definition = holder.getBeanDefinition(); beanName = holder.getBeanName(); } if (definition != null) { boolean nestedScoped = scope.equals(definition.getScope()); boolean scopeChangeRequiresProxy = !scoped && nestedScoped; if (scopeChangeRequiresProxy) { // Exit here so that nested inner bean definitions are not // analysed return createScopedProxy(beanName, definition, registry, proxyTargetClass); } } // Nested inner bean definitions are recursively analysed here value = super.resolveValue(value); return value; }
From source file:com.mtgi.analytics.aop.config.v11.BtDataSourceBeanDefinitionDecorator.java
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { BeanDefinition delegate = definition.getBeanDefinition(); BeanDefinitionBuilder wrapper = BeanDefinitionBuilder.rootBeanDefinition(DataSourceFactory.class); wrapper.addPropertyReference("trackingManager", node.getNodeValue()); wrapper.addPropertyValue("targetDataSource", delegate); wrapper.addPropertyValue("singleton", delegate.isSingleton()); return new BeanDefinitionHolder(wrapper.getRawBeanDefinition(), definition.getBeanName()); }