Maths.java:
package
com.lnn.spel.operations;
public class Maths {
private double adjustedPlus = 0;
private double adjustedMinus = 0;
private double average = 0;
private int remainder = 0;
private double circumference = 0;
private double area = 0;
private String name = null;
public double
getAdjustedPlus() {
return adjustedPlus;
}
public void
setAdjustedPlus(double adjustedPlus) {
this.adjustedPlus = adjustedPlus;
}
public double getAdjustedMinus()
{
return adjustedMinus;
}
public void
setAdjustedMinus(double adjustedMinus) {
this.adjustedMinus =
adjustedMinus;
}
public double getAverage() {
return average;
}
public void setAverage(double average) {
this.average = average;
}
public int getRemainder()
{
return remainder;
}
public void setRemainder(int remainder) {
this.remainder = remainder;
}
public double
getCircumference() {
return circumference;
}
public void
setCircumference(double circumference) {
this.circumference =
circumference;
}
public double getArea() {
return area;
}
public void setArea(double area) {
this.area = area;
}
public String
getName() {
return name;
}
public void setName(String
name) {
this.name = name;
}
}
Values.java:
package
com.lnn.spel.operations;
public class Values {
private double total = 0;
private double radius = 0;
private long count = 0;
private String firstName = null;
private String lastName = null;
public double getTotal() {
return total;
}
public void setTotal(double total) {
this.total = total;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public long getCount() {
return count;
}
public void setCount(long count) {
this.count = count;
}
public String
getFirstName() {
return firstName;
}
public void
setFirstName(String firstName) {
this.firstName = firstName;
}
public String
getLastName() {
return lastName;
}
public void
setLastName(String lastName) {
this.lastName = lastName;
}
}
operations.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="maths"
class = "com.lnn.spel.operations.Maths">
<property name="adjustedPlus"
value="#{values.total+20}"/>
<property name="adjustedMinus"
value="#{values.total-20}"/>
<property name="average"
value="#{values.total/values.count}"/>
<property name="remainder"
value="#{10%8}"/>
<property name="circumference"
value="#{T(java.lang.Math).PI*values.radius*2}"/>
<property name="area"
value="#{T(java.lang.Math).PI*values.radius^2}"/>
<property name="name"
value="#{values.firstName + ' ' + values.lastName}"/>
</bean>
<bean id="values"
class = "com.lnn.spel.operations.Values">
<property name="total"
value="#{1267.89}"/>
<property name="radius"
value="#{7}"/>
<property name="count"
value="#{10}"/>
<property name="firstName"
value="#{'Leninkumar'}"/>
<property name="lastName"
value="#{'Koppoju'}"/>
</bean>
</beans>
Test.java:
package
com.lnn.spel.operations;
import
org.springframework.context.ApplicationContext;
import
org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[]
args) {
ApplicationContext
context = new ClassPathXmlApplicationContext("operations.xml");
Maths
maths = context.getBean("maths", Maths.class);
System.out.println(maths.getAdjustedMinus());
System.out.println(maths.getAdjustedPlus());
System.out.println(maths.getArea());
System.out.println(maths.getAverage());
System.out.println(maths.getCircumference());
System.out.println(maths.getName());
System.out.println(maths.getRemainder());
}
}
No comments:
Post a Comment