Merge pull request #6225 from er-han/BAEL-2550

Added tutorial sample for BAEL-2550
This commit is contained in:
Tom Hombergs 2019-03-15 21:11:40 +01:00 committed by GitHub
commit 4df665a579
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 0 deletions

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,12 @@
package org.baeldung.sampleabstract;
import org.springframework.stereotype.Component;
@Component
public class LogRepository {
@Override
public String toString() {
return "logRepository";
}
}

View File

@ -0,0 +1,12 @@
package org.baeldung.sampleabstract;
import org.springframework.stereotype.Component;
@Component
public class RuleRepository {
@Override
public String toString() {
return "ruleRepository";
}
}