Stream API: last Stream element example refactor (#1943)

* Refactor

* Delete ApplicationContextTestBeanInjectionTypes.java

* Delete BeanInjectionJavaConfigIntegrationTest.java

* Delete BeanInjectionXMLConfigIntegrationTest.java
This commit is contained in:
Grzegorz Piwowarek
2017-06-03 20:49:56 +02:00
committed by GitHub
parent b840f15629
commit a5d5460a9f
22 changed files with 11 additions and 531 deletions
@@ -1,17 +0,0 @@
package com.baeldung.beaninjection;
public class AnotherSampleDAOBean implements IAnotherSampleDAO {
private String propertyY;
public AnotherSampleDAOBean(String propertyY) {
this.propertyY = propertyY;
}
// standard setters and getters
public String getPropertyY() {
return propertyY;
}
}
@@ -1,39 +0,0 @@
package com.baeldung.beaninjection;
import java.util.List;
public class ExampleDAOBean implements IExampleDAO {
private String propertyX;
public ExampleDAOBean(String propertyX) {
this.propertyX = propertyX;
}
public String getPropertyX() {
return propertyX;
}
public void setPropertyX(String propertyX) {
this.propertyX = propertyX;
}
@Override
public List<SampleDomainObject> getDomainList() {
// TODO Auto-generated method stub
return null;
}
@Override
public SampleDomainObject createNewDomain(SampleDomainObject inputDomain) {
// TODO Auto-generated method stub
return null;
}
@Override
public SampleDomainObject getSomeDomain() {
// TODO Auto-generated method stub
return new SampleDomainObject();
}
}
@@ -1,47 +0,0 @@
package com.baeldung.beaninjection;
import java.util.List;
public class ExampleServiceBean implements IExampleService {
private IExampleDAO exampleDAO;
private IAnotherSampleDAO anotherSampleDAO;
public ExampleServiceBean(IExampleDAO exampleDAO) {
this.exampleDAO = exampleDAO;
}
public void setAnotherSampleDAO(IAnotherSampleDAO anotherSampleDAO) {
this.anotherSampleDAO = anotherSampleDAO;
}
// standard setters and getters
public IAnotherSampleDAO getAnotherSampleDAO() {
return anotherSampleDAO;
}
public void setExampleDAO(ExampleDAOBean exampleDAO) {
this.exampleDAO = exampleDAO;
}
public IExampleDAO getExampleDAO() {
return exampleDAO;
}
private String propertyX;
public String getPropertyX() {
return propertyX;
}
public void setPropertyX(String propertyX) {
this.propertyX = propertyX;
}
public List<SampleDomainObject> serviceMethodX() {
/*get domain list from DAO .. business logic on domain objects..return*/
return exampleDAO.getDomainList();
}
}
@@ -1,19 +0,0 @@
package com.baeldung.beaninjection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class FileReader {
@Autowired
private Location location;
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
}
@@ -1,28 +0,0 @@
package com.baeldung.beaninjection;
public class FtpReader {
private String ftpHost = null;
private Integer ftpPort = null;
// Constructor with arguments
public FtpReader(String host, Integer port) {
this.ftpHost = host;
this.ftpPort = port;
}
public String getFtpHost() {
return ftpHost;
}
public void setFtpHost(String ftpHost) {
this.ftpHost = ftpHost;
}
public Integer getFtpPort() {
return ftpPort;
}
public void setFtpPort(Integer ftpPort) {
this.ftpPort = ftpPort;
}
}
@@ -1,5 +0,0 @@
package com.baeldung.beaninjection;
public interface IAnotherSampleDAO {
}
@@ -1,12 +0,0 @@
package com.baeldung.beaninjection;
import java.util.List;
public interface IExampleDAO {
List<SampleDomainObject> getDomainList();
SampleDomainObject createNewDomain(SampleDomainObject domainObject);
SampleDomainObject getSomeDomain();
}
@@ -1,9 +0,0 @@
package com.baeldung.beaninjection;
import java.util.List;
public interface IExampleService {
List<SampleDomainObject> serviceMethodX();
}
@@ -1,17 +0,0 @@
package com.baeldung.beaninjection;
import org.springframework.stereotype.Component;
@Component
public class Location {
private String filePath;
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
}
@@ -1,15 +0,0 @@
package com.baeldung.beaninjection;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan(basePackages = { "com.baeldung.beaninjection" })
public class ReaderApplicationConfig {
@Bean
public FtpReader exampleDAO() {
return new FtpReader("localhost", 21);
}
}
@@ -1,33 +0,0 @@
package com.baeldung.beaninjection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ReaderManager {
private FileReader fileReader;
private FtpReader ftpReader;
@Autowired
public ReaderManager(FtpReader ftpReader) {
this.ftpReader = ftpReader;
}
@Autowired
public void setFileReader(FileReader fileReader) {
this.fileReader = fileReader;
}
public FileReader getFileReader() {
return fileReader;
}
public void setFtpReader(FtpReader ftpReader) {
this.ftpReader = ftpReader;
}
public FtpReader getFtpReader() {
return ftpReader;
}
}
@@ -1,14 +0,0 @@
package com.baeldung.beaninjection;
public class ReaderService {
private FtpReader ftpReader;
public void setFtpReader(FtpReader reader) {
this.ftpReader = reader;
}
public FtpReader getFtpReader() {
return ftpReader;
}
}
@@ -1,31 +0,0 @@
package com.baeldung.beaninjection;
import java.io.Serializable;
public class SampleDomainObject implements Serializable {
/**
*
*/
private static final long serialVersionUID = 449859763481296747L;
private String domainPropX;
private String domainPropY;
public String getDomainPropX() {
return domainPropX;
}
public void setDomainPropX(String domainPropX) {
this.domainPropX = domainPropX;
}
public String getDomainPropY() {
return domainPropY;
}
public void setDomainPropY(String domainPropY) {
this.domainPropY = domainPropY;
}
}
@@ -1,36 +0,0 @@
package com.baeldung.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import com.baeldung.beaninjection.AnotherSampleDAOBean;
import com.baeldung.beaninjection.ExampleDAOBean;
import com.baeldung.beaninjection.ExampleServiceBean;
import com.baeldung.beaninjection.IAnotherSampleDAO;
import com.baeldung.beaninjection.IExampleDAO;
import com.baeldung.beaninjection.IExampleService;
@Configuration
@ComponentScan(basePackages = { "com.baeldung.beaninjection" })
public class ApplicationContextTestBeanInjectionTypes {
@Bean
public IExampleDAO exampleDAO() {
return new ExampleDAOBean("Mandatory DAO Property X");
}
@Bean
public IExampleService exampleServiceBean() {
ExampleServiceBean serviceBean = new ExampleServiceBean(exampleDAO());
serviceBean.setAnotherSampleDAO(anotherSampleDAO());
serviceBean.setPropertyX("Some Service Property X");
return serviceBean;
}
@Bean
public IAnotherSampleDAO anotherSampleDAO() {
return new AnotherSampleDAOBean("Mandatory DAO Property Y");
}
}