Last active
November 25, 2017 07:05
-
-
Save NikhilAshodariya/afd20b14112a50f035f779eeec9b5be4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package in.blogspot.codewithnikhil.beans; | |
| import java.net.URL; | |
| import org.springframework.context.ApplicationContext; | |
| import org.springframework.context.support.ClassPathXmlApplicationContext; | |
| public class Run | |
| { | |
| public static void main(String[] args) | |
| { | |
| URL resource = Run.class.getResource(".."); | |
| ApplicationContext context = new ClassPathXmlApplicationContext(resource+"resources/spring.xml"); | |
| Triangle t = (Triangle) context.getBean("tri"); | |
| t.paint(); | |
| System.out.println(t.getTriType()); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> | |
| <beans> | |
| <bean id="tri" class="in.blogspot.codewithnikhil.beans.Triangle"> | |
| <property name="triType" value="Scalene Triangle"></property> | |
| </bean> | |
| </beans> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package in.blogspot.codewithnikhil.beans; | |
| public class Triangle | |
| { | |
| private String triType; | |
| public void paint() | |
| { | |
| System.out.println(getTriType() + " Drawn"); | |
| } | |
| public String getTriType() | |
| { | |
| return triType; | |
| } | |
| public void setTriType(String triType) | |
| { | |
| this.triType = triType; | |
| } | |
| @Override | |
| public String toString() | |
| { | |
| return "Triangle{" + "triType=" + triType + '}'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment