There are many coverage code tool such as Emma, Cobertura, Clover.

So I choose EMMA because :

– It is open source

– Have plugin for Eclipse IDE and Maven.

Advertisements

1.Atomicity : A transaction should be all or nothing.If it fails to complete, the database will be left as if none of operations had ever been performed — known as rollback.

2.Consistency: A transaction should be incapable of breaking any rules defined for database.For example, foreign key must be obeyed.If for some reason this is impossible, the transaction will be rollback.

3.Isolation: The effects of the transaction will be completely invisible to all another transactions until it has completed successfully.This guarantees that the transaction will always see the data in a sensible state.

4.Durability: The data should retained intact. If the system fails for any reason, it should be always be possible to retrieve the database up to the moment of failure.

from Pro Hibernate Book.

Before use it .You have to register an AutowiredAnnotationBeanPostProcessor instance in the IOC container.

-Have two way to register:

1. <context:annotation-config>

2. <bean class=”org.springframework.beans

.factory.annotation.AutowiredAnnotationBeanPostProcessor” />

Different  between @Autowired and @Resource:

– @Autowired wires by Type and specified by Spring . If you want to use wires by Name . Add @Qualifier.

-@Resource wires by Name and specified by Java

Spring provides two type of Spring IOC container : BeanFactory and ApplicationContext.

Bean Factory

  • Bean instantiation/wiring

Application Context

  • Bean instantiation/wiring
  • Automatic BeanPostProcessor registration
  • Automatic BeanFactoryPostProcessor registration
  • Convenient MessageSource access (for i18n)
  • ApplicationEvent publication

Before (Spring 2.0 and earlier):

<bean id="propertyConfigurer">
 <property name="location">
  <value>file:${user.home}/env.properties</value>
 </property>
</bean>

After (Spring 2.5):

1.Loading 1 property file:

<context:property-placeholder location=”file:${user.home}/env.properties”/>

2.Loading multiple properties files:

<bean class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>

<property name=”locations”>

<list>
<value>classpath:file1</value>
<value>classpath:file2</value>
</list>

</property>

</bean>

*Other property:

-ignoreResourceNotFound

-ignoreUnresolvablePlaceholders

Spring application context loading tricks
By Ben, on May 13th, 2008
The Spring classpath:-notation

As most of you probably know, the Spring Framework can load all sorts of resources into its application context from all sorts of sources. Especially it can do this from the classpath and the people over at SpringSource have even introduced their own URI “protocol” to make this easy: you can identify resources using the classpath-URIs, like so:

classpath:

Most of you are probably familiar with this notation, because it is often used when loading the application context files themselves using the ContextLoaderListener.

What many people don’t realize, is that the classpath:-notation is far more versatile than just for use as a standard URI, because you can use wildcards. In fact I only recently learned this myself from a colleague (at least in part) — which is kind of dumb, because it’s mentioned quite clearly in the documentation.

The first thing you can do above and beyond loading resources by their full path (relative to the classpath) is use all the Ant-style wildcards. So instead of loading as follows:

contextConfigLocation

classpath:businessContext.xml
classpath:persistenceContext.xml
classpath:webFlowBeansContext.xml
classpath:etc.

you can simply load as follows:

contextConfigLocation

classpath:*Context.xml

or, as the case may be:

contextConfigLocation

classpath:**/*Context.xml

There is a catch to this strategy, however: if you have multiple resource repositories (directories, databases, online resources, whatever) on your classpath containing files that match your wildcard pattern, Spring will only look for matching resources in one of these locations. To illustrate this for yourself, try using maven to create a standard project structure, then put a context file in src/main/resources and src/test/resources and try to load both at the same time with a wildcard — you’ll only get one.

The classpath*:-notation

Of course the Spring guys wouldn’t be the Spring guys if they didn’t have a simple solution for this problem. It’s called the classpath*:-notation. Simply put, if you rewrite the snippet from above like so:

contextConfigLocation

classpath*:**/*Context.xml

then Spring will load every matching context file from the entire classpath.

As the documentation points out, the combination of the classpath*:-notation with Ant-style wildcards makes it possible to organize your application into a neat component-assembly style: you can put all the code for each individual problem from your problem domain into its own component (a jar, say) and then “slot” as many jars into place as you like to make your application. You can even add components later on without making major adjustments to any other component (if you think about it carefully). Just make sure each component has an application context file that follows the general naming schema. Think of the possibilities if you include OSGi or even the new Service Provider spec.

Caveat emptor

There is a very specific sort of naming pattern that you can also create using the classpath*:-notation. This is the naming pattern whereby all application context files within the application have exactly the same name (e.g. classpath*:myAppContext.xml). This pattern allows you to expand your context completely transparently to all others without even having to think very hard about the naming convention.

DO NOT EVER, EVER, EVER, EVER, EVER, EVER, EVER, EVER, EVER, EVER, EVER, EVER DO THIS!!!

If you give all your context files the same name, you lose precise control over what gets loaded and what doesn’t. This can hurt if you create components that you want to reuse across applications (especially if you are using Maven and have transitive dependenciesto deal with) and it can hurt in creating integration tests that involve partially loaded contexts. It also makes it harder to find naming conflicts in your contexts if you introduce them accidentally (especially if you are not the only developer on your project). Always make sure each context file on the classpath has a unique name!
Conclusion

The Spring Framework includes a very flexible notation for loading resources from the classpath, using wildcards to identify resources. This notation, if used correctly, gives you considerable freedom in creating component-assembly style applications. However, you must still guard against using unwise naming of your context files.