Baeldung eclipse formatter added.

This commit is contained in:
gschambial 2017-11-10 18:14:31 +05:30
parent 8c8af4e9bf
commit b2dead9484
30 changed files with 366 additions and 347 deletions

View File

@ -4,7 +4,7 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan(basePackages= { "com.baeldung.di.constructor.model.autowire" })
@ComponentScan(basePackages = { "com.baeldung.di.constructor.model.autowire" })
public class SpringAutowireConstructorContext {
}

View File

@ -9,20 +9,20 @@ import com.baeldung.di.constructor.model.bean.Processor;
@Configuration
public class SpringBeanConstructorContext {
@Bean
public Computer computer(){
return new Computer(processor(), memory());
}
@Bean
public Processor processor(){
return new Processor();
}
@Bean
public Memory memory(){
return new Memory();
}
@Bean
public Computer computer() {
return new Computer(processor(), memory());
}
@Bean
public Processor processor() {
return new Processor();
}
@Bean
public Memory memory() {
return new Memory();
}
}

View File

@ -9,20 +9,24 @@ import com.baeldung.di.constructor.model.autowire.Computer;
public class ComputerAutowireFactory {
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new AnnotationConfigApplicationContext(SpringAutowireConstructorContext.class);
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new AnnotationConfigApplicationContext(SpringAutowireConstructorContext.class);
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Constructor Injection via @Autowire------------------");
System.out.println("Processor cores : " + computer.getProcessor().getCores());
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
System.out.println("Memory format : " + computer.getMemory().getFormat());
System.out.println("---------------- Constructor Injection via @Autowire------------------");
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Constructor Injection via @Autowire------------------");
System.out.println("Processor cores : " + computer.getProcessor()
.getCores());
System.out.println("Processor frequency : " + computer.getProcessor()
.getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory()
.getSizeInGb());
System.out.println("Memory format : " + computer.getMemory()
.getFormat());
System.out.println("---------------- Constructor Injection via @Autowire------------------");
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
}

View File

@ -9,21 +9,25 @@ import com.baeldung.di.constructor.model.bean.Computer;
public class ComputerBeanFactory {
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new AnnotationConfigApplicationContext(SpringBeanConstructorContext.class);
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new AnnotationConfigApplicationContext(SpringBeanConstructorContext.class);
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Constructor Injection via @Bean ------------------");
System.out.println("Processor cores : " + computer.getProcessor().getCores());
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
System.out.println("Memory format : " + computer.getMemory().getFormat());
System.out.println("---------------- Constructor Injection via @Bean ------------------");
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Constructor Injection via @Bean ------------------");
System.out.println("Processor cores : " + computer.getProcessor()
.getCores());
System.out.println("Processor frequency : " + computer.getProcessor()
.getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory()
.getSizeInGb());
System.out.println("Memory format : " + computer.getMemory()
.getFormat());
System.out.println("---------------- Constructor Injection via @Bean ------------------");
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
}

View File

@ -6,26 +6,28 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.baeldung.di.constructor.model.xml.Computer;
public class ComputerXmlFactory {
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new ClassPathXmlApplicationContext("application-di-constructor-context.xml");
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new ClassPathXmlApplicationContext("application-di-constructor-context.xml");
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Constructor Injection via XML ------------------");
System.out.println("Processor cores : " + computer.getProcessor().getCores());
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
System.out.println("Memory format : " + computer.getMemory().getFormat());
System.out.println("---------------- Constructor Injection via XML ------------------");
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Constructor Injection via XML ------------------");
System.out.println("Processor cores : " + computer.getProcessor()
.getCores());
System.out.println("Processor frequency : " + computer.getProcessor()
.getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory()
.getSizeInGb());
System.out.println("Memory format : " + computer.getMemory()
.getFormat());
System.out.println("---------------- Constructor Injection via XML ------------------");
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
}

View File

@ -6,29 +6,29 @@ import org.springframework.stereotype.Component;
@Component
public class Computer {
private Processor processor;
private Memory memory;
private Processor processor;
private Memory memory;
@Autowired
public Computer(Processor processor, Memory memory) {
this.processor = processor;
this.memory = memory;
}
@Autowired
public Computer(Processor processor, Memory memory) {
this.processor = processor;
this.memory = memory;
}
public Processor getProcessor() {
return processor;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public Processor getProcessor() {
return processor;
}
public Memory getMemory() {
return memory;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
public Memory getMemory() {
return memory;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
}

View File

@ -5,15 +5,15 @@ import org.springframework.stereotype.Component;
@Component
public class Memory {
private Integer sizeInGb = 16;
private String format = "DDR3";
public Integer getSizeInGb() {
return sizeInGb;
}
private Integer sizeInGb = 16;
private String format = "DDR3";
public String getFormat() {
return format;
}
public Integer getSizeInGb() {
return sizeInGb;
}
public String getFormat() {
return format;
}
}

View File

@ -5,15 +5,15 @@ import org.springframework.stereotype.Component;
@Component
public class Processor {
private Integer cores = 2;
private Double frequency = 1.4;
private Integer cores = 2;
private Double frequency = 1.4;
public Integer getCores() {
return cores;
}
public Integer getCores() {
return cores;
}
public Double getFrequency() {
return frequency;
}
public Double getFrequency() {
return frequency;
}
}

View File

@ -2,28 +2,28 @@ package com.baeldung.di.constructor.model.bean;
public class Computer {
private Processor processor;
private Memory memory;
private Processor processor;
private Memory memory;
public Computer(Processor processor, Memory memory) {
this.processor = processor;
this.memory = memory;
}
public Computer(Processor processor, Memory memory) {
this.processor = processor;
this.memory = memory;
}
public Processor getProcessor() {
return processor;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public Processor getProcessor() {
return processor;
}
public Memory getMemory() {
return memory;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
public Memory getMemory() {
return memory;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
}

View File

@ -2,15 +2,15 @@ package com.baeldung.di.constructor.model.bean;
public class Memory {
private Integer sizeInGb = 16;
private String format = "DDR3";
public Integer getSizeInGb() {
return sizeInGb;
}
private Integer sizeInGb = 16;
private String format = "DDR3";
public String getFormat() {
return format;
}
public Integer getSizeInGb() {
return sizeInGb;
}
public String getFormat() {
return format;
}
}

View File

@ -2,15 +2,15 @@ package com.baeldung.di.constructor.model.bean;
public class Processor {
private Integer cores = 2;
private Double frequency = 1.4;
private Integer cores = 2;
private Double frequency = 1.4;
public Integer getCores() {
return cores;
}
public Integer getCores() {
return cores;
}
public Double getFrequency() {
return frequency;
}
public Double getFrequency() {
return frequency;
}
}

View File

@ -2,28 +2,28 @@ package com.baeldung.di.constructor.model.xml;
public class Computer {
private Processor processor;
private Memory memory;
private Processor processor;
private Memory memory;
public Computer(Processor processor, Memory memory) {
this.processor = processor;
this.memory = memory;
}
public Processor getProcessor() {
return processor;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public Computer(Processor processor, Memory memory) {
this.processor = processor;
this.memory = memory;
}
public Memory getMemory() {
return memory;
}
public Processor getProcessor() {
return processor;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public Memory getMemory() {
return memory;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
}

View File

@ -2,19 +2,19 @@ package com.baeldung.di.constructor.model.xml;
public class Memory {
private Integer sizeInGb = 16;
private String format = "DDR3";
private Integer sizeInGb = 16;
private String format = "DDR3";
public Memory() {
public Memory() {
}
}
public Integer getSizeInGb() {
return sizeInGb;
}
public Integer getSizeInGb() {
return sizeInGb;
}
public String getFormat() {
return format;
}
public String getFormat() {
return format;
}
}

View File

@ -2,15 +2,15 @@ package com.baeldung.di.constructor.model.xml;
public class Processor {
private Integer cores = 2;
private Double frequency = 1.4;
private Integer cores = 2;
private Double frequency = 1.4;
public Integer getCores() {
return cores;
}
public Integer getCores() {
return cores;
}
public Double getFrequency() {
return frequency;
}
public Double getFrequency() {
return frequency;
}
}

View File

@ -4,7 +4,7 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan(basePackages= { "com.baeldung.di.setter.model.autowire" })
@ComponentScan(basePackages = { "com.baeldung.di.setter.model.autowire" })
public class SpringAutowireSetterContext {
}

View File

@ -9,23 +9,23 @@ import com.baeldung.di.setter.model.bean.Processor;
@Configuration
public class SpringBeanSetterContext {
@Bean
public Computer computer(){
Computer computer = new Computer();
computer.setProcessor(processor());
computer.setMemory(memory());
return computer;
}
@Bean
public Processor processor(){
return new Processor();
}
@Bean
public Memory memory(){
return new Memory();
}
@Bean
public Computer computer() {
Computer computer = new Computer();
computer.setProcessor(processor());
computer.setMemory(memory());
return computer;
}
@Bean
public Processor processor() {
return new Processor();
}
@Bean
public Memory memory() {
return new Memory();
}
}

View File

@ -7,23 +7,26 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import com.baeldung.di.setter.config.SpringAutowireSetterContext;
import com.baeldung.di.setter.model.autowire.Computer;
public class ComputerAutowireFactory {
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new AnnotationConfigApplicationContext(SpringAutowireSetterContext.class);
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new AnnotationConfigApplicationContext(SpringAutowireSetterContext.class);
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Setter Injection via @Autowire ------------------");
System.out.println("Processor cores : " + computer.getProcessor().getCores());
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
System.out.println("Memory format : " + computer.getMemory().getFormat());
System.out.println("---------------- Setter Injection via @Autowire ------------------");
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Setter Injection via @Autowire ------------------");
System.out.println("Processor cores : " + computer.getProcessor()
.getCores());
System.out.println("Processor frequency : " + computer.getProcessor()
.getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory()
.getSizeInGb());
System.out.println("Memory format : " + computer.getMemory()
.getFormat());
System.out.println("---------------- Setter Injection via @Autowire ------------------");
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
}

View File

@ -7,24 +7,27 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import com.baeldung.di.setter.config.SpringBeanSetterContext;
import com.baeldung.di.setter.model.bean.Computer;
public class ComputerBeanFactory {
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new AnnotationConfigApplicationContext(SpringBeanSetterContext.class);
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new AnnotationConfigApplicationContext(SpringBeanSetterContext.class);
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Setter Injection via @Bean ------------------");
System.out.println("Processor cores : " + computer.getProcessor().getCores());
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
System.out.println("Memory format : " + computer.getMemory().getFormat());
System.out.println("---------------- Setter Injection via @Bean ------------------");
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Setter Injection via @Bean ------------------");
System.out.println("Processor cores : " + computer.getProcessor()
.getCores());
System.out.println("Processor frequency : " + computer.getProcessor()
.getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory()
.getSizeInGb());
System.out.println("Memory format : " + computer.getMemory()
.getFormat());
System.out.println("---------------- Setter Injection via @Bean ------------------");
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
}

View File

@ -6,25 +6,27 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.baeldung.di.setter.model.xml.Computer;
public class ComputerXmlFactory {
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new ClassPathXmlApplicationContext("application-setter-context.xml");
public static void main(String[] args) {
// Create Spring Application Context
ApplicationContext context = new ClassPathXmlApplicationContext("application-setter-context.xml");
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Setter Injection via XML ------------------");
System.out.println("Processor cores : " + computer.getProcessor().getCores());
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
System.out.println("Memory format : " + computer.getMemory().getFormat());
System.out.println("---------------- Setter Injection via XML ------------------");
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
// Get Spring bean "computer" created
Computer computer = (Computer) context.getBean("computer");
System.out.println("---------------- Setter Injection via XML ------------------");
System.out.println("Processor cores : " + computer.getProcessor()
.getCores());
System.out.println("Processor frequency : " + computer.getProcessor()
.getFrequency());
System.out.println("Memory Size in GB : " + computer.getMemory()
.getSizeInGb());
System.out.println("Memory format : " + computer.getMemory()
.getFormat());
System.out.println("---------------- Setter Injection via XML ------------------");
// Close Spring Application Context
((ConfigurableApplicationContext) context).close();
}
}

View File

@ -6,25 +6,25 @@ import org.springframework.stereotype.Component;
@Component
public class Computer {
private Processor processor;
private Memory memory;
private Processor processor;
private Memory memory;
public Processor getProcessor() {
return processor;
}
@Autowired
public void setProcessor(Processor processor) {
this.processor = processor;
}
public Processor getProcessor() {
return processor;
}
public Memory getMemory() {
return memory;
}
@Autowired
public void setMemory(Memory memory) {
this.memory = memory;
}
@Autowired
public void setProcessor(Processor processor) {
this.processor = processor;
}
public Memory getMemory() {
return memory;
}
@Autowired
public void setMemory(Memory memory) {
this.memory = memory;
}
}

View File

@ -5,15 +5,15 @@ import org.springframework.stereotype.Component;
@Component
public class Memory {
private Integer sizeInGb = 16;
private String format = "DDR3";
public Integer getSizeInGb() {
return sizeInGb;
}
private Integer sizeInGb = 16;
private String format = "DDR3";
public String getFormat() {
return format;
}
public Integer getSizeInGb() {
return sizeInGb;
}
public String getFormat() {
return format;
}
}

View File

@ -5,15 +5,15 @@ import org.springframework.stereotype.Component;
@Component
public class Processor {
private Integer cores = 2;
private Double frequency = 1.4;
private Integer cores = 2;
private Double frequency = 1.4;
public Integer getCores() {
return cores;
}
public Integer getCores() {
return cores;
}
public Double getFrequency() {
return frequency;
}
public Double getFrequency() {
return frequency;
}
}

View File

@ -2,23 +2,23 @@ package com.baeldung.di.setter.model.bean;
public class Computer {
private Processor processor;
private Memory memory;
private Processor processor;
private Memory memory;
public Processor getProcessor() {
return processor;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public Processor getProcessor() {
return processor;
}
public Memory getMemory() {
return memory;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public Memory getMemory() {
return memory;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
}

View File

@ -2,15 +2,16 @@ package com.baeldung.di.setter.model.bean;
public class Memory {
private Integer sizeInGb = 16;
private String format = "DDR3";
public Integer getSizeInGb() {
return sizeInGb;
}
private Integer sizeInGb = 16;
private String format = "DDR3";
public String getFormat() {
return format;
}
//
public Integer getSizeInGb() {
return sizeInGb;
}
public String getFormat() {
return format;
}
}

View File

@ -2,15 +2,15 @@ package com.baeldung.di.setter.model.bean;
public class Processor {
private Integer cores = 2;
private Double frequency = 1.4;
private Integer cores = 2;
private Double frequency = 1.4;
public Integer getCores() {
return cores;
}
public Integer getCores() {
return cores;
}
public Double getFrequency() {
return frequency;
}
public Double getFrequency() {
return frequency;
}
}

View File

@ -2,23 +2,23 @@ package com.baeldung.di.setter.model.xml;
public class Computer {
private Processor processor;
private Memory memory;
private Processor processor;
private Memory memory;
public Processor getProcessor() {
return processor;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public Processor getProcessor() {
return processor;
}
public Memory getMemory() {
return memory;
}
public void setProcessor(Processor processor) {
this.processor = processor;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
public Memory getMemory() {
return memory;
}
public void setMemory(Memory memory) {
this.memory = memory;
}
}

View File

@ -2,19 +2,19 @@ package com.baeldung.di.setter.model.xml;
public class Memory {
private Integer sizeInGb = 16;
private String format = "DDR3";
private Integer sizeInGb = 16;
private String format = "DDR3";
public Memory() {
public Memory() {
}
}
public Integer getSizeInGb() {
return sizeInGb;
}
public Integer getSizeInGb() {
return sizeInGb;
}
public String getFormat() {
return format;
}
public String getFormat() {
return format;
}
}

View File

@ -2,15 +2,15 @@ package com.baeldung.di.setter.model.xml;
public class Processor {
private Integer cores = 2;
private Double frequency = 1.4;
private Integer cores = 2;
private Double frequency = 1.4;
public Integer getCores() {
return cores;
}
public Integer getCores() {
return cores;
}
public Double getFrequency() {
return frequency;
}
public Double getFrequency() {
return frequency;
}
}

View File

@ -6,18 +6,18 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
">
<!-- Define your application beans here. They will be available to the beans
defined in your web-context because it is a sub-context. Beans defined in
the web-context will not be available in the application context. -->
<bean id="computer" class="com.baeldung.di.constructor.model.xml.Computer">
<constructor-arg ref="processor"/>
<constructor-arg ref="processor" />
<constructor-arg ref="memory" />
</bean>
<bean id="processor" class="com.baeldung.di.constructor.model.xml.Processor" />
<bean id="memory" class="com.baeldung.di.constructor.model.xml.Memory" />
</beans>

View File

@ -6,7 +6,7 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
">
<!-- Define your application beans here. They will be available to the beans
defined in your web-context because it is a sub-context. Beans defined in
the web-context will not be available in the application context. -->