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;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages= { "com.baeldung.di.constructor.model.autowire" })
|
@ComponentScan(basePackages = { "com.baeldung.di.constructor.model.autowire" })
|
||||||
public class SpringAutowireConstructorContext {
|
public class SpringAutowireConstructorContext {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,17 +11,17 @@ import com.baeldung.di.constructor.model.bean.Processor;
|
|||||||
public class SpringBeanConstructorContext {
|
public class SpringBeanConstructorContext {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Computer computer(){
|
public Computer computer() {
|
||||||
return new Computer(processor(), memory());
|
return new Computer(processor(), memory());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Processor processor(){
|
public Processor processor() {
|
||||||
return new Processor();
|
return new Processor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Memory memory(){
|
public Memory memory() {
|
||||||
return new Memory();
|
return new Memory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,10 +16,14 @@ public class ComputerAutowireFactory {
|
|||||||
// Get Spring bean "computer" created
|
// Get Spring bean "computer" created
|
||||||
Computer computer = (Computer) context.getBean("computer");
|
Computer computer = (Computer) context.getBean("computer");
|
||||||
System.out.println("---------------- Constructor Injection via @Autowire------------------");
|
System.out.println("---------------- Constructor Injection via @Autowire------------------");
|
||||||
System.out.println("Processor cores : " + computer.getProcessor().getCores());
|
System.out.println("Processor cores : " + computer.getProcessor()
|
||||||
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
|
.getCores());
|
||||||
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
|
System.out.println("Processor frequency : " + computer.getProcessor()
|
||||||
System.out.println("Memory format : " + computer.getMemory().getFormat());
|
.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------------------");
|
System.out.println("---------------- Constructor Injection via @Autowire------------------");
|
||||||
// Close Spring Application Context
|
// Close Spring Application Context
|
||||||
((ConfigurableApplicationContext) context).close();
|
((ConfigurableApplicationContext) context).close();
|
||||||
|
@ -16,10 +16,14 @@ public class ComputerBeanFactory {
|
|||||||
// Get Spring bean "computer" created
|
// Get Spring bean "computer" created
|
||||||
Computer computer = (Computer) context.getBean("computer");
|
Computer computer = (Computer) context.getBean("computer");
|
||||||
System.out.println("---------------- Constructor Injection via @Bean ------------------");
|
System.out.println("---------------- Constructor Injection via @Bean ------------------");
|
||||||
System.out.println("Processor cores : " + computer.getProcessor().getCores());
|
System.out.println("Processor cores : " + computer.getProcessor()
|
||||||
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
|
.getCores());
|
||||||
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
|
System.out.println("Processor frequency : " + computer.getProcessor()
|
||||||
System.out.println("Memory format : " + computer.getMemory().getFormat());
|
.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 ------------------");
|
System.out.println("---------------- Constructor Injection via @Bean ------------------");
|
||||||
|
|
||||||
// Close Spring Application Context
|
// Close Spring Application Context
|
||||||
|
@ -6,8 +6,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|||||||
|
|
||||||
import com.baeldung.di.constructor.model.xml.Computer;
|
import com.baeldung.di.constructor.model.xml.Computer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ComputerXmlFactory {
|
public class ComputerXmlFactory {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -17,10 +15,14 @@ public class ComputerXmlFactory {
|
|||||||
// Get Spring bean "computer" created
|
// Get Spring bean "computer" created
|
||||||
Computer computer = (Computer) context.getBean("computer");
|
Computer computer = (Computer) context.getBean("computer");
|
||||||
System.out.println("---------------- Constructor Injection via XML ------------------");
|
System.out.println("---------------- Constructor Injection via XML ------------------");
|
||||||
System.out.println("Processor cores : " + computer.getProcessor().getCores());
|
System.out.println("Processor cores : " + computer.getProcessor()
|
||||||
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
|
.getCores());
|
||||||
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
|
System.out.println("Processor frequency : " + computer.getProcessor()
|
||||||
System.out.println("Memory format : " + computer.getMemory().getFormat());
|
.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 ------------------");
|
System.out.println("---------------- Constructor Injection via XML ------------------");
|
||||||
|
|
||||||
// Close Spring Application Context
|
// Close Spring Application Context
|
||||||
|
@ -4,7 +4,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages= { "com.baeldung.di.setter.model.autowire" })
|
@ComponentScan(basePackages = { "com.baeldung.di.setter.model.autowire" })
|
||||||
public class SpringAutowireSetterContext {
|
public class SpringAutowireSetterContext {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import com.baeldung.di.setter.model.bean.Processor;
|
|||||||
public class SpringBeanSetterContext {
|
public class SpringBeanSetterContext {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Computer computer(){
|
public Computer computer() {
|
||||||
Computer computer = new Computer();
|
Computer computer = new Computer();
|
||||||
computer.setProcessor(processor());
|
computer.setProcessor(processor());
|
||||||
computer.setMemory(memory());
|
computer.setMemory(memory());
|
||||||
@ -19,12 +19,12 @@ public class SpringBeanSetterContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Processor processor(){
|
public Processor processor() {
|
||||||
return new Processor();
|
return new Processor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Memory memory(){
|
public Memory memory() {
|
||||||
return new 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.config.SpringAutowireSetterContext;
|
||||||
import com.baeldung.di.setter.model.autowire.Computer;
|
import com.baeldung.di.setter.model.autowire.Computer;
|
||||||
|
|
||||||
|
|
||||||
public class ComputerAutowireFactory {
|
public class ComputerAutowireFactory {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -17,10 +16,14 @@ public class ComputerAutowireFactory {
|
|||||||
// Get Spring bean "computer" created
|
// Get Spring bean "computer" created
|
||||||
Computer computer = (Computer) context.getBean("computer");
|
Computer computer = (Computer) context.getBean("computer");
|
||||||
System.out.println("---------------- Setter Injection via @Autowire ------------------");
|
System.out.println("---------------- Setter Injection via @Autowire ------------------");
|
||||||
System.out.println("Processor cores : " + computer.getProcessor().getCores());
|
System.out.println("Processor cores : " + computer.getProcessor()
|
||||||
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
|
.getCores());
|
||||||
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
|
System.out.println("Processor frequency : " + computer.getProcessor()
|
||||||
System.out.println("Memory format : " + computer.getMemory().getFormat());
|
.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 ------------------");
|
System.out.println("---------------- Setter Injection via @Autowire ------------------");
|
||||||
// Close Spring Application Context
|
// Close Spring Application Context
|
||||||
((ConfigurableApplicationContext) context).close();
|
((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.config.SpringBeanSetterContext;
|
||||||
import com.baeldung.di.setter.model.bean.Computer;
|
import com.baeldung.di.setter.model.bean.Computer;
|
||||||
|
|
||||||
|
|
||||||
public class ComputerBeanFactory {
|
public class ComputerBeanFactory {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -17,10 +16,14 @@ public class ComputerBeanFactory {
|
|||||||
// Get Spring bean "computer" created
|
// Get Spring bean "computer" created
|
||||||
Computer computer = (Computer) context.getBean("computer");
|
Computer computer = (Computer) context.getBean("computer");
|
||||||
System.out.println("---------------- Setter Injection via @Bean ------------------");
|
System.out.println("---------------- Setter Injection via @Bean ------------------");
|
||||||
System.out.println("Processor cores : " + computer.getProcessor().getCores());
|
System.out.println("Processor cores : " + computer.getProcessor()
|
||||||
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
|
.getCores());
|
||||||
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
|
System.out.println("Processor frequency : " + computer.getProcessor()
|
||||||
System.out.println("Memory format : " + computer.getMemory().getFormat());
|
.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 ------------------");
|
System.out.println("---------------- Setter Injection via @Bean ------------------");
|
||||||
|
|
||||||
// Close Spring Application Context
|
// Close Spring Application Context
|
||||||
|
@ -6,8 +6,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|||||||
|
|
||||||
import com.baeldung.di.setter.model.xml.Computer;
|
import com.baeldung.di.setter.model.xml.Computer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ComputerXmlFactory {
|
public class ComputerXmlFactory {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -17,10 +15,14 @@ public class ComputerXmlFactory {
|
|||||||
// Get Spring bean "computer" created
|
// Get Spring bean "computer" created
|
||||||
Computer computer = (Computer) context.getBean("computer");
|
Computer computer = (Computer) context.getBean("computer");
|
||||||
System.out.println("---------------- Setter Injection via XML ------------------");
|
System.out.println("---------------- Setter Injection via XML ------------------");
|
||||||
System.out.println("Processor cores : " + computer.getProcessor().getCores());
|
System.out.println("Processor cores : " + computer.getProcessor()
|
||||||
System.out.println("Processor frequency : " + computer.getProcessor().getFrequency());
|
.getCores());
|
||||||
System.out.println("Memory Size in GB : " + computer.getMemory().getSizeInGb());
|
System.out.println("Processor frequency : " + computer.getProcessor()
|
||||||
System.out.println("Memory format : " + computer.getMemory().getFormat());
|
.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 ------------------");
|
System.out.println("---------------- Setter Injection via XML ------------------");
|
||||||
// Close Spring Application Context
|
// Close Spring Application Context
|
||||||
((ConfigurableApplicationContext) context).close();
|
((ConfigurableApplicationContext) context).close();
|
||||||
|
@ -5,6 +5,7 @@ public class Memory {
|
|||||||
private Integer sizeInGb = 16;
|
private Integer sizeInGb = 16;
|
||||||
private String format = "DDR3";
|
private String format = "DDR3";
|
||||||
|
|
||||||
|
//
|
||||||
public Integer getSizeInGb() {
|
public Integer getSizeInGb() {
|
||||||
return sizeInGb;
|
return sizeInGb;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<bean id="computer" class="com.baeldung.di.constructor.model.xml.Computer">
|
<bean id="computer" class="com.baeldung.di.constructor.model.xml.Computer">
|
||||||
<constructor-arg ref="processor"/>
|
<constructor-arg ref="processor" />
|
||||||
<constructor-arg ref="memory" />
|
<constructor-arg ref="memory" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user