Merge pull request #6225 from er-han/BAEL-2550
Added tutorial sample for BAEL-2550
This commit is contained in:
commit
4df665a579
|
@ -0,0 +1,28 @@
|
|||
package org.baeldung.sampleabstract;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
public abstract class BallService {
|
||||
|
||||
private RuleRepository ruleRepository;
|
||||
|
||||
private LogRepository logRepository;
|
||||
|
||||
public BallService(RuleRepository ruleRepository) {
|
||||
this.ruleRepository = ruleRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public final void setLogRepository(LogRepository logRepository) {
|
||||
this.logRepository = logRepository;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void afterInitialize() {
|
||||
|
||||
System.out.println(ruleRepository.toString());
|
||||
System.out.println(logRepository.toString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.baeldung.sampleabstract;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BasketballService extends BallService {
|
||||
|
||||
@Autowired
|
||||
public BasketballService(RuleRepository ruleRepository) {
|
||||
super(ruleRepository);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.baeldung.sampleabstract;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = "org.baeldung.sampleabstract")
|
||||
public class DemoApp {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(DemoApp.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package org.baeldung.sampleabstract;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class LogRepository {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "logRepository";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package org.baeldung.sampleabstract;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RuleRepository {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ruleRepository";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue