Friday, January 18, 2013

Next stop - Spring 4.0

Spring will reach to 4.0 at the end of 2013. One of highlight features is new features of Java SE 8.0 and Java EE 7.0 will be supported. Included Lambda, JSR310 Date and Time, JMS 2.0, JPA 2.1, Bean Validation 1.1, Servlet 3.1, JCache and JSR356 WebSocket support. Another highlight feature is you will be able to write Spring configuration with Groovy-style.

Thursday, January 17, 2013

Preserve Whole Object


Sometimes you will obtain some data from an object to be parameters of a method. The problem is that if the method needs the new data from this object, you would have to look up and modify all of invocations to this method. So if you passed the whole object as the parameter to this method, you will avoid this problem.
And this refactoring (Preserve Whole Object) can also improve the readability.
And when you apply "Preserve Whole Object", you find the invoked method need a lot of attributes of this object. You need to consider use "Move Method" to do the code refactoring. So "Preserve Whole Object" can help you to know whether your code need to do "Move Method" refactoring.

Friday, January 11, 2013

@Resource, @Inject and @Autowired

@Resource is from JSR250 (Common Annotations for Java), when you write an app on Java EE platform, you can use @Resource to get reference from the container, like DataSource or SipFactory (from Sip Servlet) or something else you defined in your container. @Inject, it totally for DI, from JSR330 (Dependency Injection for Java). In Spring application, @Reource and @Inject and @Autowired are similar, but out of Spring, it will be another story.

Tuesday, January 8, 2013

Spring Migration Analyzer

If you want to migrate your application from JavaEE platform to Spring platform, you can use Spring Migration Analyzer to scan your app then get a suggestion report. The input of this tool is the byte package of your app, not the source package. And when you use SMA, you have to configure it. For example, you should tell SMA to exclude dependent jars of your project. For more information, go to SpringSource.org

Wednesday, January 2, 2013

How to run Tomcat7 Maven plugin

Yesterday when I studied Spring MVC showcase I found if you run "mvn tomcat:run", the async samples would not be successful. When I checked "pom.xml", I found it used old version Tomcat Maven plugin.

Loading ....

Then I change it to latest Tomcat Maven plugin. The artifact id is tomcat7-maven-plugin. (You can get it on search.maven.org, so I will not show the code.). Then run "mvn tomcat:run", but still failed. I found this plugin still use Tomcat6, not Tomcat7. Later, I tried "mvn tomcat7:run". Then I found this time the plugin used Tomcat7 run the application. So when you use Tomcat7 Maven plugin, you have to run "mvn tomcat7:run".