DrawingApp.java
package org.yash.watertechsol;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
@SuppressWarnings("deprecation")
public class DrawingApp {
public static void main(String[]
args){
//here we are
not using spring configuration
//Triangle
triangle = new Triangle();
//triangle.draw();
//Let do with
spring configuration
BeanFactory
factory = new XmlBeanFactory(new FileSystemResource("spring.xml"));
Triangle triangle
= (Triangle)factory.getBean("triangle");
triangle.draw();
}
}
Triangle.java
package org.yash.watertechsol;
public class Triangle {
public void draw(){
System.out.println("Trianble
drawn");
}
}
spring.xml
<?xml
version="1.0" encoding="UTF-8"?>
<!DOCTYPE
beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="triangle"
class="org.yash.watertechsol.Triangle"></bean>
</beans>
No comments:
Post a Comment