Archive for December 8th, 2005
Talks by Jurgen
Jurgen Hoeller gave a talk about 10 Cool Spring Features You Might Not Be Aware Of. I was somewhat familiar with most of them, especially the native JDBC connection and CLOB functionality, which I’ll talk about more during this session. There were two features that I was not aware of that look interesting for our application.
The first is lazy JDBC connections. This is a feature where a DataSource is wrapped in a DataSource implementation that returns a proxy for getConnection() instead of a real connection. This proxy will only get a real connection when it is needed. The use case for this is declarative transactions (using local transactions, not JTA) where the data that is being requested by the caller is cached. The declarative transaction manager gets a connection, turns off auto commit (although I think this depends on the environment), and starts the transaction. When the service method is done, the connection is committed. However, if the data being returned by the service is in cache, then we have made up to 3 calls to the database that were not needed. In high volume applications this can add up to a lot of overhead, especially depending on the level of isolation configured for the database connection.
The other interesting feature is the Task Executor. This is meant for launching functionality that should be executed asynchronously. They provide several implementations, including ones based on java.util.Timer, the JDK 1.5 concurrent library, and CommonJ WorkManager for WAS and WebLogic. The latter would be required if the application uses EJBs since EJBs can’t launch new threads (or at least they’re not supposed to). If needed, implementations could be provided for other EJB containers such as JBoss, but I suspect that most Spring applications are being deployed as WARs anyway which makes it a moot point.
After the talk I spoke to Jurgen about providing a JMS Invoker for JMS based remoting. I submitted an implementation before realizing that an implementation already existed in the sandbox. However, my solution performs serialization manually and uses BytesMessage instead of ObjectMessage because Tibco has issues serializing primitives. I would be interested in seeing a JMS remoting solution in Spring, and the JIRA issue was marked for Spring 1.3 (which is now Spring 2.0). I do know about the existence of Lingo so I suppose it is possible that this would be the JMS remoting solution instead of rolling it into the main project.
Speaking of Jurgen, he gave the keynote speech after dinner. The topic was “Spring’s Nature,” where he was talking about the characteristics and philosophy of Spring. Some highlights:
- Spring is very modular, and separation of components is taken very seriously
- It covers many different areas, but the design is very consistent
- Some subsystems are so independent that they effectively are libraries
- Implementation classes are considered part of the public API
- Many hooks are provided for easy customization
Spring is analogous to an ice floe: has broad coverage but is very shallow. Spring provides integration hooks for many things, but it does not provide anything that already has a good solution (such as ORM). J2EE is more like an iceberg: only a part of it is visible, but there is a lot that is hidden from view.
Notes on the expert panel
After lunch we had the expert panel taking questions from attendees. The first question was about domain models and the role that they play in application architecture. In particular, the term Anemic Domain Model was tossed around. To paraphrase Martin Fowler, this happens when a domain model exists but does not contain any behavior; instead the behavior is defined in the service layer. Using the service layer instead of the domain layer for behavior is more procedural than OO. The hard core OO crowd is not too thrilled about this, especially for complicated apps that could benefit from a strong OO model. However there are some real world constraints that make this architecture difficult. One roadblock is that it is difficult to do dependency injection on domain objects, especially when they are created with an ORM tool or with the new operator. Another example is with Apache digester: we have an application that creates domain objects based on an XML stream, and these objects have behaviors that require DAO access. The only real way to do this right now with Spring is to have a static reference to the bean factory. (Yes, this is a really ugly hack) However, with the improved AspectJ integration that is going into Spring 2.0, performing DI on domain objects will be much easier. This will allow domain objects access to the DAO or services layer, which should make it easier to associate behavior with them.
Another discussion was started about using annotations and whether frameworks that rely on them should be considered “light weight” since the annotations tie them directly to the framework. This question got Rod on his soapbox about why using annotations for configuration are not such a good idea. This reminded me of a posting by Craig Wells on this topic a few days ago. The argument is that annotations are meant for class level configuration, not object based configuration. If configuration is set up in the Java class file, then it becomes very difficult to configure individual instances of that class.
I have not had the chance to move our middle tier to Java 5 yet, so I do not have much experience with annotations. However, I do have to say that I tend to agree with this idea. In our project, we have an entire layer of mock DAOs that we swap during testing to test our service layer. Since these configurations are defined externally via XML, we’re able to swap out DAO implementations for our services without affecting the services at all. I suspect this would be more difficult with annotations since it would require modifying the Java source itself instead of just configuring the application context to load one set of DAOs for testing and another for deployment.
Of course this would not be a Java conference in 2005 if no mention of Ruby on Rails is made. The Spring team does admire the concept of convention over configuration although it is more difficult with a statically typed language like Java. However, the developers are very interested in dynamic language support in Spring, and they are also looking to simplify the MVC configuration for Spring 2.0.
The concept of setting up a foundation for ownership of Spring (ala Apache) was also mentioned to be in the works. This should be set up by Q1 next year.
TSE, post 2
Today has been a busy day thus far at TSE 2005. The talk by Keith and Christian was not so much about Agile as it was about the Spring build environment. Instead of having one monolithic build, they are moving towards a more modular approach where each component of the project (such as core, aop, dao, etc) has its own build file. They are also setting up common build targets that are shared across the various build files for each module. Jar file dependency is handled by a project called Ivy. Previously I had known of only Maven that handled this sort of thing. However Ivy is focused strictly towards jar dependencies, whereas Maven has a larger scope.
Christian is one of the main developers for the Spring IDE project which is an Eclipse plugin for managing Spring projects. It performs validation for Spring XML files, including format (making sure the file conforms to the DTD) and content (by making sure the various classes and properties exist. It also generates a graphical representation of the application context configuration. One nice feature of this project is the graphical editor for Spring Web Flow. Since SWF is a moving target, the IDE does not have support for the latest and greatest, but it should be catching up as soon as SWF goes 1.0.
Next I attended a talk by the always entertaining Matt Raible on TDD with Spring and Hibernate. This talk was mostly in the context of App Fuse, which I had heard him talk about previously at the Orlando JUG. He mentioned a class that is provided by Spring that makes it easier to test DAOs. It wraps a transaction around a test method and performs a rollback when the method has executed, which allows testing with a real database (as opposed to using mocks) but prevents polluting the database with test data. Right now I have a test DAO layer where the transaction boundaries are defined at the DAO method layer. Even though I do have a test database that I can pretty much trash, it would be nice to not have to. I think I’ll give this test class a closer look.
Tip for those at TSE 2005 with laptops
Tip for those at TSE 2005
If you’re having trouble with the wireless network in the hotel, I have had success by running:
ipconfig /release
and
ipconfig /renew
I find that I have to do this every few minutes, otherwise I loose connectivity. Running ipconfig /renew by itself did not help; I also had to release the IP.
The Spring Experience, 1st post
For the next few days I will be attending The Spring Experience in south Florida. Jim Moore and I will be presenting a case study on how we use Spring for our call tracking application in Symantec. Yesterday we had dinner and a keynote by Rod Johnson and some of the core developers. Much of the talk was about the history of Spring and the release of Spring 2.0 M1. Some of the new features include
- XML schema to simplify configurations such as JNDI, AOP
- Webflow enhancements
- Improved integration with AspectJ, including the use of the AspectJ pointcut language to declare Spring AOP pointcuts
- Message driven POJOs
I just attended the talk on Spring, Mule, and the ESB. It was a nice introduction to ESB (enterprise service bus) and Mule, the open source ESB implementation. In a nustshell, Mule is used for a decentralized messaging system. It appears to be a well thought out system, especially because of how decoupled the architecture is. It does not just rely on JMS; message endpoints can be set up using many different technologies such as EJB, SOAP, SMTP, FTP, etc. It provides a mechanism to transform data to and from the various message formats. It is also very POJO based, which makes it a great candidate to be integrated and configured with Spring.
Next I’ll be attending a talk on Spring in an agile environment with Keith Donald and Christian Dupuis. More to come later.
In the meanwhile, you can see a much more extensive description of the keynote on Matt Raible’s site.