Data.java:
package
com.lnn.spel.wwt;
public class Data {
private double multiplier;
private double randomNumber;
public double getMultiplier()
{
return multiplier;
}
public void setMultiplier(double multiplier) {
this.multiplier = multiplier;
}
public double
getRandomNumber() {
return randomNumber;
}
public void
setRandomNumber(double randomNumber) {
this.randomNumber = randomNumber;
}
}
wwt.xml:
<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-3.0.xsd">
<bean id="data"
class = "com.lnn.spel.wwt.Data">
<property name="multiplier"
value="#{T(java.lang.Math).PI}"/>
<property name="randomNumber"
value="#{T(java.lang.Math).random()}"/>
</bean>
</beans>
Test.java:
package
com.lnn.spel.wwt;
import
org.springframework.context.ApplicationContext;
import
org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[]
args) {
ApplicationContext
context = new ClassPathXmlApplicationContext("wwt.xml");
Data
data = context.getBean("data", Data.class);
System.out.println("Multiplier
: " + data.getMultiplier());
System.out.println("RandomNumber
: " + data.getRandomNumber());
}
}
No comments:
Post a Comment