130
Chapter 7: Using Flash Remoting for Java
Looking at the EJB code
The example Flash application calculates loan payments by invoking the
calculate()
method
on the following stateless session bean:
package ejbeans;
import java.rmi.*;
import java.util.*;
import javax.ejb.*;
public class SampleLoanBean implements SessionBean
{
//////////////////////////////////////////
///// General Enterprise EJBean stuff
//////////////////////////////////////////
private SessionContext sessionContext;
public void ejbCreate() throws CreateException{};
public void ejbRemove() throws RemoteException{};
public void ejbActivate() throws RemoteException{};
public void ejbPassivate() throws RemoteException{};
public void setSessionContext(SessionContext context) throws
RemoteException {
sessionContext = context;
}
public double calculate(double principal, int months, float rate){
if (rate < 0 || rate>1) return 0.0;
double monthlyPayment = principal * (rate / (1 - Math.pow(1 +
rate,-months)));
// Double payMe=new Double (monthlyPayment);
return monthlyPayment;
}
}
Looking at the user interface for the EJB
The following figure shows the user interface of the example Flash application with callouts that
indicate the field types and variable names referenced in the ActionScript code:
This Flash application invokes a stateless session bean that calculates a montlhy loan payment
based on principal amount, number of months, and rate (percentage in decimal format).