congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ConfigurableBeanFactory
Code IndexAdd Tabnine to your IDE (free)

How to use
ConfigurableBeanFactory
in
org.springframework.beans.factory.config

Best Java code snippets using org.springframework.beans.factory.config.ConfigurableBeanFactory (Showing top 20 results out of 4,689)

origin: spring-projects/spring-framework

/**
 * Resolve the given annotation-specified value,
 * potentially containing placeholders and expressions.
 */
private Object resolveStringValue(String value) {
  if (this.configurableBeanFactory == null) {
    return value;
  }
  String placeholdersResolved = this.configurableBeanFactory.resolveEmbeddedValue(value);
  BeanExpressionResolver exprResolver = this.configurableBeanFactory.getBeanExpressionResolver();
  if (exprResolver == null) {
    return value;
  }
  return exprResolver.evaluate(placeholdersResolved, this.expressionContext);
}
origin: spring-projects/spring-framework

boolean alreadyInCreation = beanFactory.isCurrentlyInCreation(beanName);
try {
  if (alreadyInCreation) {
    beanFactory.setCurrentlyInCreation(beanName, false);
  if (useArgs && beanFactory.isSingleton(beanName)) {
  Object beanInstance = (useArgs ? beanFactory.getBean(beanName, beanMethodArgs) :
      beanFactory.getBean(beanName));
  if (!ClassUtils.isAssignableValue(beanMethod.getReturnType(), beanInstance)) {
          beanMethod.getReturnType().getName(), beanInstance.getClass().getName());
      try {
        BeanDefinition beanDefinition = beanFactory.getMergedBeanDefinition(beanName);
        msg += " Overriding bean of same name declared in: " + beanDefinition.getResourceDescription();
  if (currentlyInvoked != null) {
    String outerBeanName = BeanAnnotationHelper.determineBeanNameFor(currentlyInvoked);
    beanFactory.registerDependentBean(beanName, outerBeanName);
    beanFactory.setCurrentlyInCreation(beanName, true);
origin: resilience4j/resilience4j

private void createHealthIndicatorForLimiter(ConfigurableBeanFactory beanFactory, String name, RateLimiter rateLimiter) {
  beanFactory.registerSingleton(
      name + "RateLimiterHealthIndicator",
      new RateLimiterHealthIndicator(rateLimiter)
  );
}
origin: spring-projects/spring-framework

@Override
public void setBeanFactory(BeanFactory beanFactory) {
  this.beanFactory = beanFactory;
  if (beanFactory instanceof ConfigurableBeanFactory) {
    ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
    if (this.beanClassLoader == null) {
      this.beanClassLoader = cbf.getBeanClassLoader();
    }
    this.retrievalMutex = cbf.getSingletonMutex();
  }
}
origin: spring-projects/spring-framework

/**
 * Check the BeanFactory to see whether the bean named <var>beanName</var> already
 * exists. Accounts for the fact that the requested bean may be "in creation", i.e.:
 * we're in the middle of servicing the initial request for this bean. From an enhanced
 * factory method's perspective, this means that the bean does not actually yet exist,
 * and that it is now our job to create it for the first time by executing the logic
 * in the corresponding factory method.
 * <p>Said another way, this check repurposes
 * {@link ConfigurableBeanFactory#isCurrentlyInCreation(String)} to determine whether
 * the container is calling this method or the user is calling this method.
 * @param beanName name of bean to check for
 * @return whether <var>beanName</var> already exists in the factory
 */
private boolean factoryContainsBean(ConfigurableBeanFactory beanFactory, String beanName) {
  return (beanFactory.containsBean(beanName) && !beanFactory.isCurrentlyInCreation(beanName));
}
origin: spring-projects/spring-framework

@Nullable
public Object getObject(String key) {
  if (this.beanFactory.containsBean(key)) {
    return this.beanFactory.getBean(key);
  }
  else if (this.scope != null) {
    return this.scope.resolveContextualObject(key);
  }
  else {
    return null;
  }
}
origin: spring-projects/spring-framework

@Override
public void copyConfigurationFrom(ConfigurableBeanFactory otherFactory) {
  Assert.notNull(otherFactory, "BeanFactory must not be null");
  setBeanClassLoader(otherFactory.getBeanClassLoader());
  setCacheBeanMetadata(otherFactory.isCacheBeanMetadata());
  setBeanExpressionResolver(otherFactory.getBeanExpressionResolver());
  setConversionService(otherFactory.getConversionService());
  if (otherFactory instanceof AbstractBeanFactory) {
    AbstractBeanFactory otherAbstractFactory = (AbstractBeanFactory) otherFactory;
    this.propertyEditorRegistrars.addAll(otherAbstractFactory.propertyEditorRegistrars);
    this.customEditors.putAll(otherAbstractFactory.customEditors);
    this.typeConverter = otherAbstractFactory.typeConverter;
    this.beanPostProcessors.addAll(otherAbstractFactory.beanPostProcessors);
    this.hasInstantiationAwareBeanPostProcessors = this.hasInstantiationAwareBeanPostProcessors ||
        otherAbstractFactory.hasInstantiationAwareBeanPostProcessors;
    this.hasDestructionAwareBeanPostProcessors = this.hasDestructionAwareBeanPostProcessors ||
        otherAbstractFactory.hasDestructionAwareBeanPostProcessors;
    this.scopes.putAll(otherAbstractFactory.scopes);
    this.securityContextProvider = otherAbstractFactory.securityContextProvider;
  }
  else {
    setTypeConverter(otherFactory.getTypeConverter());
    String[] otherScopeNames = otherFactory.getRegisteredScopeNames();
    for (String scopeName : otherScopeNames) {
      this.scopes.put(scopeName, otherFactory.getRegisteredScope(scopeName));
    }
  }
}
origin: spring-projects/spring-retry

/**
 * Resolve the specified value if possible.
 *
 * @see ConfigurableBeanFactory#resolveEmbeddedValue
 */
private String resolve(String value) {
  if (this.beanFactory != null && this.beanFactory instanceof ConfigurableBeanFactory) {
    return ((ConfigurableBeanFactory) this.beanFactory).resolveEmbeddedValue(value);
  }
  return value;
}
origin: ctripcorp/apollo

/**
 * Resolve placeholder property values, e.g.
 * <br />
 * <br />
 * "${somePropertyValue}" -> "the actual property value"
 */
public Object resolvePropertyValue(ConfigurableBeanFactory beanFactory, String beanName, String placeholder) {
 // resolve string value
 String strVal = beanFactory.resolveEmbeddedValue(placeholder);
 BeanDefinition bd = (beanFactory.containsBean(beanName) ? beanFactory
   .getMergedBeanDefinition(beanName) : null);
 // resolve expressions like "#{systemProperties.myProp}"
 return evaluateBeanDefinitionString(beanFactory, strVal, bd);
}
origin: Red5/red5-server

if (factory.containsSingleton(name)) {
  log.warn("Singleton {} already exists, try unload first", name);
  return;
  log.debug("Lookup common - bean:{} local:{} singleton:{}", new Object[] { factory.containsBean("red5.common"), factory.containsLocalBean("red5.common"), factory.containsSingleton("red5.common"), });
  parentContext = (ApplicationContext) factory.getBean("red5.common");
factory.registerSingleton(name, context);
origin: camunda/camunda-bpm-platform

public void copyConfigurationFrom(ConfigurableBeanFactory otherFactory) {
  Assert.notNull(otherFactory, "BeanFactory must not be null");
  setBeanClassLoader(otherFactory.getBeanClassLoader());
  setCacheBeanMetadata(otherFactory.isCacheBeanMetadata());
  setBeanExpressionResolver(otherFactory.getBeanExpressionResolver());
  if (otherFactory instanceof AbstractBeanFactory) {
    AbstractBeanFactory otherAbstractFactory = (AbstractBeanFactory) otherFactory;
    this.customEditors.putAll(otherAbstractFactory.customEditors);
    this.propertyEditorRegistrars.addAll(otherAbstractFactory.propertyEditorRegistrars);
    this.beanPostProcessors.addAll(otherAbstractFactory.beanPostProcessors);
    this.hasInstantiationAwareBeanPostProcessors = this.hasInstantiationAwareBeanPostProcessors ||
        otherAbstractFactory.hasInstantiationAwareBeanPostProcessors;
    this.hasDestructionAwareBeanPostProcessors = this.hasDestructionAwareBeanPostProcessors ||
        otherAbstractFactory.hasDestructionAwareBeanPostProcessors;
    this.scopes.putAll(otherAbstractFactory.scopes);
    this.securityContextProvider = otherAbstractFactory.securityContextProvider;
  }
  else {
    setTypeConverter(otherFactory.getTypeConverter());
  }
}
origin: spring-io/initializr

@Override
public void beforeTestClass(TestContext testContext) throws Exception {
  ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) testContext
      .getApplicationContext().getAutowireCapableBeanFactory();
  if (!beanFactory.containsBean("mockMvcClientHttpRequestFactory")) {
    this.factory = new MockMvcClientHttpRequestFactory(
        beanFactory.getBean(MockMvc.class));
    beanFactory.registerSingleton("mockMvcClientHttpRequestFactory",
        this.factory);
  }
  else {
    this.factory = beanFactory.getBean("mockMvcClientHttpRequestFactory",
        MockMvcClientHttpRequestFactory.class);
  }
}
origin: spring-projects/spring-framework

@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
  if (beanFactory instanceof ConfigurableBeanFactory) {
    Object typeConverter = ((ConfigurableBeanFactory) beanFactory).getTypeConverter();
    if (typeConverter instanceof SimpleTypeConverter) {
      delegate = (SimpleTypeConverter) typeConverter;
    }
  }
}
origin: spring-projects/spring-data-redis

public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
  // TODO: This code can never happen...
  if (converter == null && beanFactory instanceof ConfigurableBeanFactory) {
    ConfigurableBeanFactory cFB = (ConfigurableBeanFactory) beanFactory;
    ConversionService conversionService = cFB.getConversionService();
    converter = (conversionService != null ? new Converter(conversionService)
        : new Converter(cFB.getTypeConverter()));
  }
}
origin: spring-projects/spring-framework

@Override
@Nullable
public ClassLoader getAspectClassLoader() {
  return (this.beanFactory instanceof ConfigurableBeanFactory ?
      ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader() :
      ClassUtils.getDefaultClassLoader());
}
origin: spring-projects/spring-framework

@Override
public Object getTargetObject() {
  return this.beanFactory.getBean(this.targetBeanName);
}
origin: spring-projects/spring-framework

sec.addPropertyAccessor(new EnvironmentAccessor());
sec.setBeanResolver(new BeanFactoryResolver(evalContext.getBeanFactory()));
sec.setTypeLocator(new StandardTypeLocator(evalContext.getBeanFactory().getBeanClassLoader()));
ConversionService conversionService = evalContext.getBeanFactory().getConversionService();
if (conversionService != null) {
  sec.setTypeConverter(new StandardTypeConverter(conversionService));
origin: spring-projects/spring-framework

if (beanFactory.isCurrentlyInCreation(scopedBeanName)) {
  beanName = scopedBeanName;
Object factoryBean = beanFactory.getBean(BeanFactory.FACTORY_BEAN_PREFIX + beanName);
if (factoryBean instanceof ScopedProxyFactoryBean) {
origin: org.springframework.boot/spring-boot

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));
  }
}
origin: ctripcorp/apollo

private Object evaluateBeanDefinitionString(ConfigurableBeanFactory beanFactory, String value,
  BeanDefinition beanDefinition) {
 if (beanFactory.getBeanExpressionResolver() == null) {
  return value;
 }
 Scope scope = (beanDefinition != null ? beanFactory
   .getRegisteredScope(beanDefinition.getScope()) : null);
 return beanFactory.getBeanExpressionResolver()
   .evaluate(value, new BeanExpressionContext(beanFactory, scope));
}
org.springframework.beans.factory.configConfigurableBeanFactory

Javadoc

Configuration interface to be implemented by most bean factories. Provides facilities to configure a bean factory, in addition to the bean factory client methods in the org.springframework.beans.factory.BeanFactoryinterface.

This bean factory interface is not meant to be used in normal application code: Stick to org.springframework.beans.factory.BeanFactory or org.springframework.beans.factory.ListableBeanFactory for typical needs. This extended interface is just meant to allow for framework-internal plug'n'play and for special access to bean factory configuration methods.

Most used methods

  • resolveEmbeddedValue
    Resolve the given embedded value, e.g. an annotation attribute.
  • getBeanExpressionResolver
    Return the resolution strategy for expressions in bean definition values.
  • getBean
  • registerSingleton
    Register the given existing object as singleton in the bean factory, under the given bean name.The g
  • getTypeConverter
    Obtain a type converter as used by this BeanFactory. This may be a fresh instance for each call, sin
  • getBeanClassLoader
    Return this factory's class loader for loading bean classes (only null if even the system ClassLoade
  • containsBean
  • getConversionService
    Return the associated ConversionService, if any.
  • getMergedBeanDefinition
    Return a merged BeanDefinition for the given bean name, merging a child bean definition with its par
  • isCurrentlyInCreation
    Determine whether the specified bean is currently in creation.
  • getSingletonMutex
  • destroySingletons
    Destroy all cached singletons in this factory. To be called on shutdown of a factory.
  • getSingletonMutex,
  • destroySingletons,
  • getSingletonNames,
  • registerDependentBean,
  • containsSingleton,
  • destroyBean,
  • isFactoryBean,
  • isSingleton,
  • registerAlias,
  • addBeanPostProcessor

Popular in Java

  • Creating JSON documents from java classes using gson
  • setScale (BigDecimal)
  • getContentResolver (Context)
  • findViewById (Activity)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now