|
| 1 | +package com.baeldung.config; |
| 2 | + |
| 3 | +import com.baeldung.Computer; |
| 4 | +import com.baeldung.model.*; |
| 5 | +import org.springframework.context.annotation.Bean; |
| 6 | +import org.springframework.context.annotation.Configuration; |
| 7 | + |
| 8 | +/** |
| 9 | + * Beans configuration. |
| 10 | + */ |
| 11 | +@Configuration |
| 12 | +public class AppConfig { |
| 13 | + |
| 14 | + @Bean(name = "computer") |
| 15 | + public Computer computer() { |
| 16 | + return new Computer(processor(), operatingSystem(), hardDisk()); |
| 17 | + } |
| 18 | + |
| 19 | + @Bean(name = "processor") |
| 20 | + public Processor processor() { |
| 21 | + Processor processor = new Processor(); |
| 22 | + processor.setName("Intel Core i7-6650U"); |
| 23 | + return processor; |
| 24 | + } |
| 25 | + |
| 26 | + @Bean(name = "hardDisk") |
| 27 | + public HardDisk hardDisk() { |
| 28 | + HardDisk hardDisk = new HardDisk(); |
| 29 | + hardDisk.setName("SSD TRANSCEND MTS400"); |
| 30 | + return hardDisk; |
| 31 | + } |
| 32 | + |
| 33 | + @Bean(name = "graphicsCard") |
| 34 | + public GraphicsCard graphicsCard() { |
| 35 | + GraphicsCard graphicsCard = new GraphicsCard(); |
| 36 | + graphicsCard.setName("NVIDIA GeForce GTX980M"); |
| 37 | + return graphicsCard; |
| 38 | + } |
| 39 | + |
| 40 | + @Bean(name = "operatingSystem") |
| 41 | + public OperatingSystem operatingSystem() { |
| 42 | + OperatingSystem operatingSystem = new OperatingSystem(); |
| 43 | + operatingSystem.setName("Windows 10 Pro"); |
| 44 | + return operatingSystem; |
| 45 | + } |
| 46 | + |
| 47 | + @Bean(name = "screen") |
| 48 | + public Screen screen() { |
| 49 | + Screen screen = new Screen(); |
| 50 | + screen.setSize("17 inches"); |
| 51 | + return screen; |
| 52 | + } |
| 53 | + |
| 54 | +} |
0 commit comments