File tree Expand file tree Collapse file tree
spring-all/src/main/java/org/baeldung/sampleabstract Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 44import org .springframework .stereotype .Component ;
55
66@ Component
7- public class FooService extends AbstractService {
7+ public class BasketballService extends BallService {
88
99 @ Autowired
10- public FooService (FooBarBean fooBarBean ) {
11-
12- super (fooBarBean );
10+ public BasketballService (RuleRepository ruleRepository ) {
11+ super (ruleRepository );
1312 }
1413}
Original file line number Diff line number Diff line change 11package org .baeldung .sampleabstract ;
22
3- import org .springframework .beans .factory .annotation .Autowired ;
43import org .springframework .context .ApplicationContext ;
54import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
65import org .springframework .context .annotation .ComponentScan ;
76import org .springframework .context .annotation .Configuration ;
87
9- import javax .annotation .PostConstruct ;
10-
118@ Configuration
129@ ComponentScan (basePackages = "org.baeldung.sampleabstract" )
1310public class DemoApp {
1411
15- @ Autowired
16- private FooService fooService ;
1712
1813 public static void main (String [] args ) {
1914
2015 ApplicationContext applicationContext = new AnnotationConfigApplicationContext (DemoApp .class );
2116 }
2217
23- @ PostConstruct
24- public void afterInitialize () {
25-
26- fooService .afterInitialize ();
27- }
2818}
Load diff This file was deleted.
Original file line number Diff line number Diff line change 33import org .springframework .stereotype .Component ;
44
55@ Component
6- public class BarBean {
6+ public class LogRepository {
77
8- public String value () {
9-
10- return "barBean " ;
8+ @ Override
9+ public String toString () {
10+ return "logRepository " ;
1111 }
1212}
Original file line number Diff line number Diff line change 33import org .springframework .stereotype .Component ;
44
55@ Component
6- public class FooBarBean {
6+ public class RuleRepository {
77
8- public String value () {
9-
10- return "fooBarBean " ;
8+ @ Override
9+ public String toString () {
10+ return "ruleRepository " ;
1111 }
1212}
You can’t perform that action at this time.
0 commit comments