Last week, I had the opportunity to present on the Spring Framework for the Oracle Consulting Java Professional Community at Oracle The Netherlands. Having worked at Oracle for over 8 years, it was a funny feeling being back there after three years. Standing on the same spot in the main presentation room (Morse), looking at almost the same faces – it felt good to be back. We had a very good session on Spring, with lots of questions and discussion about what the various Spring Modules have to offer and especially: how Spring can be integrated into typical Oracle Consulting projects that usually primarily use Oracle’s J2EE technology such as JDeveloper and the ADF framework.
During the presentation, I did some demonstrations on IoC and Dependency Injection, on Spring AOP and Spring JDBC and finally on Spring Remoting. I also talked about Mock Objects and Unit Testing of objects with very real dependencies.
The discussion on how to integrate Spring with ADF quickly focused on using a Spring based Business Service – that may be backed by Spring JDBC or Spring Persistence or DAO using Toplink or Hibernate and could be Adviced using Spring AOP – as DataControl in the ADF BindingFramework. Using one of the comments in this discussion, I worked out a demonstration of this Spring and ADF integration that you can read about in this post: Spring and Oracle ADF – registering a POJO Spring JDBC based Business Service as Data Control.
We could not see much value in trying to wrap ADF BC’s ViewObject RowImpl objects in POJO layers, trying to add behavior through AOP and forcing the Bean Factory onto ADF BC. Nor did we see the immediate value of trying to use Spring MVC on top of the ADF Binding Framework. Not only would be miss out on the ADF Struts LifeCycle Management – which is a very valuable asset of the ADF Binding Framework, it also seems that the ADF philosophy of decoupling Model from View/Controller through implementation independent DataControls and DataControlBindings is somewhat at odds with Spring’s vision that the Domain Model’s POJOs can and should be used through all tiers, including the Web Tier. Even when a DataControl(Binding) wraps a real POJO – instead of a ViewObjectRowImpl, which is more common when using ADF – the web-tier still should access it through the Binding interface, rather than directly at the POJO level.
In a way, ADF and especially ADF Business Components in combination with ADF Binding Framework and ADF UIX implements an architectur very similar to what Spring proposes – albeit in a very different manner.
You can download the presentation I showed here: spring_oracleJavaPC_29aug.ppt
The demonstrations I showed are zipped up in a single archive that you can download here: SpringAtOracle29Aug2005.zip
Note: the sources are assembled in JDeveloper 10.1.2 projects inside a single Application Workspace. The Java Classes and XML files can of course be used in any Java IDE, but you would have to setup your own project. The Spring library needs to be available in your project’s classpath.
So download the Springframework from SourceForge: http://sourceforge.net/project/showfiles.php?group_id=73357; choose Download spring-framework-1.2.4-with-dependencies.zip;this will download a zip-file that contains all jars of Spring and related libraries such as Log4J and CGLib. Unzip the zipfile in the directory of your choice.
Start JDeveloper 10.1.2. Open the SpringAndAdf application workspace. Edit the SpringJDBC project. Go to the Libraries node. Create a new library SpringFramework. Have the classpath of this library refer to all jars you have just extracted from the Spring-with-dependencies-download. For example:
Add this library to all projects.
Set up database connection details for the Spring JDBC demo
The HrmWebApplication attempts to connect to a SCOTT schema that contains an EMP table. The precise connection details such as database location and name and username and password are defined in the SpringConfig.xml file – the Spring Bean Configuration file – that you can find in the SpringJDBC project under Application Sources. Edit these configuration details to suit your environment.