Baeldung eclipse formatter added.
This commit is contained in:
parent
8c8af4e9bf
commit
b2dead9484
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
|
@ -11,17 +11,17 @@ import com.baeldung.di.constructor.model.bean.Processor;
|
|||
public class SpringBeanConstructorContext {
|
||||
|
||||
@Bean
|
||||
public Computer computer(){
|
||||
public Computer computer() {
|
||||
return new Computer(processor(), memory());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Processor processor(){
|
||||
public Processor processor() {
|
||||
return new Processor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Memory memory(){
|
||||
public Memory memory() {
|
||||
return new Memory();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,14 @@ public class ComputerAutowireFactory {
|
|||
// 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("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();
|
||||
|
|
|
@ -16,10 +16,14 @@ public class ComputerBeanFactory {
|
|||
// 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("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
|
||||
|
|
|
@ -6,8 +6,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|||
|
||||
import com.baeldung.di.constructor.model.xml.Computer;
|
||||
|
||||
|
||||
|
||||
public class ComputerXmlFactory {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -17,10 +15,14 @@ public class ComputerXmlFactory {
|
|||
// 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("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
|
||||
|
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.baeldung.di.setter.model.bean.Processor;
|
|||
public class SpringBeanSetterContext {
|
||||
|
||||
@Bean
|
||||
public Computer computer(){
|
||||
public Computer computer() {
|
||||
Computer computer = new Computer();
|
||||
computer.setProcessor(processor());
|
||||
computer.setMemory(memory());
|
||||
|
@ -19,12 +19,12 @@ public class SpringBeanSetterContext {
|
|||
}
|
||||
|
||||
@Bean
|
||||
public Processor processor(){
|
||||
public Processor processor() {
|
||||
return new Processor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Memory memory(){
|
||||
public Memory memory() {
|
||||
return new Memory();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ 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) {
|
||||
|
@ -17,10 +16,14 @@ public class ComputerAutowireFactory {
|
|||
// 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("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();
|
||||
|
|
|
@ -7,7 +7,6 @@ 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) {
|
||||
|
@ -17,10 +16,14 @@ public class ComputerBeanFactory {
|
|||
// 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("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
|
||||
|
|
|
@ -6,8 +6,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|||
|
||||
import com.baeldung.di.setter.model.xml.Computer;
|
||||
|
||||
|
||||
|
||||
public class ComputerXmlFactory {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -17,10 +15,14 @@ public class ComputerXmlFactory {
|
|||
// 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("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();
|
||||
|
|
|
@ -5,6 +5,7 @@ public class Memory {
|
|||
private Integer sizeInGb = 16;
|
||||
private String format = "DDR3";
|
||||
|
||||
//
|
||||
public Integer getSizeInGb() {
|
||||
return sizeInGb;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
<bean id="computer" class="com.baeldung.di.constructor.model.xml.Computer">
|
||||
<constructor-arg ref="processor"/>
|
||||
<constructor-arg ref="processor" />
|
||||
<constructor-arg ref="memory" />
|
||||
</bean>
|
||||
|
||||
|
|
Loading…
Reference in New Issue