package com.venkat.core;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
public class DrawingApp {
/**
* @param args
*/
public static void main(String[] args) {
BeanFactory factory=new XmlBeanFactory(new FileSystemResource("applicationContext.xml"));
Triangle t=(Triangle)factory.getBean("triangleBean");
t.draw();
}
}
-------------------------------------------------------------------------
package com.venkat.core;
public class Triangle {
public void draw()
{
System.out.println("we are in Triangle ");
}
}
---------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="triangleBean" class="com.venkat.core.Triangle">
</bean>
</beans>
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
public class DrawingApp {
/**
* @param args
*/
public static void main(String[] args) {
BeanFactory factory=new XmlBeanFactory(new FileSystemResource("applicationContext.xml"));
Triangle t=(Triangle)factory.getBean("triangleBean");
t.draw();
}
}
-------------------------------------------------------------------------
package com.venkat.core;
public class Triangle {
public void draw()
{
System.out.println("we are in Triangle ");
}
}
---------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="triangleBean" class="com.venkat.core.Triangle">
</bean>
</beans>
No comments:
Post a Comment