DrawingApp.java
package org.yash.watertechsol;
import org.springframework.context.ApplicationContext;
import
org.springframework.context.support.ClassPathXmlApplicationContext;
public class DrawingApp {
public static void main(String[]
args){
ApplicationContext
context = new ClassPathXmlApplicationContext("spring.xml");
Triangle triangle
= (Triangle)context.getBean("triangle");
triangle.draw();
}
}
Triangle.java
package org.yash.watertechsol;
public class Triangle {
private String type;
public void draw(){
System.out.println(getType()
+ "
Trianble drawn");
}
public void setType(String
type) {
this.type = type;
}
public String
getType() {
return type;
}
}
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>
<!-- It is
blue print to object -->
<bean id="triangle"
class="org.yash.watertechsol.Triangle">
<property name="type"
value="Equilateral"></property>
</bean>
</beans>
No comments:
Post a Comment