Skip to content

Commit 2f8c5a5

Browse files
committed
Polishing
1 parent 2bc213d commit 2f8c5a5

File tree

2 files changed

+42
-39
lines changed

2 files changed

+42
-39
lines changed

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/BeanRegistry.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
*/
3939
public interface BeanRegistry {
4040

41+
/**
42+
* Register beans using the given {@link BeanRegistrar}.
43+
* @param registrar the bean registrar that will be called to register
44+
* additional beans
45+
*/
46+
void register(BeanRegistrar registrar);
47+
4148
/**
4249
* Given a name, register an alias for it.
4350
* @param name the canonical name
@@ -88,12 +95,6 @@ public interface BeanRegistry {
8895
*/
8996
<T> void registerBean(String name, Class<T> beanClass, Consumer<Spec<T>> customizer);
9097

91-
/**
92-
* Register beans using the given {@link BeanRegistrar}.
93-
* @param registrar the bean registrar that will be called to register
94-
* additional beans
95-
*/
96-
void register(BeanRegistrar registrar);
9798

9899
/**
99100
* Specification for customizing a bean.

Diff for: spring-beans/src/main/kotlin/org/springframework/beans/factory/BeanRegistrarDsl.kt

+35-33
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,41 @@ open class BeanRegistrarDsl(private val init: BeanRegistrarDsl.() -> Unit): Bean
6464
*/
6565
lateinit var env: Environment
6666

67+
68+
/**
69+
* Apply the nested block if the given profile expression matches the
70+
* active profiles.
71+
*
72+
* A profile expression may contain a simple profile name (for example
73+
* `"production"`) or a compound expression. A compound expression allows
74+
* for more complicated profile logic to be expressed, for example
75+
* `"production & cloud"`.
76+
*
77+
* The following operators are supported in profile expressions:
78+
* - `!` - A logical *NOT* of the profile name or compound expression
79+
* - `&` - A logical *AND* of the profile names or compound expressions
80+
* - `|` - A logical *OR* of the profile names or compound expressions
81+
*
82+
* Please note that the `&` and `|` operators may not be mixed
83+
* without using parentheses. For example, `"a & b | c"` is not a valid
84+
* expression: it must be expressed as `"(a & b) | c"` or `"a & (b | c)"`.
85+
* @param expression the profile expressions to evaluate
86+
*/
87+
fun profile(expression: String, init: BeanRegistrarDsl.() -> Unit) {
88+
if (env.matchesProfiles(expression)) {
89+
init()
90+
}
91+
}
92+
93+
/**
94+
* Register beans using the given [BeanRegistrar].
95+
* @param registrar the bean registrar that will be called to register
96+
* additional beans
97+
*/
98+
fun register(registrar: BeanRegistrar) {
99+
return registry.register(registrar)
100+
}
101+
67102
/**
68103
* Given a name, register an alias for it.
69104
* @param name the canonical name
@@ -345,39 +380,6 @@ open class BeanRegistrarDsl(private val init: BeanRegistrarDsl.() -> Unit): Bean
345380
return registry.registerBean(T::class.java, customizer)
346381
}
347382

348-
/**
349-
* Register beans using the given [BeanRegistrar].
350-
* @param registrar the bean registrar that will be called to register
351-
* additional beans
352-
*/
353-
fun register(registrar: BeanRegistrar) {
354-
return registry.register(registrar)
355-
}
356-
357-
/**
358-
* Apply the nested block if the given profile expression matches the
359-
* active profiles.
360-
*
361-
* A profile expression may contain a simple profile name (for example
362-
* `"production"`) or a compound expression. A compound expression allows
363-
* for more complicated profile logic to be expressed, for example
364-
* `"production & cloud"`.
365-
*
366-
* The following operators are supported in profile expressions:
367-
* - `!` - A logical *NOT* of the profile name or compound expression
368-
* - `&` - A logical *AND* of the profile names or compound expressions
369-
* - `|` - A logical *OR* of the profile names or compound expressions
370-
*
371-
* Please note that the `&` and `|` operators may not be mixed
372-
* without using parentheses. For example, `"a & b | c"` is not a valid
373-
* expression: it must be expressed as `"(a & b) | c"` or `"a & (b | c)"`.
374-
* @param expression the profile expressions to evaluate
375-
*/
376-
fun profile(expression: String, init: BeanRegistrarDsl.() -> Unit) {
377-
if (env.matchesProfiles(expression)) {
378-
init()
379-
}
380-
}
381383

382384
/**
383385
* Context available from the bean instance supplier designed to give access

0 commit comments

Comments
 (0)