精通Jboss——Ejb和Web Services开发精解的随书源代码
源代码在线查看: accountbean.java
/**
* AccountBean.java Created on 2003-12-8
*
*/
package com.liuyang.ejb.cmp.account;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
/**
* @author liuyang
*
* @ejb.bean description="AccountBean"
* display-name="AccountBean"
* local-jndi-name = "cmp/AccountHomeLocal"
* name="Account"
* primkey-field="username"
* schema="account"
* type="CMP"
* cmp-version = "2.x"
* view-type="local"
*
* @ejb.finder signature="java.util.Collection findAll()"
* query = ""
* @jboss.query signature ="java.util.Collection findAll()"
* query = "SELECT OBJECT(g) FROM account g"
* @ejb.finder query="select object(g) from account g where g.username =?1"
* signature="java.util.Collection findByUsername(java.lang.String username)"
*
*/
public abstract class AccountBean implements EntityBean {
/**
* @ejb.pk-field
* @ejb.persistence
* @ejb.interface-method view-type = "local"
*/
public abstract String getUsername();
/**
* @ejb.interface-method view-type = "local"
*/
public abstract void setUsername(String username);
/**
* @ejb.persistence
* @ejb.interface-method view-type = "local"
*/
public abstract String getPassword();
/**
* @ejb.interface-method view-type = "local"
*/
public abstract void setPassword(String password);
/**
* @ejb.create-method
*/
public String ejbCreate(String username,String password) throws CreateException {
this.setUsername(username);
this.setPassword(password);
return username;
}
public void ejbPostCreate(String username,String password){
}
public void ejbActivate() throws EJBException, RemoteException {
}
public void ejbLoad() throws EJBException, RemoteException {
}
public void ejbPassivate() throws EJBException, RemoteException {
}
public void ejbRemove()
throws RemoveException, EJBException, RemoteException {
}
public void ejbStore() throws EJBException, RemoteException {
}
private EntityContext ctx;
public void setEntityContext(EntityContext ec)
throws EJBException, RemoteException {
ctx = ec;
}
public void unsetEntityContext() throws EJBException, RemoteException {
ctx = null;
}
}