Skip to content

Commit c19dfa5

Browse files
committed
remove extra classes
1 parent 1cea9ee commit c19dfa5

6 files changed

Lines changed: 25 additions & 65 deletions

File tree

‎spring-core/src/main/java/com/baeldung/scope/AppConfig.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public SingletonObjectFactoryBean singletonObjectFactoryBean() {
4747
}
4848

4949
@Bean
50-
public Function<String, PrototypeBeanWithParam> beanFactory() {
50+
public Function<String, PrototypeBean> beanFactory() {
5151
return name -> prototypeBeanWithParam(name);
5252
}
5353

5454
@Bean
5555
@Scope(value = "prototype")
56-
public PrototypeBeanWithParam prototypeBeanWithParam(String name) {
57-
return new PrototypeBeanWithParam(name);
56+
public PrototypeBean prototypeBeanWithParam(String name) {
57+
return new PrototypeBean(name);
5858
}
5959

6060
@Bean

‎spring-core/src/main/java/com/baeldung/scope/PrototypeFactoryBeanConfig.java‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎spring-core/src/main/java/com/baeldung/scope/prototype/PrototypeBean.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,20 @@ public class PrototypeBean {
99
public PrototypeBean() {
1010
logger.info("Prototype instance created");
1111
}
12+
13+
private String name;
14+
15+
public PrototypeBean(String name) {
16+
this.name = name;
17+
logger.info("Prototype instance " + name + " created");
18+
}
19+
20+
public String getName() {
21+
return name;
22+
}
23+
24+
public void setName(String name) {
25+
this.name = name;
26+
}
27+
1228
}

‎spring-core/src/main/java/com/baeldung/scope/prototype/PrototypeBeanWithParam.java‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎spring-core/src/main/java/com/baeldung/scope/singletone/SingletonFunctionBean.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
import org.springframework.beans.factory.annotation.Autowired;
66

7-
import com.baeldung.scope.prototype.PrototypeBeanWithParam;
7+
import com.baeldung.scope.prototype.PrototypeBean;
88

99
public class SingletonFunctionBean {
1010

1111
@Autowired
12-
private Function<String, PrototypeBeanWithParam> beanFactory;
12+
private Function<String, PrototypeBean> beanFactory;
1313

14-
public PrototypeBeanWithParam getPrototypeInstance(String name) {
15-
PrototypeBeanWithParam bean = beanFactory.apply(name);
14+
public PrototypeBean getPrototypeInstance(String name) {
15+
PrototypeBean bean = beanFactory.apply(name);
1616
return bean;
1717
}
1818

‎spring-core/src/test/java/com/baeldung/scope/PrototypeBeanInjectionIntegrationTest.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.baeldung.scope;
22

33
import com.baeldung.scope.prototype.PrototypeBean;
4-
import com.baeldung.scope.prototype.PrototypeBeanWithParam;
54
import com.baeldung.scope.singletone.SingletonFunctionBean;
65
import com.baeldung.scope.singletone.SingletonLookupBean;
76
import com.baeldung.scope.singletone.SingletonObjectFactoryBean;
@@ -70,8 +69,8 @@ public void givenPrototypeInjection_WhenFunction_ThenNewInstanceReturn() {
7069
SingletonFunctionBean firstContext = context.getBean(SingletonFunctionBean.class);
7170
SingletonFunctionBean secondContext = context.getBean(SingletonFunctionBean.class);
7271

73-
PrototypeBeanWithParam firstInstance = firstContext.getPrototypeInstance("instance1");
74-
PrototypeBeanWithParam secondInstance = secondContext.getPrototypeInstance("instance2");
72+
PrototypeBean firstInstance = firstContext.getPrototypeInstance("instance1");
73+
PrototypeBean secondInstance = secondContext.getPrototypeInstance("instance2");
7574

7675
Assert.assertTrue("New instance expected", firstInstance != secondInstance);
7776
}

0 commit comments

Comments
 (0)