Based on "Spring Framework: Spring Fundamentals", a Pluralsight course by Bryan Hansen.
- JEE Blueprints
- WORA (write once, run anywhere)
- Hardcoded
- AppConfig
- @Configuration
- @Bean
- Setter & Constructor injection
- Singleton
- Prototype
- Request
- Session
- GlobalSession
@Scope(value = BeanDefinition.SCOPE_SINGLETON)
-
@Autowired
-
Stereotypes
- @Component
- @Repository
- @Service
- @Controller
- ...
- Instantiation
- Populate Properties
- BeanNameAware
- BeanFactoryAware
- Pre Initialization - BeanPostProcessors
- InitializeBean
- initMethod
- Post Initialization - BeanPostProcessors
- @PostConstruct
- @PreDestroy
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
- Builds on initMethod concept
- Factory Method Pattern
- Legacy Code
- Contract without Constructor
- Static Methods
Spring Expression Language is used for:
- Manipulate Object Graph
- Evaluate at Runtime
- Configuration
Spring utilizes proxies.
ProxyFactory factory = new ProxyFactory(new SimplePojo());
factory.addInterface(Pojo.class);
factory.addAvice(new RetryAdvice());
factory.setExposeProxy(true);
Pojo pojo = (Pojo) factory.getProxy();
// This is a method call on the proxy
pojo.foo();
- Adapt Environments
- Runtime Configuration
@Profile("dev")
VMOptions: -Dspring.profiles.active=dev