⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readerejavabean.java

📁 java EJB 编程源代码。
💻 JAVA
字号:
package library.ejb;

import java.util.*;
import javax.ejb.*;

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//这是Entity Bean的Bean Class类
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

public class ReaderEJavaBean implements EntityBean
  {
   private EntityContext context;

   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
   //定义一些变量,这些变量同数据表中的字段必须一一对应
   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

   public String readname = null;
   public String cardid = null;
   public String password = null;
   public String address = null;
   public String email = null;

   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   //定义回调方法(callback method)
   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

   public void setEntityContext(EntityContext context)
     {
      this.context = context;
     }

   public void unsetEntityContext()
     {
      context = null;
     }

  public String ejbCreate(String cardid) throws DuplicateKeyException, CreateException
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //这个回调方法同ReaderInfoHomeInt接口中的create()方法相对应
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

      this.readname = "";
      this.cardid = cardid;
      this.password = "";
      this.address = "";
      this.email = "";
    
      return null;
     }

   public void ejbPostCreate(String cardid)
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //这个回调方法同Bean Class中的ejbCreate()回调方法相对应
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
     }

   public String ejbCreate(String readname,String cardid,String password,String address,String email)
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //这个回调方法同ReaderInfoHomeInt接口中的create()方法相对应
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

      this.readname = readname;
      this.cardid = cardid;
      this.password = password;
      this.address = address;
      this.email = email;

      return null;
     }

   public void ejbPostCreate(String readname,String cardid,String password,String address,String email)
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //这个回调方法同Bean Class中的ejbCreate()回调方法相对应
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
     }

   public void ejbActivate()
     {
      cardid = (String)context.getPrimaryKey();
     }

   public void ejbPassivate()
     {
      readname = null;
      cardid = null;
      password = null;
      address = null;
      email = null;
     }

   public void ejbLoad()
     {}

   public void ejbStore()
     {}

   public void ejbRemove()
     {}

   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   //定义business方法,这里的business方法同ReaderInfoRemoteInt接口中
   //business方法要一一对应
   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

   public void setReaderInfo(String readname,String cardid,String password,String address,String email)
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的setReaderInfo()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

	  this.readname = readname;
      this.cardid = cardid;
      this.password = password;
      this.address = address;
      this.email = email;
     }

   public void setCardID(String cardid)
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的setcardid()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

      this.cardid = cardid;
     }

   public void setPassword(String password)
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的setPassword()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

      this.password = password;
     }

   public void setReadName(String readname)
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的setReadName()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

      this.readname = readname;
     }

   public void setAddress(String address)
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的setAddress()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

      this.address = address;
     }

   public void setEmail(String email)
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的setEmail()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

      this.email = email;
     }

   public Hashtable getReaderInfo()
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的getReaderInfo()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

      Hashtable hashtbl = new Hashtable();      // 定义散列表对象

      try
        {
         //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         //调用put方法,将变量的值放入散列表(Hash表)
         //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

         hashtbl.put("readname",readname);
         hashtbl.put("cardid",cardid);
         hashtbl.put("password",password);
         hashtbl.put("address",address);
         hashtbl.put("email",email);
        }
      catch(NullPointerException e)
        {}

      return hashtbl;
     }

   public String getCardID()
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的getcardid()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      return cardid;
     }

   public String getPassword()
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的getPassword()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      return password;
     }

   public String getReadName()
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的getReadName()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      return readname;
     }

   public String getAddress()
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的getAddress()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      return address;
     }
   
   public String getEmail()
     {
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      //实现ReaderInfoRemoteInt接口中的getEmail()方法
      //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      return email;
     }
  }

⌨️ 快捷键说明

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