Saturday, November 7, 2009

Spring Training -Day 1

Trainer : Oleg.zhurakousky@springsource.com

Spring deals with plumbing so that we can focus on domain problem.

We analyse what part Is business logic & what’s rest ?

Creation pattern - Strategy Pattern – Dependency Injection – Interface based.

Conventions over configuration – ex maven etc

Annotations – when dependency is mostly static , and also confusion can be solved using conventions.

Generic at compile time Vs runtime – This may be to support old Java runtimes

Implement FactoryBean – the getObject() – will give result whenever the bean is injected.

How to get factory itself - &<beanname> in property field.

FilePathXmlContex(“classpath:dhgadhs.xml”,c:/sdsd/sdsd/asds.xml); - classpath will ensure its searched in classpath for the first xml

Bean Life Cycle

BeanFactoryPostProcessor – just after dependency tree is constructed but before objects are created.Can change definition of any bean here.

One usecase would be propertyplaceholderconfigurer – to replace values with exact properties from file.

once configurer like placeholder is register it will be replaced with property files. - <context:property placeholder/>

<context:annotation-config/> - needs to be registered for annotations.

@Required - throws error if property is not set

Enforcing init method – by implementing initializingBean

Proxy – Decorator pattern

<bean class=”Org.springframework.beasn.factory.config.PropertyPlaceholderConfigurer” >

<property name=”location” value”…”/>

</bean>

With namespace – no need to remember the class

<context:property-placeholder location=””/>

Giving class as part of application context – helps identify where the xml is located

Bean Initilization (3 ways)

@PostConstruct ,init-method,implement interface initializingBean

Bean Post processor example - @Required – have to add contextannotation config

Destroying the application Context

ConfigurableApplicationContext.close()

Bean Destruction(3 ways)

@PreDestory,destroy-method,implement interface DisposableBean

Scopes – request and session makes sense only when they are in a web continer.

No comments:

 
Free Domain Names @ .co.nr!