AddressBean.java
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:3k
源码类别:
Java编程
开发平台:
Java
- package cmpsample;
- import javax.ejb.*;
- import javax.naming.*;
- abstract public class AddressBean implements EntityBean {
- EntityContext entityContext;
- public java.lang.String ejbCreate(java.lang.String addressID) throws CreateException {
- setAddressID(addressID);
- return addressID;
- }
- public java.lang.String ejbCreate(String id, String addressID, String street, String city, String zip, String state) throws CreateException {
- /**@todo Complete this method*/
- System.out.println(" -- AddressEJB - ejbCreate...");
- setAddressID(addressID);
- setStreet(street);
- setCity(city);
- setZip(zip);
- setState(state);
- return addressID;
- }
- public void ejbPostCreate(java.lang.String addressID) throws CreateException {
- /**@todo Complete this method*/
- }
- public void ejbPostCreate(String id, String addressID, String street, String city, String zip, String state) throws CreateException {
- /**@todo Complete this method*/
- System.out.println(" -- AddressEJB - ejbPostCreate...");
- try {
- Context ic = new InitialContext();
- StudentHome home = (StudentHome)
- ic.lookup("Student");
- Student student = home.findByPrimaryKey(id);
- student.addAddress( (Address) entityContext.getEJBLocalObject());
- }
- catch (Exception ex) {
- System.out.println("in addressbean");
- entityContext.setRollbackOnly();
- ex.printStackTrace();
- }
- }
- public void ejbRemove() throws RemoveException {
- /**@todo Complete this method*/
- }
- public abstract void setAddressID(java.lang.String addressID);
- public abstract void setStreet(java.lang.String street);
- public abstract void setCity(java.lang.String city);
- public abstract void setZip(java.lang.String zip);
- public abstract void setState(java.lang.String state);
- public abstract void setStudentID(java.lang.String studentID);
- public abstract java.lang.String getAddressID();
- public abstract java.lang.String getStreet();
- public abstract java.lang.String getCity();
- public abstract java.lang.String getZip();
- public abstract java.lang.String getState();
- public abstract java.lang.String getStudentID();
- public void ejbLoad() {
- /**@todo Complete this method*/
- }
- public void ejbStore() {
- /**@todo Complete this method*/
- }
- public void ejbActivate() {
- /**@todo Complete this method*/
- }
- public void ejbPassivate() {
- /**@todo Complete this method*/
- }
- public void unsetEntityContext() {
- this.entityContext = null;
- }
- public void setEntityContext(EntityContext entityContext) {
- this.entityContext = entityContext;
- }
- }