Skip to content

Commit 4ffdb35

Browse files
committed
GH-1498: created early test project for indexing framework 7 bean registrars
1 parent 28e0438 commit 4ffdb35

File tree

7 files changed

+94
-0
lines changed

7 files changed

+94
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.example</groupId>
6+
<artifactId>test-framework-7-indexing</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
<dependencies>
10+
<dependency>
11+
<groupId>org.springframework</groupId>
12+
<artifactId>spring-context</artifactId>
13+
<version>7.0.0-SNAPSHOT</version>
14+
</dependency>
15+
</dependencies>
16+
17+
<repositories>
18+
<repository>
19+
<id>repository.spring.snapshot</id>
20+
<name>Spring Snapshot Repository</name>
21+
<url>https://repo.spring.io/snapshot</url>
22+
</repository>
23+
</repositories>
24+
25+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.example;
2+
3+
public class Bar {
4+
5+
private Foo foo;
6+
7+
public Bar(Foo foo) {
8+
this.foo = foo;
9+
}
10+
11+
public Foo getFoo() {
12+
return foo;
13+
}
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.example;
2+
3+
public class Baz {
4+
5+
private String something;
6+
7+
public Baz(String something) {
8+
this.something = something;
9+
}
10+
11+
public void printSomething() {
12+
System.out.println(something);
13+
}
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.example;
2+
3+
public class BeanClass {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.example;
2+
3+
public class Foo {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.example;
2+
3+
public class FooFoo {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example;
2+
3+
import org.springframework.beans.factory.BeanRegistrar;
4+
import org.springframework.beans.factory.BeanRegistry;
5+
import org.springframework.core.env.Environment;
6+
7+
public class MyBeanRegistrar implements BeanRegistrar {
8+
9+
@Override
10+
public void register(BeanRegistry registry, Environment env) {
11+
registry.registerBean(FooFoo.class);
12+
registry.registerBean("foo", Foo.class);
13+
registry.registerBean("bar", Bar.class, spec -> spec
14+
.prototype()
15+
.lazyInit()
16+
.description("Custom description")
17+
.supplier(context -> new Bar(context.bean(Foo.class))));
18+
if (env.matchesProfiles("baz")) {
19+
registry.registerBean(Baz.class, spec -> spec
20+
.supplier(context -> new Baz("Hello World!")));
21+
}
22+
}
23+
24+
}

0 commit comments

Comments
 (0)