At the Spring Experience, in several different sessions, there is quite a bit of coverage of different uses of annotations. I may have to update
my list.
One of the really interesting uses (maybe I'm just ignorant here) is to identify classes and methods to apply point cuts with AOP. This seems like the perfect use of meta-data. This one isn't necessarily a Spring thing, just cool.
The use of annotations in the MVC project have some good and bad. One good thing is the use of an annotation to identify a controller, rather than having the controller extend the
AbstractController. This means the class doesn't need to depend upon Spring classes. This should help preserve backward dependability (to your app) as the framework evolves.
Another cool thing is the ability to decide which method gets called by the value of a request parameter, via annotation. This changes to a more declarative model of programming that should make code easier to develop and much easier to test (less logic, less to test).
@RequestMapping(params = "action=delete")
public void removeSite(@RequestParam("site") String site,
&nbp;&nbp;&nbp;ActionResponse response) {
.
Then there is a scary part, using annotations to map URL patterns to controllers. This means the URL patterns will get scattered around the code base (hopefully in only one or two packages). The XML configuration isn't perfect but, personally, I'd like to see URL mappings in one place.
@RequestMapping("/myAction.do")
public void handleAction....
An interesting thing of the how annotations are used in Spring is in many places they help remove dependence on Spring classes and interfaces. "Use Spring but, don't
depend on it".
@PostContruct and
@PreDestroy (function are obvious from the name) are pretty cool.
@Resource both powerful AND dangerous (this one is for annotation driven dependency injection). Using this could make unit test more challenging.
@Autowired is a good way to reduce XML if auot wired beans don't scare you.
A little validation for my attitude with annotations. During Rod Johnson's presentation on The State of the Art Dependency Injection, he said that he like annotations but, not annotations that take strings (even the stuff in Spring). At least if I'm crazy, I'm not alone
:-) Update: reference to this post on DZone.
.
.
Labels: annotations, java, patterns, practices, spring, Spring Experience
It's that time of year again. I'm getting ready to attend the
Spring Experience conference.
Last year's was completely awesome. I learned sooo much and was completely worn out. There's nothing as good as crashing completely exhausted from learning so much.
Trying to decide which sessions to attend is always the hardest part. There are so many cases where I want to attend several simultaneously.
Here's my itinerary so far:
Thursday, 13 December
Five Aspects You Don't Know AboutWhat's New in Spring 2.5?Task-Focused Programming with Eclipse MylynThe State of the Art in Dependency InjectionRapid Fire: The Coherence Data GridFriday, 14 December
AspectJ for Spring DevelopersFocusing Enterprise Java Development: Mylyn and Spring IDEScale Out Your Spring Applications in 3 Simple StepsSpring Web Flow Hidden GemsSaturday, 15 December
Architecture Enforcement with AspectJ and Other ToolsRich Web FormsSpring OSGi UpdateFrom "Hello World" to Real World : Building Web Apps with Spring OSGiLots of good stuff. I'm really looking forward to the OSGi presentations. I've got a feeling that
OSGi may be the wave of the future for enterprise development. I expect the
Mylyn to be good to. I want to get Mylyn running at work but, first I've got to build a connector to the very old version of Bugzilla we use.
I recently
upgraded a project from Spring 2.0 to 2.5 so, I'm looking forward to learning about what other things I can do with it.
I'll keep updating the blog as the events progress.
Labels: community, continuing education, spring, Spring Experience
I'm about mid-stream on a project built using Maven2 and using the Spring Framework to glue it together.
The cool kids at
Spring Source, recently announce the release of Spring 2.5. It seems best to try to upgrade now while the project is still in development than later (and deal with extra QA requirements).
At first my thinking is this should be easy, go to the
maven repository and see what the latest versions are, edit my pom, and rebuilt the project and see what happens.
For the most part, it is that easy.
But, then there are the 'other' little things.
An issue, unrelated to Spring is
Open Smphony's OSCache. Updating from 2.3 to 2.4 introduces a dependency on JMS that can't be resolved. Why should an object caching system depend on JMS? If it must, why can't they define the damn POM correctly so the dependency can be found? Its the standard JMS api jar for crying out loud.
Anyway, back to Spring 2.5. Changes made:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>2.0.6</version>
<scope>compile</scope>
</dependency>
Becomes
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
Then:
mvn clean package is run, the test server started, and all appears well and good in the world.
Kudo's to the good folks at Spring Source. Backwards compatibility is a beautiful thing.
Update:I forgot to mention, the namespaces in the configuration files should get updated at some point as well. I didn't encounter any problems with the 2.0 namespaces and the 2.5 libraries. However, there are a few improvements, notably the JndiObjectFactoryBean, that are pretty darned useful.
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:cache="http://www.springmodules.org/schema/oscache"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springmodules.org/schema/oscache http://www.springmodules.org/schema/cache/springmodules-oscache.xsd" />
becomes
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:cache="http://www.springmodules.org/schema/oscache"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springmodules.org/schema/oscache http://www.springmodules.org/schema/cache/springmodules-oscache.xsd" />
WooHoo!
Now, if the Spring Modules guys could get their act together....
Labels: development, review, spring