Literals.java:
package com.lnn.spel;
public class Literals {
private int count;
private String message;
private double frequency;
private long capacity;
private String name1;
private String name2;
private boolean enabled;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public String
getMessage() {
return message;
}
public void
setMessage(String message) {
this.message = message;
}
public double getFrequency()
{
return frequency;
}
public void setFrequency(double frequency) {
this.frequency = frequency;
}
public long getCapacity() {
return capacity;
}
public void setCapacity(long capacity) {
this.capacity = capacity;
}
public String
getName1() {
return name1;
}
public void setName1(String
name1) {
this.name1 = name1;
}
public String
getName2() {
return name2;
}
public void setName2(String
name2) {
this.name2 = name2;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
spel.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="literals"
class = "com.lnn.spel.Literals">
<property name="count" value="#{5}"/>
<property name="message"
value="The value is #{5}"/>
<property name="frequency"
value="#{89.7}"/>
<property name="capacity"
value="#{1e4}"/>
<property name="name1"
value="#{'Chuck'}"/>
<property name='name2' value='#{"Chuck"}'/>
<property name="enabled"
value="#{false}"/>
</bean>
</beans>
Test.java
:
package
com.lnn.spel;
import
org.springframework.context.ApplicationContext;
import
org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[]
args) {
ApplicationContext
context = new ClassPathXmlApplicationContext("spel.xml");
Literals
literals = context.getBean("literals", Literals.class);
System.out.println("count :
" + literals.getCount());
System.out.println("message
: " + literals.getMessage());
System.out.println("frequencey
: " + literals.getFrequency());
System.out.println("capacity
: " + literals.getCapacity());
System.out.println("name1 :
" + literals.getName1());
System.out.println("name2 :
" + literals.getName2());
System.out.println("enabled
: " + literals.isEnabled());
}
}
No comments:
Post a Comment