Skip to content

Commit

Permalink
Common constant for DefaultBeanNameGenerator as well
Browse files Browse the repository at this point in the history
Closes gh-22591
  • Loading branch information
jhoeller committed Apr 3, 2019
1 parent 47c8d1d commit dee88d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,7 +61,7 @@ public abstract class AbstractBeanDefinitionReader implements BeanDefinitionRead

private Environment environment;

private BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
private BeanNameGenerator beanNameGenerator = DefaultBeanNameGenerator.INSTANCE;


/**
Expand Down Expand Up @@ -171,7 +171,7 @@ public Environment getEnvironment() {
* <p>Default is a {@link DefaultBeanNameGenerator}.
*/
public void setBeanNameGenerator(@Nullable BeanNameGenerator beanNameGenerator) {
this.beanNameGenerator = (beanNameGenerator != null ? beanNameGenerator : new DefaultBeanNameGenerator());
this.beanNameGenerator = (beanNameGenerator != null ? beanNameGenerator : DefaultBeanNameGenerator.INSTANCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,6 +27,14 @@
*/
public class DefaultBeanNameGenerator implements BeanNameGenerator {

/**
* A convenient constant for a default {@code DefaultBeanNameGenerator} instance,
* as used for {@link AbstractBeanDefinitionReader} setup.
* @since 5.2
*/
public static final DefaultBeanNameGenerator INSTANCE = new DefaultBeanNameGenerator();


@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
return BeanDefinitionReaderUtils.generateBeanName(definition, registry);
Expand Down

0 comments on commit dee88d9

Please sign in to comment.