package com.amit.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import amit.com.beans.HelloBean;
public class Test {
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext("applicationConfig.xml");
HelloBean bean = (HelloBean) context.getBean("hb");
System.out.println(bean.sayHello());
}
}
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import amit.com.beans.HelloBean;
public class Test {
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext("applicationConfig.xml");
HelloBean bean = (HelloBean) context.getBean("hb");
System.out.println(bean.sayHello());
}
}
=====================================================================
package amit.com.beans;
public class HelloBean
{
HelloBean()
{
System.out.println("Object Creation.......");
}
public void initialize()
{
System.out.println("Initialization......");
}
public void destroy()
{
System.out.println("Destruction......");
}
public String sayHello()
{
return "Hello User";
}
}
=====================================================================
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="hb" class ="amit.com.beans.HelloBean" init-method="initialize" destroy-method="destroy"></bean>
</beans>
====================================================================
No comments:
Post a Comment