Calculator.java
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:1k
源码类别:
Java编程
开发平台:
Java
- package bible.webservices.rpc;
- import java.rmi.*;
- import javax.ejb.*;
- /**
- * Class Calculator
- * A Session Bean that allows the user to perform simple arithmetic operations
- * on the two parameters provided. The java primitives are passed to the Session
- * Bean via the SOAP Servlet. The SOAP Servlet decodes the parameters from the
- * SOAP envelope which is sent from the user client. The process is reversed when
- * the Session Bean sends its reply to the client.
- *
- * @author Geoff Schneider
- */
- public class Calculator implements SessionBean {
- private SessionContext sessionContext;
- public void ejbCreate() {
- }
- public void ejbRemove() throws RemoteException {
- }
- public void ejbActivate() throws RemoteException {
- }
- public void ejbPassivate() throws RemoteException {
- }
- public void setSessionContext(SessionContext sessionContext) throws RemoteException {
- this.sessionContext = sessionContext;
- }
- /**
- * Returns the sum of two long primitives.
- */
- public long add(long amount1, long amount2) {
- return amount1 + amount2;
- }
- /**
- * Returns the difference of two long primitives.
- */
- public long subtract(long amount1, long amount2) {
- return amount1 - amount2;
- }
- /**
- * Returns the product of two double primitives.
- */
- public double multiply(double amount, double factor) {
- return amount * factor;
- }
- /**
- * Returns the quotient of two double primitives.
- */
- public double divide(double amount, double divisor) {
- return amount / divisor;
- }
- }