org.springframework.beans.factory.config.BeanDefinition

Here are the examples of the java api org.springframework.beans.factory.config.BeanDefinition taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

874 Examples 7

19 Source : NoSuchBeanDefinitionFailureAnalyzer.java
with Apache License 2.0
from yuanmabiji

private MethodMetadata getFactoryMethodMetadata(String beanName) {
    BeanDefinition beanDefinition = this.beanFactory.getBeanDefinition(beanName);
    if (beanDefinition instanceof AnnotatedBeanDefinition) {
        return ((AnnotatedBeanDefinition) beanDefinition).getFactoryMethodMetadata();
    }
    return null;
}

19 Source : BeanTypeRegistry.java
with Apache License 2.0
from yuanmabiji

private Method getFactoryMethod(BeanDefinition definition, Clreplaced<?> factoryClreplaced) {
    Method uniqueMethod = null;
    for (Method candidate : getCandidateFactoryMethods(definition, factoryClreplaced)) {
        if (candidate.getName().equals(definition.getFactoryMethodName())) {
            if (uniqueMethod == null) {
                uniqueMethod = candidate;
            } else if (!hasMatchingParameterTypes(candidate, uniqueMethod)) {
                return null;
            }
        }
    }
    return uniqueMethod;
}

19 Source : BeanTypeRegistry.java
with Apache License 2.0
from yuanmabiji

private boolean shouldConsiderNonPublicMethods(BeanDefinition definition) {
    return (definition instanceof AbstractBeanDefinition) && ((AbstractBeanDefinition) definition).isNonPublicAccessAllowed();
}

19 Source : BeanTypeRegistry.java
with Apache License 2.0
from yuanmabiji

private ResolvableType getFactoryMethodReturnType(BeanDefinition definition) {
    try {
        if (StringUtils.hasLength(definition.getFactoryBeanName()) && StringUtils.hasLength(definition.getFactoryMethodName())) {
            Method method = getFactoryMethod(this.beanFactory, definition);
            ResolvableType type = (method != null) ? ResolvableType.forMethodReturnType(method) : null;
            return type;
        }
    } catch (Exception ex) {
    }
    return null;
}

19 Source : BeanTypeRegistry.java
with Apache License 2.0
from yuanmabiji

private ResolvableType getFactoryBeanType(BeanDefinition definition, ResolvableType type) throws ClreplacedNotFoundException, LinkageError {
    ResolvableType generic = type.as(FactoryBean.clreplaced).getGeneric();
    if ((generic == null || generic.resolve().equals(Object.clreplaced)) && definition.hasAttribute(FACTORY_BEAN_OBJECT_TYPE)) {
        generic = getTypeFromAttribute(definition.getAttribute(FACTORY_BEAN_OBJECT_TYPE));
    }
    return generic;
}

19 Source : BeanTypeRegistry.java
with Apache License 2.0
from yuanmabiji

private Method[] getCandidateFactoryMethods(BeanDefinition definition, Clreplaced<?> factoryClreplaced) {
    return (shouldConsiderNonPublicMethods(definition) ? ReflectionUtils.getAllDeclaredMethods(factoryClreplaced) : factoryClreplaced.getMethods());
}

19 Source : WebServletHandler.java
with Apache License 2.0
from yuanmabiji

private String determineName(Map<String, Object> attributes, BeanDefinition beanDefinition) {
    return (String) (StringUtils.hasText((String) attributes.get("name")) ? attributes.get("name") : beanDefinition.getBeanClreplacedName());
}

19 Source : WebFilterHandler.java
with Apache License 2.0
from yuanmabiji

private String determineName(Map<String, Object> attributes, BeanDefinition beanDefinition) {
    return (String) (StringUtils.hasText((String) attributes.get("filterName")) ? attributes.get("filterName") : beanDefinition.getBeanClreplacedName());
}

19 Source : NoUniqueBeanDefinitionFailureAnalyzer.java
with Apache License 2.0
from yuanmabiji

private void buildMessage(StringBuilder message, String beanName) {
    try {
        BeanDefinition definition = this.beanFactory.getMergedBeanDefinition(beanName);
        message.append(getDefinitionDescription(beanName, definition));
    } catch (NoSuchBeanDefinitionException ex) {
        message.append(String.format("\t- %s: a programmatically registered singleton", beanName));
    }
}

19 Source : WebComponentRegister.java
with Apache License 2.0
from yfh0918

protected String determineName(Map<String, Object> attributes, BeanDefinition beanDefinition, String key) {
    return (String) (StringUtils.hasText((String) attributes.get(key)) ? attributes.get(key) : beanDefinition.getBeanClreplacedName());
}

19 Source : BeanRegistryUtils.java
with GNU Affero General Public License v3.0
from xiaoxu97

public static void registerBeanDefinition(BeanDefinitionRegistry registry, BeanDefinition beanDefinition, String beanName) {
    registry.registerBeanDefinition(beanName, beanDefinition);
}

19 Source : ScheduledAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus

@Test
public void severalFixedRatesWithRepeatedScheduledAnnotation() {
    BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.clreplaced);
    BeanDefinition targetDefinition = new RootBeanDefinition(SeveralFixedRatesWithRepeatedScheduledAnnotationTestBean.clreplaced);
    severalFixedRates(context, processorDefinition, targetDefinition);
}

19 Source : ScheduledAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus

@Test
public void severalFixedRatesOnBaseClreplaced() {
    BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.clreplaced);
    BeanDefinition targetDefinition = new RootBeanDefinition(FixedRatesSubBean.clreplaced);
    severalFixedRates(context, processorDefinition, targetDefinition);
}

19 Source : ScheduledAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus

@Test
public void severalFixedRatesWithSchedulesContainerAnnotation() {
    BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.clreplaced);
    BeanDefinition targetDefinition = new RootBeanDefinition(SeveralFixedRatesWithSchedulesContainerAnnotationTestBean.clreplaced);
    severalFixedRates(context, processorDefinition, targetDefinition);
}

19 Source : ScheduledAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus

@Test
public void severalFixedRatesOnDefaultMethod() {
    BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.clreplaced);
    BeanDefinition targetDefinition = new RootBeanDefinition(FixedRatesDefaultBean.clreplaced);
    severalFixedRates(context, processorDefinition, targetDefinition);
}

19 Source : ScheduledAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus

@Test
public void severalFixedRatesAgainstNestedCglibProxy() {
    BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.clreplaced);
    BeanDefinition targetDefinition = new RootBeanDefinition(SeveralFixedRatesWithRepeatedScheduledAnnotationTestBean.clreplaced);
    targetDefinition.setFactoryMethodName("nestedProxy");
    severalFixedRates(context, processorDefinition, targetDefinition);
}

19 Source : JeeNamespaceHandlerTests.java
with MIT License
from Vip-Augus

private void replacedertPropertyValue(BeanDefinition beanDefinition, String propertyName, Object expectedValue) {
    replacedertEquals("Property '" + propertyName + "' incorrect", expectedValue, beanDefinition.getPropertyValues().getPropertyValue(propertyName).getValue());
}

19 Source : LiveBeansView.java
with MIT License
from Vip-Augus

/**
 * Determine a resource description for the given bean definition and
 * apply basic JSON escaping (backslashes, double quotes) to it.
 * @param bd the bean definition to build the resource description for
 * @return the JSON-escaped resource description
 */
@Nullable
protected String getEscapedResourceDescription(BeanDefinition bd) {
    String resourceDescription = bd.getResourceDescription();
    if (resourceDescription == null) {
        return null;
    }
    StringBuilder result = new StringBuilder(resourceDescription.length() + 16);
    for (int i = 0; i < resourceDescription.length(); i++) {
        char character = resourceDescription.charAt(i);
        if (character == '\\') {
            result.append('/');
        } else if (character == '"') {
            result.append("\\").append('"');
        } else {
            result.append(character);
        }
    }
    return result.toString();
}

19 Source : LiveBeansView.java
with MIT License
from Vip-Augus

/**
 * Determine whether the specified bean is eligible for inclusion in the
 * LiveBeansView JSON snapshot.
 * @param beanName the name of the bean
 * @param bd the corresponding bean definition
 * @param bf the containing bean factory
 * @return {@code true} if the bean is to be included; {@code false} otherwise
 */
protected boolean isBeanEligible(String beanName, BeanDefinition bd, ConfigurableBeanFactory bf) {
    return (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE && (!bd.isLazyInit() || bf.containsSingleton(beanName)));
}

19 Source : ConfigurationClassUtils.java
with MIT License
from Vip-Augus

/**
 * Determine the order for the given configuration clreplaced bean definition,
 * as set by {@link #checkConfigurationClreplacedCandidate}.
 * @param beanDef the bean definition to check
 * @return the {@link Order @Order} annotation value on the configuration clreplaced,
 * or {@link Ordered#LOWEST_PRECEDENCE} if none declared
 * @since 4.2
 */
public static int getOrder(BeanDefinition beanDef) {
    Integer order = (Integer) beanDef.getAttribute(ORDER_ATTRIBUTE);
    return (order != null ? order : Ordered.LOWEST_PRECEDENCE);
}

19 Source : ConfigurationClassBeanDefinitionReader.java
with MIT License
from Vip-Augus

protected boolean isOverriddenByExistingDefinition(BeanMethod beanMethod, String beanName) {
    if (!this.registry.containsBeanDefinition(beanName)) {
        return false;
    }
    BeanDefinition existingBeanDef = this.registry.getBeanDefinition(beanName);
    // Is the existing bean definition one that was created from a configuration clreplaced?
    // -> allow the current bean method to override, since both are at second-preplaced level.
    // However, if the bean method is an overloaded case on the same configuration clreplaced,
    // preserve the existing bean definition.
    if (existingBeanDef instanceof ConfigurationClreplacedBeanDefinition) {
        ConfigurationClreplacedBeanDefinition ccbd = (ConfigurationClreplacedBeanDefinition) existingBeanDef;
        if (ccbd.getMetadata().getClreplacedName().equals(beanMethod.getConfigurationClreplaced().getMetadata().getClreplacedName())) {
            if (ccbd.getFactoryMethodMetadata().getMethodName().equals(ccbd.getFactoryMethodName())) {
                ccbd.setNonUniqueFactoryMethodName(ccbd.getFactoryMethodMetadata().getMethodName());
            }
            return true;
        } else {
            return false;
        }
    }
    // A bean definition resulting from a component scan can be silently overridden
    // by an @Bean method, as of 4.2...
    if (existingBeanDef instanceof ScannedGenericBeanDefinition) {
        return false;
    }
    // Has the existing bean definition bean marked as a framework-generated bean?
    // -> allow the current bean method to override it, since it is application-level
    if (existingBeanDef.getRole() > BeanDefinition.ROLE_APPLICATION) {
        return false;
    }
    // At this point, it's a top-level override (probably XML), just having been parsed
    // before configuration clreplaced processing kicks in...
    if (this.registry instanceof DefaultListableBeanFactory && !((DefaultListableBeanFactory) this.registry).isAllowBeanDefinitionOverriding()) {
        throw new BeanDefinitionStoreException(beanMethod.getConfigurationClreplaced().getResource().getDescription(), beanName, "@Bean definition illegally overridden by existing bean definition: " + existingBeanDef);
    }
    if (logger.isDebugEnabled()) {
        logger.debug(String.format("Skipping bean definition for %s: a definition for bean '%s' " + "already exists. This top-level bean definition is considered as an override.", beanMethod, beanName));
    }
    return true;
}

19 Source : ClassPathBeanDefinitionScanner.java
with MIT License
from Vip-Augus

/**
 * Determine whether the given new bean definition is compatible with
 * the given existing bean definition.
 * <p>The default implementation considers them as compatible when the existing
 * bean definition comes from the same source or from a non-scanning source.
 * @param newDefinition the new bean definition, originated from scanning
 * @param existingDefinition the existing bean definition, potentially an
 * explicitly defined one or a previously generated one from scanning
 * @return whether the definitions are considered as compatible, with the
 * new definition to be skipped in favor of the existing definition
 */
protected boolean isCompatible(BeanDefinition newDefinition, BeanDefinition existingDefinition) {
    return (// explicitly registered overriding bean
    !(existingDefinition instanceof ScannedGenericBeanDefinition) || // scanned same file twice
    (newDefinition.getSource() != null && newDefinition.getSource().equals(existingDefinition.getSource())) || // scanned equivalent clreplaced twice
    newDefinition.equals(existingDefinition));
}

19 Source : Spr5475Tests.java
with MIT License
from Vip-Augus

private void replacedertExceptionMessageForMisconfiguredFactoryMethod(BeanDefinition bd, String expectedMessage) {
    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("foo", bd);
    try {
        factory.preInstantiateSingletons();
        fail("should have failed with BeanCreationException due to incorrectly invoked factory method");
    } catch (BeanCreationException ex) {
        replacedertThat(ex.getMessage(), equalTo(expectedMessage));
    }
}

19 Source : XmlReaderContext.java
with MIT License
from Vip-Augus

/**
 * Call the bean name generator for the given bean definition
 * and register the bean definition under the generated name.
 * @see XmlBeanDefinitionReader#getBeanNameGenerator()
 * @see org.springframework.beans.factory.support.BeanNameGenerator#generateBeanName
 * @see BeanDefinitionRegistry#registerBeanDefinition
 */
public String registerWithGeneratedName(BeanDefinition beanDefinition) {
    String generatedName = generateBeanName(beanDefinition);
    getRegistry().registerBeanDefinition(generatedName, beanDefinition);
    return generatedName;
}

19 Source : XmlReaderContext.java
with MIT License
from Vip-Augus

// Convenience methods to delegate to
/**
 * Call the bean name generator for the given bean definition.
 * @see XmlBeanDefinitionReader#getBeanNameGenerator()
 * @see org.springframework.beans.factory.support.BeanNameGenerator#generateBeanName
 */
public String generateBeanName(BeanDefinition beanDefinition) {
    return this.reader.getBeanNameGenerator().generateBeanName(beanDefinition, getRegistry());
}

19 Source : ParserContext.java
with MIT License
from Vip-Augus

/**
 * Context that gets preplaceded along a bean definition parsing process,
 * encapsulating all relevant configuration as well as state.
 * Nested inside an {@link XmlReaderContext}.
 *
 * @author Rob Harrop
 * @author Juergen Hoeller
 * @since 2.0
 * @see XmlReaderContext
 * @see BeanDefinitionParserDelegate
 */
public final clreplaced ParserContext {

    private final XmlReaderContext readerContext;

    private final BeanDefinitionParserDelegate delegate;

    @Nullable
    private BeanDefinition containingBeanDefinition;

    private final Deque<CompositeComponentDefinition> containingComponents = new ArrayDeque<>();

    public ParserContext(XmlReaderContext readerContext, BeanDefinitionParserDelegate delegate) {
        this.readerContext = readerContext;
        this.delegate = delegate;
    }

    public ParserContext(XmlReaderContext readerContext, BeanDefinitionParserDelegate delegate, @Nullable BeanDefinition containingBeanDefinition) {
        this.readerContext = readerContext;
        this.delegate = delegate;
        this.containingBeanDefinition = containingBeanDefinition;
    }

    public final XmlReaderContext getReaderContext() {
        return this.readerContext;
    }

    public final BeanDefinitionRegistry getRegistry() {
        return this.readerContext.getRegistry();
    }

    public final BeanDefinitionParserDelegate getDelegate() {
        return this.delegate;
    }

    @Nullable
    public final BeanDefinition getContainingBeanDefinition() {
        return this.containingBeanDefinition;
    }

    public final boolean isNested() {
        return (this.containingBeanDefinition != null);
    }

    public boolean isDefaultLazyInit() {
        return BeanDefinitionParserDelegate.TRUE_VALUE.equals(this.delegate.getDefaults().getLazyInit());
    }

    @Nullable
    public Object extractSource(Object sourceCandidate) {
        return this.readerContext.extractSource(sourceCandidate);
    }

    @Nullable
    public CompositeComponentDefinition getContainingComponent() {
        return this.containingComponents.peek();
    }

    public void pushContainingComponent(CompositeComponentDefinition containingComponent) {
        this.containingComponents.push(containingComponent);
    }

    public CompositeComponentDefinition popContainingComponent() {
        return this.containingComponents.pop();
    }

    public void popAndRegisterContainingComponent() {
        registerComponent(popContainingComponent());
    }

    public void registerComponent(ComponentDefinition component) {
        CompositeComponentDefinition containingComponent = getContainingComponent();
        if (containingComponent != null) {
            containingComponent.addNestedComponent(component);
        } else {
            this.readerContext.fireComponentRegistered(component);
        }
    }

    public void registerBeanComponent(BeanComponentDefinition component) {
        BeanDefinitionReaderUtils.registerBeanDefinition(component, getRegistry());
        registerComponent(component);
    }
}

19 Source : BeanDefinitionValueResolver.java
with MIT License
from Vip-Augus

/**
 * Helper clreplaced for use in bean factory implementations,
 * resolving values contained in bean definition objects
 * into the actual values applied to the target bean instance.
 *
 * <p>Operates on an {@link AbstractBeanFactory} and a plain
 * {@link org.springframework.beans.factory.config.BeanDefinition} object.
 * Used by {@link AbstractAutowireCapableBeanFactory}.
 *
 * @author Juergen Hoeller
 * @since 1.2
 * @see AbstractAutowireCapableBeanFactory
 */
clreplaced BeanDefinitionValueResolver {

    private final AbstractBeanFactory beanFactory;

    private final String beanName;

    private final BeanDefinition beanDefinition;

    private final TypeConverter typeConverter;

    /**
     * Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition.
     * @param beanFactory the BeanFactory to resolve against
     * @param beanName the name of the bean that we work on
     * @param beanDefinition the BeanDefinition of the bean that we work on
     * @param typeConverter the TypeConverter to use for resolving TypedStringValues
     */
    public BeanDefinitionValueResolver(AbstractBeanFactory beanFactory, String beanName, BeanDefinition beanDefinition, TypeConverter typeConverter) {
        this.beanFactory = beanFactory;
        this.beanName = beanName;
        this.beanDefinition = beanDefinition;
        this.typeConverter = typeConverter;
    }

    /**
     * Given a PropertyValue, return a value, resolving any references to other
     * beans in the factory if necessary. The value could be:
     * <li>A BeanDefinition, which leads to the creation of a corresponding
     * new bean instance. Singleton flags and names of such "inner beans"
     * are always ignored: Inner beans are anonymous prototypes.
     * <li>A RuntimeBeanReference, which must be resolved.
     * <li>A ManagedList. This is a special collection that may contain
     * RuntimeBeanReferences or Collections that will need to be resolved.
     * <li>A ManagedSet. May also contain RuntimeBeanReferences or
     * Collections that will need to be resolved.
     * <li>A ManagedMap. In this case the value may be a RuntimeBeanReference
     * or Collection that will need to be resolved.
     * <li>An ordinary object or {@code null}, in which case it's left alone.
     * @param argName the name of the argument that the value is defined for
     * @param value the value object to resolve
     * @return the resolved object
     */
    @Nullable
    public Object resolveValueIfNecessary(Object argName, @Nullable Object value) {
        // We must check each value to see whether it requires a runtime reference
        // to another bean to be resolved.
        // 我们必须检查每个值,看看它是否需要一个运行时引用,然后来解析另一个 bean
        if (value instanceof RuntimeBeanReference) {
            // 注释 5.6 在这一步中,如果判断是引用类型,需要解析引用,加载另一个 bean
            RuntimeBeanReference ref = (RuntimeBeanReference) value;
            return resolveReference(argName, ref);
        } else if (value instanceof RuntimeBeanNameReference) {
            String refName = ((RuntimeBeanNameReference) value).getBeanName();
            refName = String.valueOf(doEvaluate(refName));
            if (!this.beanFactory.containsBean(refName)) {
                throw new BeanDefinitionStoreException("Invalid bean name '" + refName + "' in bean reference for " + argName);
            }
            return refName;
        } else if (value instanceof BeanDefinitionHolder) {
            // Resolve BeanDefinitionHolder: contains BeanDefinition with name and aliases.
            BeanDefinitionHolder bdHolder = (BeanDefinitionHolder) value;
            return resolveInnerBean(argName, bdHolder.getBeanName(), bdHolder.getBeanDefinition());
        } else if (value instanceof BeanDefinition) {
            // Resolve plain BeanDefinition, without contained name: use dummy name.
            BeanDefinition bd = (BeanDefinition) value;
            String innerBeanName = "(inner bean)" + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdenreplacedyHexString(bd);
            return resolveInnerBean(argName, innerBeanName, bd);
        } else if (value instanceof ManagedArray) {
            // May need to resolve contained runtime references.
            ManagedArray array = (ManagedArray) value;
            Clreplaced<?> elementType = array.resolvedElementType;
            if (elementType == null) {
                String elementTypeName = array.getElementTypeName();
                if (StringUtils.hasText(elementTypeName)) {
                    try {
                        elementType = ClreplacedUtils.forName(elementTypeName, this.beanFactory.getBeanClreplacedLoader());
                        array.resolvedElementType = elementType;
                    } catch (Throwable ex) {
                        // Improve the message by showing the context.
                        throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Error resolving array type for " + argName, ex);
                    }
                } else {
                    elementType = Object.clreplaced;
                }
            }
            return resolveManagedArray(argName, (List<?>) value, elementType);
        } else if (value instanceof ManagedList) {
            // May need to resolve contained runtime references.
            return resolveManagedList(argName, (List<?>) value);
        } else if (value instanceof ManagedSet) {
            // May need to resolve contained runtime references.
            return resolveManagedSet(argName, (Set<?>) value);
        } else if (value instanceof ManagedMap) {
            // May need to resolve contained runtime references.
            return resolveManagedMap(argName, (Map<?, ?>) value);
        } else if (value instanceof ManagedProperties) {
            Properties original = (Properties) value;
            Properties copy = new Properties();
            original.forEach((propKey, propValue) -> {
                if (propKey instanceof TypedStringValue) {
                    propKey = evaluate((TypedStringValue) propKey);
                }
                if (propValue instanceof TypedStringValue) {
                    propValue = evaluate((TypedStringValue) propValue);
                }
                if (propKey == null || propValue == null) {
                    throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Error converting Properties key/value pair for " + argName + ": resolved to null");
                }
                copy.put(propKey, propValue);
            });
            return copy;
        } else if (value instanceof TypedStringValue) {
            // Convert value to target type here.
            TypedStringValue typedStringValue = (TypedStringValue) value;
            Object valueObject = evaluate(typedStringValue);
            try {
                Clreplaced<?> resolvedTargetType = resolveTargetType(typedStringValue);
                if (resolvedTargetType != null) {
                    return this.typeConverter.convertIfNecessary(valueObject, resolvedTargetType);
                } else {
                    return valueObject;
                }
            } catch (Throwable ex) {
                // Improve the message by showing the context.
                throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Error converting typed String value for " + argName, ex);
            }
        } else if (value instanceof NullBean) {
            return null;
        } else {
            return evaluate(value);
        }
    }

    /**
     * Evaluate the given value as an expression, if necessary.
     * @param value the candidate value (may be an expression)
     * @return the resolved value
     */
    @Nullable
    protected Object evaluate(TypedStringValue value) {
        Object result = doEvaluate(value.getValue());
        if (!ObjectUtils.nullSafeEquals(result, value.getValue())) {
            value.setDynamic();
        }
        return result;
    }

    /**
     * Evaluate the given value as an expression, if necessary.
     * @param value the original value (may be an expression)
     * @return the resolved value if necessary, or the original value
     */
    @Nullable
    protected Object evaluate(@Nullable Object value) {
        if (value instanceof String) {
            return doEvaluate((String) value);
        } else if (value instanceof String[]) {
            String[] values = (String[]) value;
            boolean actuallyResolved = false;
            Object[] resolvedValues = new Object[values.length];
            for (int i = 0; i < values.length; i++) {
                String originalValue = values[i];
                Object resolvedValue = doEvaluate(originalValue);
                if (resolvedValue != originalValue) {
                    actuallyResolved = true;
                }
                resolvedValues[i] = resolvedValue;
            }
            return (actuallyResolved ? resolvedValues : values);
        } else {
            return value;
        }
    }

    /**
     * Evaluate the given String value as an expression, if necessary.
     * @param value the original value (may be an expression)
     * @return the resolved value if necessary, or the original String value
     */
    @Nullable
    private Object doEvaluate(@Nullable String value) {
        return this.beanFactory.evaluateBeanDefinitionString(value, this.beanDefinition);
    }

    /**
     * Resolve the target type in the given TypedStringValue.
     * @param value the TypedStringValue to resolve
     * @return the resolved target type (or {@code null} if none specified)
     * @throws ClreplacedNotFoundException if the specified type cannot be resolved
     * @see TypedStringValue#resolveTargetType
     */
    @Nullable
    protected Clreplaced<?> resolveTargetType(TypedStringValue value) throws ClreplacedNotFoundException {
        if (value.hasTargetType()) {
            return value.getTargetType();
        }
        return value.resolveTargetType(this.beanFactory.getBeanClreplacedLoader());
    }

    /**
     * Resolve an inner bean definition.
     * @param argName the name of the argument that the inner bean is defined for
     * @param innerBeanName the name of the inner bean
     * @param innerBd the bean definition for the inner bean
     * @return the resolved inner bean instance
     */
    @Nullable
    private Object resolveInnerBean(Object argName, String innerBeanName, BeanDefinition innerBd) {
        RootBeanDefinition mbd = null;
        try {
            mbd = this.beanFactory.getMergedBeanDefinition(innerBeanName, innerBd, this.beanDefinition);
            // Check given bean name whether it is unique. If not already unique,
            // add counter - increasing the counter until the name is unique.
            String actualInnerBeanName = innerBeanName;
            if (mbd.isSingleton()) {
                actualInnerBeanName = adaptInnerBeanName(innerBeanName);
            }
            this.beanFactory.registerContainedBean(actualInnerBeanName, this.beanName);
            // Guarantee initialization of beans that the inner bean depends on.
            String[] dependsOn = mbd.getDependsOn();
            if (dependsOn != null) {
                for (String dependsOnBean : dependsOn) {
                    this.beanFactory.registerDependentBean(dependsOnBean, actualInnerBeanName);
                    this.beanFactory.getBean(dependsOnBean);
                }
            }
            // Actually create the inner bean instance now...
            Object innerBean = this.beanFactory.createBean(actualInnerBeanName, mbd, null);
            if (innerBean instanceof FactoryBean) {
                boolean synthetic = mbd.isSynthetic();
                innerBean = this.beanFactory.getObjectFromFactoryBean((FactoryBean<?>) innerBean, actualInnerBeanName, !synthetic);
            }
            if (innerBean instanceof NullBean) {
                innerBean = null;
            }
            return innerBean;
        } catch (BeansException ex) {
            throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Cannot create inner bean '" + innerBeanName + "' " + (mbd != null && mbd.getBeanClreplacedName() != null ? "of type [" + mbd.getBeanClreplacedName() + "] " : "") + "while setting " + argName, ex);
        }
    }

    /**
     * Checks the given bean name whether it is unique. If not already unique,
     * a counter is added, increasing the counter until the name is unique.
     * @param innerBeanName the original name for the inner bean
     * @return the adapted name for the inner bean
     */
    private String adaptInnerBeanName(String innerBeanName) {
        String actualInnerBeanName = innerBeanName;
        int counter = 0;
        while (this.beanFactory.isBeanNameInUse(actualInnerBeanName)) {
            counter++;
            actualInnerBeanName = innerBeanName + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + counter;
        }
        return actualInnerBeanName;
    }

    /**
     * Resolve a reference to another bean in the factory.
     */
    @Nullable
    private Object resolveReference(Object argName, RuntimeBeanReference ref) {
        try {
            Object bean;
            String refName = ref.getBeanName();
            refName = String.valueOf(doEvaluate(refName));
            if (ref.isToParent()) {
                if (this.beanFactory.getParentBeanFactory() == null) {
                    throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Can't resolve reference to bean '" + refName + "' in parent factory: no parent factory available");
                }
                bean = this.beanFactory.getParentBeanFactory().getBean(refName);
            } else {
                // 注释 5.7 在这里加载引用的 bean
                bean = this.beanFactory.getBean(refName);
                this.beanFactory.registerDependentBean(refName, this.beanName);
            }
            if (bean instanceof NullBean) {
                bean = null;
            }
            return bean;
        } catch (BeansException ex) {
            throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Cannot resolve reference to bean '" + ref.getBeanName() + "' while setting " + argName, ex);
        }
    }

    /**
     * For each element in the managed array, resolve reference if necessary.
     */
    private Object resolveManagedArray(Object argName, List<?> ml, Clreplaced<?> elementType) {
        Object resolved = Array.newInstance(elementType, ml.size());
        for (int i = 0; i < ml.size(); i++) {
            Array.set(resolved, i, resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
        }
        return resolved;
    }

    /**
     * For each element in the managed list, resolve reference if necessary.
     */
    private List<?> resolveManagedList(Object argName, List<?> ml) {
        List<Object> resolved = new ArrayList<>(ml.size());
        for (int i = 0; i < ml.size(); i++) {
            resolved.add(resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
        }
        return resolved;
    }

    /**
     * For each element in the managed set, resolve reference if necessary.
     */
    private Set<?> resolveManagedSet(Object argName, Set<?> ms) {
        Set<Object> resolved = new LinkedHashSet<>(ms.size());
        int i = 0;
        for (Object m : ms) {
            resolved.add(resolveValueIfNecessary(new KeyedArgName(argName, i), m));
            i++;
        }
        return resolved;
    }

    /**
     * For each element in the managed map, resolve reference if necessary.
     */
    private Map<?, ?> resolveManagedMap(Object argName, Map<?, ?> mm) {
        Map<Object, Object> resolved = new LinkedHashMap<>(mm.size());
        mm.forEach((key, value) -> {
            Object resolvedKey = resolveValueIfNecessary(argName, key);
            Object resolvedValue = resolveValueIfNecessary(new KeyedArgName(argName, key), value);
            resolved.put(resolvedKey, resolvedValue);
        });
        return resolved;
    }

    /**
     * Holder clreplaced used for delayed toString building.
     */
    private static clreplaced KeyedArgName {

        private final Object argName;

        private final Object key;

        public KeyedArgName(Object argName, Object key) {
            this.argName = argName;
            this.key = key;
        }

        @Override
        public String toString() {
            return this.argName + " with key " + BeanWrapper.PROPERTY_KEY_PREFIX + this.key + BeanWrapper.PROPERTY_KEY_SUFFIX;
        }
    }
}

19 Source : BeanDefinitionValueResolver.java
with MIT License
from Vip-Augus

/**
 * Resolve an inner bean definition.
 * @param argName the name of the argument that the inner bean is defined for
 * @param innerBeanName the name of the inner bean
 * @param innerBd the bean definition for the inner bean
 * @return the resolved inner bean instance
 */
@Nullable
private Object resolveInnerBean(Object argName, String innerBeanName, BeanDefinition innerBd) {
    RootBeanDefinition mbd = null;
    try {
        mbd = this.beanFactory.getMergedBeanDefinition(innerBeanName, innerBd, this.beanDefinition);
        // Check given bean name whether it is unique. If not already unique,
        // add counter - increasing the counter until the name is unique.
        String actualInnerBeanName = innerBeanName;
        if (mbd.isSingleton()) {
            actualInnerBeanName = adaptInnerBeanName(innerBeanName);
        }
        this.beanFactory.registerContainedBean(actualInnerBeanName, this.beanName);
        // Guarantee initialization of beans that the inner bean depends on.
        String[] dependsOn = mbd.getDependsOn();
        if (dependsOn != null) {
            for (String dependsOnBean : dependsOn) {
                this.beanFactory.registerDependentBean(dependsOnBean, actualInnerBeanName);
                this.beanFactory.getBean(dependsOnBean);
            }
        }
        // Actually create the inner bean instance now...
        Object innerBean = this.beanFactory.createBean(actualInnerBeanName, mbd, null);
        if (innerBean instanceof FactoryBean) {
            boolean synthetic = mbd.isSynthetic();
            innerBean = this.beanFactory.getObjectFromFactoryBean((FactoryBean<?>) innerBean, actualInnerBeanName, !synthetic);
        }
        if (innerBean instanceof NullBean) {
            innerBean = null;
        }
        return innerBean;
    } catch (BeansException ex) {
        throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Cannot create inner bean '" + innerBeanName + "' " + (mbd != null && mbd.getBeanClreplacedName() != null ? "of type [" + mbd.getBeanClreplacedName() + "] " : "") + "while setting " + argName, ex);
    }
}

19 Source : BeanDefinitionResource.java
with MIT License
from Vip-Augus

/**
 * Descriptive {@link org.springframework.core.io.Resource} wrapper for
 * a {@link org.springframework.beans.factory.config.BeanDefinition}.
 *
 * @author Juergen Hoeller
 * @since 2.5.2
 * @see org.springframework.core.io.DescriptiveResource
 */
clreplaced BeanDefinitionResource extends AbstractResource {

    private final BeanDefinition beanDefinition;

    /**
     * Create a new BeanDefinitionResource.
     * @param beanDefinition the BeanDefinition object to wrap
     */
    public BeanDefinitionResource(BeanDefinition beanDefinition) {
        replacedert.notNull(beanDefinition, "BeanDefinition must not be null");
        this.beanDefinition = beanDefinition;
    }

    /**
     * Return the wrapped BeanDefinition object.
     */
    public final BeanDefinition getBeanDefinition() {
        return this.beanDefinition;
    }

    @Override
    public boolean exists() {
        return false;
    }

    @Override
    public boolean isReadable() {
        return false;
    }

    @Override
    public InputStream getInputStream() throws IOException {
        throw new FileNotFoundException("Resource cannot be opened because it points to " + getDescription());
    }

    @Override
    public String getDescription() {
        return "BeanDefinition defined in " + this.beanDefinition.getResourceDescription();
    }

    /**
     * This implementation compares the underlying BeanDefinition.
     */
    @Override
    public boolean equals(Object other) {
        return (this == other || (other instanceof BeanDefinitionResource && ((BeanDefinitionResource) other).beanDefinition.equals(this.beanDefinition)));
    }

    /**
     * This implementation returns the hash code of the underlying BeanDefinition.
     */
    @Override
    public int hashCode() {
        return this.beanDefinition.hashCode();
    }
}

19 Source : BeanDefinitionReaderUtils.java
with MIT License
from Vip-Augus

/**
 * Generate a bean name for the given bean definition, unique within the
 * given bean factory.
 * @param definition the bean definition to generate a bean name for
 * @param registry the bean factory that the definition is going to be
 * registered with (to check for existing bean names)
 * @param isInnerBean whether the given bean definition will be registered
 * as inner bean or as top-level bean (allowing for special name generation
 * for inner beans versus top-level beans)
 * @return the generated bean name
 * @throws BeanDefinitionStoreException if no unique name can be generated
 * for the given bean definition
 */
public static String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry, boolean isInnerBean) throws BeanDefinitionStoreException {
    String generatedBeanName = definition.getBeanClreplacedName();
    if (generatedBeanName == null) {
        if (definition.getParentName() != null) {
            generatedBeanName = definition.getParentName() + "$child";
        } else if (definition.getFactoryBeanName() != null) {
            generatedBeanName = definition.getFactoryBeanName() + "$created";
        }
    }
    if (!StringUtils.hasText(generatedBeanName)) {
        throw new BeanDefinitionStoreException("Unnamed bean definition specifies neither " + "'clreplaced' nor 'parent' nor 'factory-bean' - can't generate bean name");
    }
    String id = generatedBeanName;
    if (isInnerBean) {
        // Inner bean: generate idenreplacedy hashcode suffix.
        id = generatedBeanName + GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdenreplacedyHexString(definition);
    } else {
        // Top-level bean: use plain clreplaced name with unique suffix if necessary.
        return uniqueBeanName(generatedBeanName, registry);
    }
    return id;
}

19 Source : BeanDefinitionReaderUtils.java
with MIT License
from Vip-Augus

/**
 * Generate a bean name for the given top-level bean definition,
 * unique within the given bean factory.
 * @param beanDefinition the bean definition to generate a bean name for
 * @param registry the bean factory that the definition is going to be
 * registered with (to check for existing bean names)
 * @return the generated bean name
 * @throws BeanDefinitionStoreException if no unique name can be generated
 * for the given bean definition
 * @see #generateBeanName(BeanDefinition, BeanDefinitionRegistry, boolean)
 */
public static String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry registry) throws BeanDefinitionStoreException {
    return generateBeanName(beanDefinition, registry, false);
}

19 Source : BeanDefinitionOverrideException.java
with MIT License
from Vip-Augus

/**
 * Subclreplaced of {@link BeanDefinitionStoreException} indicating an invalid override
 * attempt: typically registering a new definition for the same bean name while
 * {@link DefaultListableBeanFactory#isAllowBeanDefinitionOverriding()} is {@code false}.
 *
 * @author Juergen Hoeller
 * @since 5.1
 * @see DefaultListableBeanFactory#setAllowBeanDefinitionOverriding
 * @see DefaultListableBeanFactory#registerBeanDefinition
 */
public clreplaced BeanDefinitionOverrideException extends BeanDefinitionStoreException {

    private final BeanDefinition beanDefinition;

    private final BeanDefinition existingDefinition;

    /**
     * Create a new BeanDefinitionOverrideException for the given new and existing definition.
     * @param beanName the name of the bean
     * @param beanDefinition the newly registered bean definition
     * @param existingDefinition the existing bean definition for the same name
     */
    public BeanDefinitionOverrideException(String beanName, BeanDefinition beanDefinition, BeanDefinition existingDefinition) {
        super(beanDefinition.getResourceDescription(), beanName, "Cannot register bean definition [" + beanDefinition + "] for bean '" + beanName + "': There is already [" + existingDefinition + "] bound.");
        this.beanDefinition = beanDefinition;
        this.existingDefinition = existingDefinition;
    }

    /**
     * Return the description of the resource that the bean definition came from.
     */
    @Override
    @NonNull
    public String getResourceDescription() {
        return String.valueOf(super.getResourceDescription());
    }

    /**
     * Return the name of the bean.
     */
    @Override
    @NonNull
    public String getBeanName() {
        return String.valueOf(super.getBeanName());
    }

    /**
     * Return the newly registered bean definition.
     * @see #getBeanName()
     */
    public BeanDefinition getBeanDefinition() {
        return this.beanDefinition;
    }

    /**
     * Return the existing bean definition for the same name.
     * @see #getBeanName()
     */
    public BeanDefinition getExistingDefinition() {
        return this.existingDefinition;
    }
}

19 Source : AbstractBeanDefinition.java
with MIT License
from Vip-Augus

/**
 * Set the originating (e.g. decorated) BeanDefinition, if any.
 */
public void setOriginatingBeanDefinition(BeanDefinition originatingBd) {
    this.resource = new BeanDefinitionResource(originatingBd);
}

19 Source : PointcutComponentDefinition.java
with MIT License
from Vip-Augus

/**
 * {@link org.springframework.beans.factory.parsing.ComponentDefinition}
 * implementation that holds a pointcut definition.
 *
 * @author Rob Harrop
 * @since 2.0
 */
public clreplaced PointcutComponentDefinition extends AbstractComponentDefinition {

    private final String pointcutBeanName;

    private final BeanDefinition pointcutDefinition;

    private final String description;

    public PointcutComponentDefinition(String pointcutBeanName, BeanDefinition pointcutDefinition, String expression) {
        replacedert.notNull(pointcutBeanName, "Bean name must not be null");
        replacedert.notNull(pointcutDefinition, "Pointcut definition must not be null");
        replacedert.notNull(expression, "Expression must not be null");
        this.pointcutBeanName = pointcutBeanName;
        this.pointcutDefinition = pointcutDefinition;
        this.description = "Pointcut <name='" + pointcutBeanName + "', expression=[" + expression + "]>";
    }

    @Override
    public String getName() {
        return this.pointcutBeanName;
    }

    @Override
    public String getDescription() {
        return this.description;
    }

    @Override
    public BeanDefinition[] getBeanDefinitions() {
        return new BeanDefinition[] { this.pointcutDefinition };
    }

    @Override
    @Nullable
    public Object getSource() {
        return this.pointcutDefinition.getSource();
    }
}

19 Source : AbstractInterceptorDrivenBeanDefinitionDecorator.java
with MIT License
from Vip-Augus

private boolean isProxyFactoryBeanDefinition(BeanDefinition existingDefinition) {
    return ProxyFactoryBean.clreplaced.getName().equals(existingDefinition.getBeanClreplacedName());
}

19 Source : AbstractInterceptorDrivenBeanDefinitionDecorator.java
with MIT License
from Vip-Augus

protected String getInterceptorNameSuffix(BeanDefinition interceptorDefinition) {
    String beanClreplacedName = interceptorDefinition.getBeanClreplacedName();
    return (StringUtils.hasLength(beanClreplacedName) ? StringUtils.uncapitalize(ClreplacedUtils.getShortName(beanClreplacedName)) : "");
}

19 Source : ApiServiceScanner.java
with Apache License 2.0
from SpringStudent

protected boolean isCompatible(BeanDefinition newDefinition, BeanDefinition existingDefinition) {
    return !(existingDefinition instanceof ScannedGenericBeanDefinition) || newDefinition.getSource().equals(existingDefinition.getSource()) || newDefinition.equals(existingDefinition);
}

19 Source : RegionTemplateAutoConfiguration.java
with Apache License 2.0
from spring-projects

private boolean isBeanWithGemfireTemplateDependency(@NonNull BeanFactory beanFactory, @NonNull BeanDefinition beanDefinition) {
    Predicate<Object> isGemfireTemplate = value -> value instanceof RuntimeBeanReference ? beanFactory.isTypeMatch(((RuntimeBeanReference) value).getBeanName(), GemfireOperations.clreplaced) : value instanceof GemfireOperations;
    boolean match = beanDefinition.getConstructorArgumentValues().getGenericArgumentValues().stream().map(ConstructorArgumentValues.ValueHolder::getValue).anyMatch(isGemfireTemplate);
    match |= match || beanDefinition.getPropertyValues().getPropertyValueList().stream().map(PropertyValue::getValue).anyMatch(isGemfireTemplate);
    match |= match || Optional.of(beanDefinition).filter(AnnotatedBeanDefinition.clreplaced::isInstance).map(AnnotatedBeanDefinition.clreplaced::cast).map(AnnotatedBeanDefinition::getFactoryMethodMetadata).filter(StandardMethodMetadata.clreplaced::isInstance).map(StandardMethodMetadata.clreplaced::cast).map(StandardMethodMetadata::getIntrospectedMethod).map(method -> Arrays.stream(ArrayUtils.nullSafeArray(method.getParameterTypes(), Clreplaced.clreplaced)).filter(Objects::nonNull).anyMatch(GemfireOperations.clreplaced::isreplacedignableFrom)).orElse(false);
    return match;
}

19 Source : JeeNamespaceHandlerTests.java
with Apache License 2.0
from SourceHot

private void replacedertPropertyValue(BeanDefinition beanDefinition, String propertyName, Object expectedValue) {
    replacedertThat(beanDefinition.getPropertyValues().getPropertyValue(propertyName).getValue()).as("Property '" + propertyName + "' incorrect").isEqualTo(expectedValue);
}

19 Source : ClassPathBeanDefinitionScanner.java
with Apache License 2.0
from SourceHot

/**
 * Determine whether the given new bean definition is compatible with
 * the given existing bean definition.
 * <p>The default implementation considers them as compatible when the existing
 * bean definition comes from the same source or from a non-scanning source.
 * @param newDefinition the new bean definition, originated from scanning
 * @param existingDefinition the existing bean definition, potentially an
 * explicitly defined one or a previously generated one from scanning
 * @return whether the definitions are considered as compatible, with the
 * new definition to be skipped in favor of the existing definition
 */
protected boolean isCompatible(BeanDefinition newDefinition, BeanDefinition existingDefinition) {
    // 1. 是否是 ScannedGenericBeanDefinition 类型
    // 2. source 是否相同
    // 3. 参数是否相同
    return (// explicitly registered overriding bean
    !(existingDefinition instanceof ScannedGenericBeanDefinition) || // scanned same file twice
    (newDefinition.getSource() != null && newDefinition.getSource().equals(existingDefinition.getSource())) || // scanned equivalent clreplaced twice
    newDefinition.equals(existingDefinition));
}

19 Source : Spr5475Tests.java
with Apache License 2.0
from SourceHot

private void replacedertExceptionMessageForMisconfiguredFactoryMethod(BeanDefinition bd, String expectedMessage) {
    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("foo", bd);
    replacedertThatExceptionOfType(BeanCreationException.clreplaced).isThrownBy(factory::preInstantiateSingletons).withMessageContaining(expectedMessage);
}

19 Source : ParserContext.java
with Apache License 2.0
from SourceHot

/**
 * Context that gets preplaceded along a bean definition parsing process,
 * encapsulating all relevant configuration as well as state.
 * Nested inside an {@link XmlReaderContext}.
 *
 * @author Rob Harrop
 * @author Juergen Hoeller
 * @since 2.0
 * @see XmlReaderContext
 * @see BeanDefinitionParserDelegate
 */
public final clreplaced ParserContext {

    private final XmlReaderContext readerContext;

    private final BeanDefinitionParserDelegate delegate;

    private final Deque<CompositeComponentDefinition> containingComponents = new ArrayDeque<>();

    @Nullable
    private BeanDefinition containingBeanDefinition;

    public ParserContext(XmlReaderContext readerContext, BeanDefinitionParserDelegate delegate) {
        this.readerContext = readerContext;
        this.delegate = delegate;
    }

    public ParserContext(XmlReaderContext readerContext, BeanDefinitionParserDelegate delegate, @Nullable BeanDefinition containingBeanDefinition) {
        this.readerContext = readerContext;
        this.delegate = delegate;
        this.containingBeanDefinition = containingBeanDefinition;
    }

    public final XmlReaderContext getReaderContext() {
        return this.readerContext;
    }

    public final BeanDefinitionRegistry getRegistry() {
        return this.readerContext.getRegistry();
    }

    public final BeanDefinitionParserDelegate getDelegate() {
        return this.delegate;
    }

    @Nullable
    public final BeanDefinition getContainingBeanDefinition() {
        return this.containingBeanDefinition;
    }

    public final boolean isNested() {
        return (this.containingBeanDefinition != null);
    }

    public boolean isDefaultLazyInit() {
        return BeanDefinitionParserDelegate.TRUE_VALUE.equals(this.delegate.getDefaults().getLazyInit());
    }

    @Nullable
    public Object extractSource(Object sourceCandidate) {
        return this.readerContext.extractSource(sourceCandidate);
    }

    @Nullable
    public CompositeComponentDefinition getContainingComponent() {
        return this.containingComponents.peek();
    }

    public void pushContainingComponent(CompositeComponentDefinition containingComponent) {
        this.containingComponents.push(containingComponent);
    }

    public CompositeComponentDefinition popContainingComponent() {
        return this.containingComponents.pop();
    }

    public void popAndRegisterContainingComponent() {
        registerComponent(popContainingComponent());
    }

    public void registerComponent(ComponentDefinition component) {
        CompositeComponentDefinition containingComponent = getContainingComponent();
        if (containingComponent != null) {
            containingComponent.addNestedComponent(component);
        } else {
            this.readerContext.fireComponentRegistered(component);
        }
    }

    public void registerBeanComponent(BeanComponentDefinition component) {
        BeanDefinitionReaderUtils.registerBeanDefinition(component, getRegistry());
        registerComponent(component);
    }
}

19 Source : BeanDefinitionValueResolver.java
with Apache License 2.0
from SourceHot

/**
 * Helper clreplaced for use in bean factory implementations,
 * resolving values contained in bean definition objects
 * into the actual values applied to the target bean instance.
 *
 * <p>Operates on an {@link AbstractBeanFactory} and a plain
 * {@link org.springframework.beans.factory.config.BeanDefinition} object.
 * Used by {@link AbstractAutowireCapableBeanFactory}.
 *
 * @author Juergen Hoeller
 * @since 1.2
 * @see AbstractAutowireCapableBeanFactory
 */
clreplaced BeanDefinitionValueResolver {

    private final AbstractAutowireCapableBeanFactory beanFactory;

    private final String beanName;

    private final BeanDefinition beanDefinition;

    private final TypeConverter typeConverter;

    /**
     * Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition.
     * @param beanFactory the BeanFactory to resolve against
     * @param beanName the name of the bean that we work on
     * @param beanDefinition the BeanDefinition of the bean that we work on
     * @param typeConverter the TypeConverter to use for resolving TypedStringValues
     */
    public BeanDefinitionValueResolver(AbstractAutowireCapableBeanFactory beanFactory, String beanName, BeanDefinition beanDefinition, TypeConverter typeConverter) {
        this.beanFactory = beanFactory;
        this.beanName = beanName;
        this.beanDefinition = beanDefinition;
        this.typeConverter = typeConverter;
    }

    /**
     * Given a PropertyValue, return a value, resolving any references to other
     * beans in the factory if necessary. The value could be:
     * <li>A BeanDefinition, which leads to the creation of a corresponding
     * new bean instance. Singleton flags and names of such "inner beans"
     * are always ignored: Inner beans are anonymous prototypes.
     * <li>A RuntimeBeanReference, which must be resolved.
     * <li>A ManagedList. This is a special collection that may contain
     * RuntimeBeanReferences or Collections that will need to be resolved.
     * <li>A ManagedSet. May also contain RuntimeBeanReferences or
     * Collections that will need to be resolved.
     * <li>A ManagedMap. In this case the value may be a RuntimeBeanReference
     * or Collection that will need to be resolved.
     * <li>An ordinary object or {@code null}, in which case it's left alone.
     * @param argName the name of the argument that the value is defined for
     * @param value the value object to resolve
     * @return the resolved object
     */
    @Nullable
    public Object resolveValueIfNecessary(Object argName, @Nullable Object value) {
        // We must check each value to see whether it requires a runtime reference
        // to another bean to be resolved.
        if (value instanceof RuntimeBeanReference) {
            RuntimeBeanReference ref = (RuntimeBeanReference) value;
            return resolveReference(argName, ref);
        } else if (value instanceof RuntimeBeanNameReference) {
            String refName = ((RuntimeBeanNameReference) value).getBeanName();
            refName = String.valueOf(doEvaluate(refName));
            if (!this.beanFactory.containsBean(refName)) {
                throw new BeanDefinitionStoreException("Invalid bean name '" + refName + "' in bean reference for " + argName);
            }
            return refName;
        } else if (value instanceof BeanDefinitionHolder) {
            // Resolve BeanDefinitionHolder: contains BeanDefinition with name and aliases.
            BeanDefinitionHolder bdHolder = (BeanDefinitionHolder) value;
            return resolveInnerBean(argName, bdHolder.getBeanName(), bdHolder.getBeanDefinition());
        } else if (value instanceof BeanDefinition) {
            // Resolve plain BeanDefinition, without contained name: use dummy name.
            BeanDefinition bd = (BeanDefinition) value;
            String innerBeanName = "(inner bean)" + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdenreplacedyHexString(bd);
            return resolveInnerBean(argName, innerBeanName, bd);
        } else if (value instanceof DependencyDescriptor) {
            Set<String> autowiredBeanNames = new LinkedHashSet<>(4);
            Object result = this.beanFactory.resolveDependency((DependencyDescriptor) value, this.beanName, autowiredBeanNames, this.typeConverter);
            for (String autowiredBeanName : autowiredBeanNames) {
                if (this.beanFactory.containsBean(autowiredBeanName)) {
                    this.beanFactory.registerDependentBean(autowiredBeanName, this.beanName);
                }
            }
            return result;
        } else if (value instanceof ManagedArray) {
            // May need to resolve contained runtime references.
            ManagedArray array = (ManagedArray) value;
            Clreplaced<?> elementType = array.resolvedElementType;
            if (elementType == null) {
                String elementTypeName = array.getElementTypeName();
                if (StringUtils.hasText(elementTypeName)) {
                    try {
                        elementType = ClreplacedUtils.forName(elementTypeName, this.beanFactory.getBeanClreplacedLoader());
                        array.resolvedElementType = elementType;
                    } catch (Throwable ex) {
                        // Improve the message by showing the context.
                        throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Error resolving array type for " + argName, ex);
                    }
                } else {
                    elementType = Object.clreplaced;
                }
            }
            return resolveManagedArray(argName, (List<?>) value, elementType);
        } else if (value instanceof ManagedList) {
            // May need to resolve contained runtime references.
            return resolveManagedList(argName, (List<?>) value);
        } else if (value instanceof ManagedSet) {
            // May need to resolve contained runtime references.
            return resolveManagedSet(argName, (Set<?>) value);
        } else if (value instanceof ManagedMap) {
            // May need to resolve contained runtime references.
            return resolveManagedMap(argName, (Map<?, ?>) value);
        } else if (value instanceof ManagedProperties) {
            Properties original = (Properties) value;
            Properties copy = new Properties();
            original.forEach((propKey, propValue) -> {
                if (propKey instanceof TypedStringValue) {
                    propKey = evaluate((TypedStringValue) propKey);
                }
                if (propValue instanceof TypedStringValue) {
                    propValue = evaluate((TypedStringValue) propValue);
                }
                if (propKey == null || propValue == null) {
                    throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Error converting Properties key/value pair for " + argName + ": resolved to null");
                }
                copy.put(propKey, propValue);
            });
            return copy;
        } else if (value instanceof TypedStringValue) {
            // Convert value to target type here.
            TypedStringValue typedStringValue = (TypedStringValue) value;
            Object valueObject = evaluate(typedStringValue);
            try {
                Clreplaced<?> resolvedTargetType = resolveTargetType(typedStringValue);
                if (resolvedTargetType != null) {
                    return this.typeConverter.convertIfNecessary(valueObject, resolvedTargetType);
                } else {
                    return valueObject;
                }
            } catch (Throwable ex) {
                // Improve the message by showing the context.
                throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Error converting typed String value for " + argName, ex);
            }
        } else if (value instanceof NullBean) {
            return null;
        } else {
            return evaluate(value);
        }
    }

    /**
     * Evaluate the given value as an expression, if necessary.
     * @param value the candidate value (may be an expression)
     * @return the resolved value
     */
    @Nullable
    protected Object evaluate(TypedStringValue value) {
        Object result = doEvaluate(value.getValue());
        if (!ObjectUtils.nullSafeEquals(result, value.getValue())) {
            value.setDynamic();
        }
        return result;
    }

    /**
     * Evaluate the given value as an expression, if necessary.
     * @param value the original value (may be an expression)
     * @return the resolved value if necessary, or the original value
     */
    @Nullable
    protected Object evaluate(@Nullable Object value) {
        if (value instanceof String) {
            return doEvaluate((String) value);
        } else if (value instanceof String[]) {
            String[] values = (String[]) value;
            boolean actuallyResolved = false;
            Object[] resolvedValues = new Object[values.length];
            for (int i = 0; i < values.length; i++) {
                String originalValue = values[i];
                Object resolvedValue = doEvaluate(originalValue);
                if (resolvedValue != originalValue) {
                    actuallyResolved = true;
                }
                resolvedValues[i] = resolvedValue;
            }
            return (actuallyResolved ? resolvedValues : values);
        } else {
            return value;
        }
    }

    /**
     * Evaluate the given String value as an expression, if necessary.
     * @param value the original value (may be an expression)
     * @return the resolved value if necessary, or the original String value
     */
    @Nullable
    private Object doEvaluate(@Nullable String value) {
        return this.beanFactory.evaluateBeanDefinitionString(value, this.beanDefinition);
    }

    /**
     * Resolve the target type in the given TypedStringValue.
     * @param value the TypedStringValue to resolve
     * @return the resolved target type (or {@code null} if none specified)
     * @throws ClreplacedNotFoundException if the specified type cannot be resolved
     * @see TypedStringValue#resolveTargetType
     */
    @Nullable
    protected Clreplaced<?> resolveTargetType(TypedStringValue value) throws ClreplacedNotFoundException {
        if (value.hasTargetType()) {
            return value.getTargetType();
        }
        return value.resolveTargetType(this.beanFactory.getBeanClreplacedLoader());
    }

    /**
     * Resolve a reference to another bean in the factory.
     */
    @Nullable
    private Object resolveReference(Object argName, RuntimeBeanReference ref) {
        try {
            Object bean;
            Clreplaced<?> beanType = ref.getBeanType();
            if (ref.isToParent()) {
                BeanFactory parent = this.beanFactory.getParentBeanFactory();
                if (parent == null) {
                    throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Cannot resolve reference to bean " + ref + " in parent factory: no parent factory available");
                }
                if (beanType != null) {
                    bean = parent.getBean(beanType);
                } else {
                    bean = parent.getBean(String.valueOf(doEvaluate(ref.getBeanName())));
                }
            } else {
                String resolvedName;
                if (beanType != null) {
                    NamedBeanHolder<?> namedBean = this.beanFactory.resolveNamedBean(beanType);
                    bean = namedBean.getBeanInstance();
                    resolvedName = namedBean.getBeanName();
                } else {
                    resolvedName = String.valueOf(doEvaluate(ref.getBeanName()));
                    bean = this.beanFactory.getBean(resolvedName);
                }
                this.beanFactory.registerDependentBean(resolvedName, this.beanName);
            }
            if (bean instanceof NullBean) {
                bean = null;
            }
            return bean;
        } catch (BeansException ex) {
            throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Cannot resolve reference to bean '" + ref.getBeanName() + "' while setting " + argName, ex);
        }
    }

    /**
     * Resolve an inner bean definition.
     * @param argName the name of the argument that the inner bean is defined for
     * @param innerBeanName the name of the inner bean
     * @param innerBd the bean definition for the inner bean
     * @return the resolved inner bean instance
     */
    @Nullable
    private Object resolveInnerBean(Object argName, String innerBeanName, BeanDefinition innerBd) {
        RootBeanDefinition mbd = null;
        try {
            mbd = this.beanFactory.getMergedBeanDefinition(innerBeanName, innerBd, this.beanDefinition);
            // Check given bean name whether it is unique. If not already unique,
            // add counter - increasing the counter until the name is unique.
            String actualInnerBeanName = innerBeanName;
            if (mbd.isSingleton()) {
                actualInnerBeanName = adaptInnerBeanName(innerBeanName);
            }
            this.beanFactory.registerContainedBean(actualInnerBeanName, this.beanName);
            // Guarantee initialization of beans that the inner bean depends on.
            String[] dependsOn = mbd.getDependsOn();
            if (dependsOn != null) {
                for (String dependsOnBean : dependsOn) {
                    this.beanFactory.registerDependentBean(dependsOnBean, actualInnerBeanName);
                    this.beanFactory.getBean(dependsOnBean);
                }
            }
            // Actually create the inner bean instance now...
            Object innerBean = this.beanFactory.createBean(actualInnerBeanName, mbd, null);
            if (innerBean instanceof FactoryBean) {
                boolean synthetic = mbd.isSynthetic();
                innerBean = this.beanFactory.getObjectFromFactoryBean((FactoryBean<?>) innerBean, actualInnerBeanName, !synthetic);
            }
            if (innerBean instanceof NullBean) {
                innerBean = null;
            }
            return innerBean;
        } catch (BeansException ex) {
            throw new BeanCreationException(this.beanDefinition.getResourceDescription(), this.beanName, "Cannot create inner bean '" + innerBeanName + "' " + (mbd != null && mbd.getBeanClreplacedName() != null ? "of type [" + mbd.getBeanClreplacedName() + "] " : "") + "while setting " + argName, ex);
        }
    }

    /**
     * Checks the given bean name whether it is unique. If not already unique,
     * a counter is added, increasing the counter until the name is unique.
     * @param innerBeanName the original name for the inner bean
     * @return the adapted name for the inner bean
     */
    private String adaptInnerBeanName(String innerBeanName) {
        String actualInnerBeanName = innerBeanName;
        int counter = 0;
        while (this.beanFactory.isBeanNameInUse(actualInnerBeanName)) {
            counter++;
            actualInnerBeanName = innerBeanName + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + counter;
        }
        return actualInnerBeanName;
    }

    /**
     * For each element in the managed array, resolve reference if necessary.
     */
    private Object resolveManagedArray(Object argName, List<?> ml, Clreplaced<?> elementType) {
        Object resolved = Array.newInstance(elementType, ml.size());
        for (int i = 0; i < ml.size(); i++) {
            Array.set(resolved, i, resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
        }
        return resolved;
    }

    /**
     * For each element in the managed list, resolve reference if necessary.
     */
    private List<?> resolveManagedList(Object argName, List<?> ml) {
        List<Object> resolved = new ArrayList<>(ml.size());
        for (int i = 0; i < ml.size(); i++) {
            resolved.add(resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
        }
        return resolved;
    }

    /**
     * For each element in the managed set, resolve reference if necessary.
     */
    private Set<?> resolveManagedSet(Object argName, Set<?> ms) {
        Set<Object> resolved = new LinkedHashSet<>(ms.size());
        int i = 0;
        for (Object m : ms) {
            resolved.add(resolveValueIfNecessary(new KeyedArgName(argName, i), m));
            i++;
        }
        return resolved;
    }

    /**
     * For each element in the managed map, resolve reference if necessary.
     */
    private Map<?, ?> resolveManagedMap(Object argName, Map<?, ?> mm) {
        Map<Object, Object> resolved = new LinkedHashMap<>(mm.size());
        mm.forEach((key, value) -> {
            Object resolvedKey = resolveValueIfNecessary(argName, key);
            Object resolvedValue = resolveValueIfNecessary(new KeyedArgName(argName, key), value);
            resolved.put(resolvedKey, resolvedValue);
        });
        return resolved;
    }

    /**
     * Holder clreplaced used for delayed toString building.
     */
    private static clreplaced KeyedArgName {

        private final Object argName;

        private final Object key;

        public KeyedArgName(Object argName, Object key) {
            this.argName = argName;
            this.key = key;
        }

        @Override
        public String toString() {
            return this.argName + " with key " + BeanWrapper.PROPERTY_KEY_PREFIX + this.key + BeanWrapper.PROPERTY_KEY_SUFFIX;
        }
    }
}

19 Source : BeanDefinitionResource.java
with Apache License 2.0
from SourceHot

/**
 * Descriptive {@link org.springframework.core.io.Resource} wrapper for
 * a {@link org.springframework.beans.factory.config.BeanDefinition}.
 *
 * @author Juergen Hoeller
 * @since 2.5.2
 * @see org.springframework.core.io.DescriptiveResource
 */
clreplaced BeanDefinitionResource extends AbstractResource {

    private final BeanDefinition beanDefinition;

    /**
     * Create a new BeanDefinitionResource.
     * @param beanDefinition the BeanDefinition object to wrap
     */
    public BeanDefinitionResource(BeanDefinition beanDefinition) {
        replacedert.notNull(beanDefinition, "BeanDefinition must not be null");
        this.beanDefinition = beanDefinition;
    }

    /**
     * Return the wrapped BeanDefinition object.
     */
    public final BeanDefinition getBeanDefinition() {
        return this.beanDefinition;
    }

    @Override
    public boolean exists() {
        return false;
    }

    @Override
    public boolean isReadable() {
        return false;
    }

    @Override
    public InputStream getInputStream() throws IOException {
        throw new FileNotFoundException("Resource cannot be opened because it points to " + getDescription());
    }

    @Override
    public String getDescription() {
        return "BeanDefinition defined in " + this.beanDefinition.getResourceDescription();
    }

    /**
     * This implementation compares the underlying BeanDefinition.
     */
    @Override
    public boolean equals(@Nullable Object other) {
        return (this == other || (other instanceof BeanDefinitionResource && ((BeanDefinitionResource) other).beanDefinition.equals(this.beanDefinition)));
    }

    /**
     * This implementation returns the hash code of the underlying BeanDefinition.
     */
    @Override
    public int hashCode() {
        return this.beanDefinition.hashCode();
    }
}

19 Source : BeanDefinitionReaderUtils.java
with Apache License 2.0
from SourceHot

/**
 * Generate a bean name for the given bean definition, unique within the
 * given bean factory.
 *
 * 生成一个beanName
 * @param definition the bean definition to generate a bean name for
 * @param registry the bean factory that the definition is going to be
 * registered with (to check for existing bean names)
 * @param isInnerBean whether the given bean definition will be registered
 * as inner bean or as top-level bean (allowing for special name generation
 * for inner beans versus top-level beans)
 * @return the generated bean name
 * @throws BeanDefinitionStoreException if no unique name can be generated
 * for the given bean definition
 */
public static String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry, boolean isInnerBean) throws BeanDefinitionStoreException {
    // 获取 bean clreplaced 的名称
    // Clreplaced.getName()
    String generatedBeanName = definition.getBeanClreplacedName();
    if (generatedBeanName == null) {
        // 父类名称是否存在
        if (definition.getParentName() != null) {
            generatedBeanName = definition.getParentName() + "$child";
        } else // 工厂 beanName 是否为空
        if (definition.getFactoryBeanName() != null) {
            generatedBeanName = definition.getFactoryBeanName() + "$created";
        }
    }
    if (!StringUtils.hasText(generatedBeanName)) {
        throw new BeanDefinitionStoreException("Unnamed bean definition specifies neither " + "'clreplaced' nor 'parent' nor 'factory-bean' - can't generate bean name");
    }
    String id = generatedBeanName;
    if (isInnerBean) {
        // Inner bean: generate idenreplacedy hashcode suffix.
        // 组装名称
        // 生成名称 + # + 16 进制的一个字符串
        id = generatedBeanName + GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdenreplacedyHexString(definition);
    } else {
        // Top-level bean: use plain clreplaced name with unique suffix if necessary.
        // 唯一beanName设置
        // // beanName + # + 序号
        return uniqueBeanName(generatedBeanName, registry);
    }
    return id;
}

19 Source : BeanDefinitionOverrideException.java
with Apache License 2.0
from SourceHot

/**
 * Subclreplaced of {@link BeanDefinitionStoreException} indicating an invalid override
 * attempt: typically registering a new definition for the same bean name while
 * {@link DefaultListableBeanFactory#isAllowBeanDefinitionOverriding()} is {@code false}.
 *
 * @author Juergen Hoeller
 * @since 5.1
 * @see DefaultListableBeanFactory#setAllowBeanDefinitionOverriding
 * @see DefaultListableBeanFactory#registerBeanDefinition
 */
@SuppressWarnings("serial")
public clreplaced BeanDefinitionOverrideException extends BeanDefinitionStoreException {

    private final BeanDefinition beanDefinition;

    private final BeanDefinition existingDefinition;

    /**
     * Create a new BeanDefinitionOverrideException for the given new and existing definition.
     * @param beanName the name of the bean
     * @param beanDefinition the newly registered bean definition
     * @param existingDefinition the existing bean definition for the same name
     */
    public BeanDefinitionOverrideException(String beanName, BeanDefinition beanDefinition, BeanDefinition existingDefinition) {
        super(beanDefinition.getResourceDescription(), beanName, "Cannot register bean definition [" + beanDefinition + "] for bean '" + beanName + "': There is already [" + existingDefinition + "] bound.");
        this.beanDefinition = beanDefinition;
        this.existingDefinition = existingDefinition;
    }

    /**
     * Return the description of the resource that the bean definition came from.
     */
    @Override
    @NonNull
    public String getResourceDescription() {
        return String.valueOf(super.getResourceDescription());
    }

    /**
     * Return the name of the bean.
     */
    @Override
    @NonNull
    public String getBeanName() {
        return String.valueOf(super.getBeanName());
    }

    /**
     * Return the newly registered bean definition.
     * @see #getBeanName()
     */
    public BeanDefinition getBeanDefinition() {
        return this.beanDefinition;
    }

    /**
     * Return the existing bean definition for the same name.
     * @see #getBeanName()
     */
    public BeanDefinition getExistingDefinition() {
        return this.existingDefinition;
    }
}

19 Source : PointcutComponentDefinition.java
with Apache License 2.0
from SourceHot

/**
 * {@link org.springframework.beans.factory.parsing.ComponentDefinition}
 * implementation that holds a pointcut definition.
 *
 * 切点的组件描述
 * @author Rob Harrop
 * @since 2.0
 */
public clreplaced PointcutComponentDefinition extends AbstractComponentDefinition {

    /**
     * 切点bean名称
     */
    private final String pointcutBeanName;

    /**
     * 切点的bean定义
     */
    private final BeanDefinition pointcutDefinition;

    /**
     * 切点描述
     */
    private final String description;

    /**
     * @param pointcutBeanName 切点 bean
     * @param pointcutDefinition 切点描述
     * @param expression 表达式
     */
    public PointcutComponentDefinition(String pointcutBeanName, BeanDefinition pointcutDefinition, String expression) {
        replacedert.notNull(pointcutBeanName, "Bean name must not be null");
        replacedert.notNull(pointcutDefinition, "Pointcut definition must not be null");
        replacedert.notNull(expression, "Expression must not be null");
        this.pointcutBeanName = pointcutBeanName;
        this.pointcutDefinition = pointcutDefinition;
        this.description = "Pointcut <name='" + pointcutBeanName + "', expression=[" + expression + "]>";
    }

    @Override
    public String getName() {
        return this.pointcutBeanName;
    }

    @Override
    public String getDescription() {
        return this.description;
    }

    @Override
    public BeanDefinition[] getBeanDefinitions() {
        return new BeanDefinition[] { this.pointcutDefinition };
    }

    @Override
    @Nullable
    public Object getSource() {
        return this.pointcutDefinition.getSource();
    }
}

19 Source : DataSourceBeanFactoryPostProcessor.java
with Apache License 2.0
from sofastack

private String resolveBeanClreplacedName(BeanDefinition dataSource) {
    String beanClreplacedName = dataSource.getBeanClreplacedName();
    if (beanClreplacedName != null) {
        return beanClreplacedName;
    }
    Object source = dataSource.getSource();
    if (source instanceof MethodMetadataReadingVisitor) {
        return ((MethodMetadataReadingVisitor) source).getReturnTypeName();
    }
    return null;
}

19 Source : SofaBeanNameGenerator.java
with Apache License 2.0
from sofastack

public static String generateSofaServiceBeanName(BeanDefinition definition) {
    String interfaceName = (String) definition.getPropertyValues().get(AbstractContractDefinitionParser.INTERFACE_PROPERTY);
    Clreplaced clazz = (Clreplaced) definition.getPropertyValues().get(AbstractContractDefinitionParser.INTERFACE_CLreplaced_PROPERTY);
    if (clazz != null) {
        interfaceName = clazz.getCanonicalName();
    }
    String uniqueId = (String) definition.getPropertyValues().get(AbstractContractDefinitionParser.UNIQUE_ID_PROPERTY);
    return generateSofaServiceBeanName(interfaceName, uniqueId);
}

19 Source : BeanDefinitionUtil.java
with Apache License 2.0
from sofastack

/**
 * @param beanDefinition Check whether it is a bean definition created from a configuration clreplaced
 *                       as opposed to any other configuration source.
 * @return
 */
public static boolean isFromConfigurationSource(BeanDefinition beanDefinition) {
    return beanDefinition.getClreplaced().getCanonicalName().startsWith("org.springframework.context.annotation.ConfigurationClreplacedBeanDefinitionReader");
}

See More Examples