Hello,
I was trying to familiarize with different ways to define a bean using a XML file (spring 3.2).
I created a bean with a init-method
Code:
	<bean id="main" class="org.gsarno.spring.main.DBExecutor" init-method="start">
and I experimented 2 different ways to create the bean using a java property file. I noticed that
with Method-1 the init-method is only invoked if factory.getBean is invoked. With Method 2 getBean is not necessary.

Can anybody explain init-method is not invoked for Method-1 and whether there is a way to do that without invoking getBean ?


Method-1:
Code:
        XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("gsarnoSpringConfig.xml"));
        URL propurl = (new File("gsarnoSpringConfig.properties")).toURI().toURL();
        InputStream in = propurl.openStream();
        Properties properties = new Properties();
        properties.load(in);
        PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();     
        configurer.setProperties(properties);
        configurer.setIgnoreUnresolvablePlaceholders(true);
        configurer.postProcessBeanFactory(factory);
        //DBExecutor bean = (DBExecutor) factory.getBean("main");
Method-2:
Code:
        FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext("gsarnoSpringConfigNew.xml");