Thursday 15 October 2009

Creating a Spring application

Creating a standalone (ie non-web) application can seem a little confusing to some. Sproing makes this easy by extending a Sproing class and implementing a method, and that's it!

All you need do is have your main (the class with the main() method that starts the application) extend ApplicationWirer and implement the getPaths() method that returns the path(s) to your application context xml files. Then a single call to the wire() method does the rest



import uk.org.sith.sproing.spring.ApplicationWirer;
public class Main extends ApplicationWirer {
public static void main(String[] args) {
Main main = new Main();
main.wire(main);
}

public String[] getPaths() {
return new String[] {"applicationContext.xml"};
}
}



This code will start your application and load the applicationContext.xml file into spring with all the spring beans defined. Easy!


Sproing version 0.3.1alpha is available now from Sith Open Source

1 comment:

Unknown said...

Cool!. The Sith Open Source Web looks down. I found this:
Sith Open Source: http://sith.antonylees.com/index.html

Priject Sproing: http://sourceforge.net/projects/sproing/

Thanks for the link