Interfaces and classes for employee storage.

Java To Go!
Empower your EJB clients with mobile actions
Roger L. Cauvin
Listing 1. Interfaces and classes for employee storage.


// Session bean remote interface.
public interface EmployeeStorage extends javax.ejb.EJBObject
  {void storeEmployee(Employee employee) throws
RemoteException, StorageException;
  Vector retrieveEmployeeSSNs() throws RemoteException,
RetrievalException;
  Vector retrieveEmployees() throws RemoteException,
RetrievalException;
  Employee retrieveEmployee(String ssn) throws RemoteException,
RetrievalException;
  Object performAction(EmployeeStorageAction action) throws
RemoteException, ActionException;
  void removeEmployee(String ssn) throws RemoteException,
 RemovalException;}

// Action interface visible to session bean and its client.
public interface EmployeeStorageAction
  {Object perform(IEmployeeStorage employeeStorage) throws
ActionException;}

// Local interface visible to session bean and its client.
public interface IEmployeeStorage
  {void storeEmployee(Employee employee) throws StorageException;
  Vector retrieveEmployeeSSNs() throws RetrievalException;
  Vector retrieveEmployees() throws RetrievalException;
  Employee retrieveEmployee(String ssn) throws RetrievalException;
  Object performAction(EmployeeStorageAction action) throws
ActionException;
  void removeEmployee(String ssn) throws RemovalException;}

// Session bean class.
public class EmployeeStorageBean implements IEmployeeStorage,
javax.ejb.SessionBean
  { ... code for ejbCreate, storeEmployee, etc. ...

  public Object performAction(EmployeeStorageAction action) throws RemoteException, ActionException
    {return employeeStorageAction.perform(this);}
  }

About the Author

Roger L. Cauvin is a software engineer at KLA-Tencor, Austin, TX. He can be contacted at [email protected].