This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package exam.test03; | ||
|
||
/** | ||
* Created by nhnent on 2017. 5. 27.. | ||
*/ | ||
public class Score { | ||
|
||
private String name; | ||
private float kor; | ||
private float eng; | ||
private float math; | ||
|
||
public Score() { | ||
|
||
} | ||
|
||
public Score(String name, float kor, float eng, float math) { | ||
this.name = name; | ||
this.kor = kor; | ||
this.eng = eng; | ||
this.math = math; | ||
} | ||
|
||
public float average() { | ||
return sum() / (float)3; | ||
} | ||
|
||
public float sum() { | ||
return kor + eng + math; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public float getKor() { | ||
return kor; | ||
} | ||
|
||
public void setKor(float kor) { | ||
this.kor = kor; | ||
} | ||
|
||
public float getEng() { | ||
return eng; | ||
} | ||
|
||
public void setEng(float eng) { | ||
this.eng = eng; | ||
} | ||
|
||
public float getMath() { | ||
return math; | ||
} | ||
|
||
public void setMath(float math) { | ||
this.math = math; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package exam.test03; | ||
|
||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
/** | ||
* Created by nhnent on 2017. 5. 27.. | ||
*/ | ||
public class Test { | ||
|
||
public static void main(String[] args) { | ||
|
||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("file:/Users/nhnent/workspace/workspace-intellij/java_webdev_workbook_spring/src/main/java/exam/test03/beans.xml"); | ||
|
||
System.out.println("[Print the name of beans stored in container]"); | ||
|
||
for (String name : ctx.getBeanDefinitionNames()) { | ||
System.out.println(name); | ||
} | ||
|
||
System.out.println("[Extract annonymous bean]"); | ||
Score score1 = (Score)ctx.getBean("exam.test03.Score"); | ||
Score score2 = (Score)ctx.getBean("exam.test03.Score#0"); | ||
|
||
if (score1 == score2) { | ||
System.out.println("score == score#0"); | ||
} | ||
|
||
Score score3 = (Score)ctx.getBean("exam.test03.Score#1"); | ||
if (score1 != score3) { | ||
System.out.println("score != score#1"); | ||
} | ||
|
||
System.out.println("[Extract by class type]"); | ||
Score score4 =(Score)ctx.getBean(exam.test03.Score.class); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?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 class="exam.test03.Score"></bean> | ||
<bean class="exam.test03.Score"></bean> | ||
|
||
</beans> |