Spring Utility
ON THIS PAGE:
OTHER PAGES:
When I started to investigate the Spring Framework, I wanted to be able to make use of the XML bean definition mechanism and dependency injection without having to include references to the Spring libraries in my code (it seemed to be adding a dependency of a different kind). So I created a SpringRunner class which reads in the set of bean definitions, locates a bean named “main” and runs it. In this way, all of the Spring dependencies can be extracted from the main code of the program.
It's possible that something like this already exists — after all, it's trivially simple to implement. But I couldn't find anything like this in my initial perusal of the Spring libraries, and it seemed like a useful exercise to create it for myself.
The SpringRunner class acts as a Java main() program. It reads an XML bean definition file specified by the first argument to the main method, locates a bean named “main” which must be of type Runnable, and calls the run() method of that bean.
The class uses the Apache Commons Logging framework, and of course it uses classes from the Spring Framework. These libraries must be downloaded separately (see the readme.txt file in the main project zip file).
This software has been tested on Linux (Ubuntu) and Windows (XP). It should run without modification on any system that supports Java SE and Spring.
For those people who wish to use the class but not modify it, a JAR file containing the single class is available for download. A ZIP file of the Javadoc for the class is also available. And for those who wish to modify the source or just to peruse it, a ZIP file of the entire project (source, Ant build file etc.) is available.
File Name File Size File Type
SpringUtil.jar 1,877 JAR file
SpringUtilDoc.zip 18,504 ZIP of Javadoc
SpringUtilProject.zip 14,951 ZIP of source etc.
Do not deep-link to the download files — the URLs include a numeric IP address which may change from time to time.
This software requires the Spring Framework library, version 2.0.x or later, which is not included in the above downloads. It may be downloaded from: The Spring library comes in two forms — an all-in-one JAR file containing all the classes, or broken-out JAR files containing just the classes relating to a specific area. If the latter form is used, then at least the following JAR files must be present in the classpath:
  • spring-core.jar
  • spring-beans.jar
  • spring-context.jar
This software also requires the following libraries from the Apache Commons collection, which are also not included in the above downloads.
  • commons-logging.jar
  • commons-collections.jar
Javadoc for the project may be perused online: Please use this only for occasional reference; for repeated use please download the ZIP of the Javadoc (see above). Do not deep-link to the online Javadoc — the URL includes a numeric IP address which may change from time to time.
This software is copyright © 2007, 2008 Peter Wall. It is licensed under the GNU Lesser General Public License.
Valid HTML 4.0! Valid CSS! Last modified:
23 April 2008