Skip to content

Commit 4df665a

Browse files
authored
Merge pull request eugenp#6225 from er-han/BAEL-2550
Added tutorial sample for BAEL-2550
2 parents 9b6a3a0 + 84d83fb commit 4df665a

5 files changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.baeldung.sampleabstract;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
5+
import javax.annotation.PostConstruct;
6+
7+
public abstract class BallService {
8+
9+
private RuleRepository ruleRepository;
10+
11+
private LogRepository logRepository;
12+
13+
public BallService(RuleRepository ruleRepository) {
14+
this.ruleRepository = ruleRepository;
15+
}
16+
17+
@Autowired
18+
public final void setLogRepository(LogRepository logRepository) {
19+
this.logRepository = logRepository;
20+
}
21+
22+
@PostConstruct
23+
public void afterInitialize() {
24+
25+
System.out.println(ruleRepository.toString());
26+
System.out.println(logRepository.toString());
27+
}
28+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.baeldung.sampleabstract;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.stereotype.Component;
5+
6+
@Component
7+
public class BasketballService extends BallService {
8+
9+
@Autowired
10+
public BasketballService(RuleRepository ruleRepository) {
11+
super(ruleRepository);
12+
}
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.baeldung.sampleabstract;
2+
3+
import org.springframework.context.ApplicationContext;
4+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
5+
import org.springframework.context.annotation.ComponentScan;
6+
import org.springframework.context.annotation.Configuration;
7+
8+
@Configuration
9+
@ComponentScan(basePackages = "org.baeldung.sampleabstract")
10+
public class DemoApp {
11+
12+
13+
public static void main(String[] args) {
14+
15+
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(DemoApp.class);
16+
}
17+
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.baeldung.sampleabstract;
2+
3+
import org.springframework.stereotype.Component;
4+
5+
@Component
6+
public class LogRepository {
7+
8+
@Override
9+
public String toString() {
10+
return "logRepository";
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.baeldung.sampleabstract;
2+
3+
import org.springframework.stereotype.Component;
4+
5+
@Component
6+
public class RuleRepository {
7+
8+
@Override
9+
public String toString() {
10+
return "ruleRepository";
11+
}
12+
}

0 commit comments

Comments
 (0)