Changed class names to make them more memorable

This commit is contained in:
Erhan KARAKAYA 2019-03-10 21:37:48 +03:00
parent 11bce96dc8
commit 84d83fb8ec
7 changed files with 39 additions and 91 deletions

View File

@ -1,57 +0,0 @@
package org.baeldung.sampleabstract;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class AbstractService {
@Autowired
private FooBean fooBean;
private BarBean barBean;
private FooBarBean fooBarBean;
public AbstractService(FooBarBean fooBarBean) {
this.fooBarBean = fooBarBean;
}
public FooBean getFooBean() {
return fooBean;
}
public void setFooBean(FooBean fooBean) {
this.fooBean = fooBean;
}
public BarBean getBarBean() {
return barBean;
}
@Autowired
public void setBarBean(BarBean barBean) {
this.barBean = barBean;
}
public FooBarBean getFooBarBean() {
return fooBarBean;
}
public void setFooBarBean(FooBarBean fooBarBean) {
this.fooBarBean = fooBarBean;
}
public void afterInitialize() {
System.out.println(fooBean.value());
System.out.println(barBean.value());
System.out.println(fooBarBean.value());
}
}

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

@ -4,11 +4,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class FooService extends AbstractService {
public class BasketballService extends BallService {
@Autowired
public FooService(FooBarBean fooBarBean) {
super(fooBarBean);
public BasketballService(RuleRepository ruleRepository) {
super(ruleRepository);
}
}

View File

@ -1,28 +1,18 @@
package org.baeldung.sampleabstract;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
@Configuration
@ComponentScan(basePackages = "org.baeldung.sampleabstract")
public class DemoApp {
@Autowired
private FooService fooService;
public static void main(String[] args) {
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(DemoApp.class);
}
@PostConstruct
public void afterInitialize() {
fooService.afterInitialize();
}
}

View File

@ -1,12 +0,0 @@
package org.baeldung.sampleabstract;
import org.springframework.stereotype.Component;
@Component
public class FooBean {
public String value() {
return "fooBean";
}
}

View File

@ -3,10 +3,10 @@ package org.baeldung.sampleabstract;
import org.springframework.stereotype.Component;
@Component
public class BarBean {
public class LogRepository {
public String value() {
return "barBean";
@Override
public String toString() {
return "logRepository";
}
}

View File

@ -3,10 +3,10 @@ package org.baeldung.sampleabstract;
import org.springframework.stereotype.Component;
@Component
public class FooBarBean {
public class RuleRepository {
public String value() {
return "fooBarBean";
@Override
public String toString() {
return "ruleRepository";
}
}