operationbean.java

来自「jboss4 + Mysql +ejb3.0 EJB3 简单例子」· Java 代码 · 共 47 行

JAVA
47
字号
/**
 * Copyright (c)上海烟草(集团)公司与上海康时信息系统有限公司。
 */
package com.myejb.imp;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;

import org.jboss.annotation.ejb.LocalBinding;
import org.jboss.annotation.ejb.RemoteBinding;

import com.myejb.LocalOperation;
import com.myejb.Operation;

/**
 * 实现了远程和本地的会话Bean
 * @author xywang
 * @since 2009-2-11
 * @version 1.0
 */
@Stateless
@Remote({Operation.class})
@RemoteBinding(jndiBinding="myejb/RemoteOperation") // 自己定义jndi名字
@Local({LocalOperation.class})
@LocalBinding(jndiBinding="myejb/LocalOperation")
public class OperationBean implements Operation,LocalOperation{
    private int total = 0;
    private int addresult = 0;
    /* (非 Javadoc)
     * @see com.myejb.Operation#Add(int, int)
     */
    public int Add(int a,int b){
        addresult = a + b;
        return addresult;
    }

    /* (非 Javadoc)
     * @see com.myejb.LocalOperation#getResult()
     */
    public int getResult(){
        total += addresult;
        return total;
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?