I am not sure how it can be done the way you are trying to do. I have some batches, all of them instantiated by Spring IoC, and with dependecies, but you need a class with a main method that loads context files. For example:
Code:
private static String[] _config = new String[] {
"applicationContext.xml",
"applicationContext-batches.xml"};
private static String BATCH_BEAN = "listaProcesos";
public static void main(String[] args) throws Exception {
ApplicationContext appContext = new ClassPathXmlApplicationContext(_config);
IBatch batch = (IBatch)appContext.getBean(BATCH_BEAN, IBatch.class);
batchInicial.execute();
}
IBatch, is just an interface which declares a method called "execute()"
That is, you may have a file with the configuration of all your batches, and get the one desired with appContext.getBean
If you want more flexibility, think that the bean name and configuration files may be sent as command line arguments