有实现类,刚才忘了帖: @Stateful @Remote(NewSessionRemote.class) @Local(NewSessionLocal.class) public class NewSessionBean implements NewSessionRemote, NewSessionLocal {private Newtable account=null; public void open(int accountNumber){ account=manager.find(test.Newtable.class,accountNumber); if(account==null){ account=new Newtable(); account.setAccountNumber(new Integer(accountNumber)); account.setAccount(new Integer(0)); manager.persist(account); } } public int getAccount(){ if(account==null){ throw new IllegalStateException(); } return account.getAccount(); }
public void deposit(int amount){ if(account==null){ throw new IllegalStateException(); } account.deposit(amount); } public int withdraw(int amount){ if(account==null){ throw new IllegalStateException(); } return account.withdraw(amount); } }
@Stateful
@Remote(NewSessionRemote.class)
@Local(NewSessionLocal.class)
public class NewSessionBean implements NewSessionRemote, NewSessionLocal {private Newtable account=null; public void open(int accountNumber){
account=manager.find(test.Newtable.class,accountNumber);
if(account==null){
account=new Newtable();
account.setAccountNumber(new Integer(accountNumber));
account.setAccount(new Integer(0));
manager.persist(account);
}
} public int getAccount(){
if(account==null){
throw new IllegalStateException();
}
return account.getAccount();
}
public void deposit(int amount){
if(account==null){
throw new IllegalStateException();
}
account.deposit(amount);
} public int withdraw(int amount){
if(account==null){
throw new IllegalStateException();
}
return account.withdraw(amount);
}
}
实现类里加了@Remote(NewSessionRemote.class),接口类中的@Remote也可以去掉