Wednesday, May 02, 2012

Review: Java Brains Spring Framework - Core Spring, by Koushik Kothagal

I've recently watched the subject Java Brains - Spring Framework video tutorials and I must admit that these screencasts were well done. One of the best Java related video tutorials I've ever seen. Whether you are experienced or beginner developer it worth to watch them all. It's very good sample how to produce qualitative and pleasure to watch screencasts.

Let's review each tutorial one-by-one just to have some snapshot what was described there:

01 - Understanding Dependency Injection Dependency Injection (DI) introduction. Here was explained why do we need DI and some conceptual sample.

02 - Setting Up Project Setup. The author avoided using any build tools (Ant, Maven) and set up Eclipse-based project via using Eclipse User Library.

03 - Understanding Spring Bean Factory Explained the differences between Factory pattern and Spring Bean Factory without any technical details, plain conceptual overview.

04 - Writing Code Using the Bean Factory Actually it's the first video with some code inside. Author use classical approach to introduce Spring DI in practice - wrote simple code without Spring and re-wrote it with Spring. And it has nice effect - it became very descriptive.
The next Spring-related things were introduced:
  • spring.xml
  • BeanFactory
  • XmlBeanFactory and FileSystemResources
  • bean instantiation via factory
05 - ApplicationContext and Property Initialization Replaced BeanFactory with ApplicationContext. How to initialize bean property via spring.xml has been shown.

06 - Using Constructor Injection Depicted different ways of constructor injection:
  • plain
  • index based
  • type based
07 - Injecting Objects Created simple object and shown how to inject object dependency (i.e. was used  "property" tag and "ref" attribute, <property name="propname" ref="beanref" />

08 - Inner Beans, Aliases and idref The topic has pretty descriptive content, nothing more was here.

09 - Initializing Collections Here List was used as sample to initialize bean with collection. Stated that the same approach should be applied to Set and Map.

10 - Bean Autowiring Configured autowiring via spring.xml. Described pros&cons:
  • byName
  • byType
  • constructor
11 - Understanding Bean Scopes Explained bean scopes:
  • Singleton
  • Prototype
  • Request
  • Session
  • Global Session
12 - Using ApplicationContextAware Nicely shown how to use ApplicationAwareContext and BeanNameAware interfaces.

13 - Bean Definition Inheritance Nice Spring feature is bean definition inheritance and how it is different from OOP inheritance. Explained when to use it and what is the benefits. Introduced bean abstract and  parent attributes and when to use it.

14 - Lifecycle Callbacks Introduced init and destroy methods in different incarnations:
  • InitializingBean and DisposableBean interfaces
  • bean tag attributes: init-method and destroy-method
  • beans tag attributes: default-init-method and default-destroy-method
  • Added AbstractApplicationCantext to switch on redisterShutdownHook()
15 - Writing a BeanPostProcessor Shown how to implement custom BeanPostProcessor

16 - Writing a BeanFactoryPostProcessor Shown how to implement:
  • custom BeanFactoryPostProcessor
  • introduces properties for spring.xml via adding PropertyPlaceholderConfigurer (implementation of BeanFactoryPostProcessor)
Explained when and why to use BeanFactoryPostProcessors. Explained the differences between BeanFactoryPostProcessors and BeanPostProcessor.

17 - Coding To Interfaces Rewritten the initial demo project to support interface based design, the right way for developing Spring applications :-)

18 - Introduction to Annotations and the Required Annotation Added @Required annotation in demo project and activated it via adding bean post processor RequiredAnnotationBeanPostProcessor.

19 - The Autowired Annotation Shown how to use:
  • @Autowire and @Qualifier annotations
  • <context:annotation-config /> in spring.xml
20 - Some JSR-250 Annotations Shown how to use:
  • @Resource annotation
  • @Resource annotation with parameters
  • @PostConstruct annotation
  • @PreDestroy annotation
21 - Component and Stereotype Annotations Added the <context:component-scan base-packaeg="package" /> to spring.xml. Shown how to use @Component annotation and what rules applied to this annotation. Also, were mentioned other Spring stereotypes.

22 - Using MessageSource To Get Text From Property Files Shown how to use ResourceBundleMessageSource to get properties.

23 - Event Handling in Spring Very nice introduction tutorial into the subject: even definition, event listeners and even publishing on application level.

Ofcource, these tutorial are only intro and you should read Spring Documentation to gain the Spring "black" magic. But, it's good start point.