Use the Mobile Action design pattern.

Java To Go!
Empower your EJB clients with mobile actions
Roger L. Cauvin
Listing 3. Use the Mobile Action design pattern.


public class FindByNameAction implements EmployeeAction,
Serializable
  {
  public FindByNameAction(String targetName)
    {
    setTargetName(targetName);
    }

  public Object perform(IEmployeeStorage employeeStorage) throws
ActionException
    {
    Vector employees = null;
    try
      {
      employees = employeeStorage.retrieveEmployees();
      }
    catch (RetrievalException retrievalException)
      {
      throw new ActionException(retrievalException);
      }

    String targetName = getTargetName();

    Employee employee = null;
    Enumeration enumeration = employees.elements();
    boolean wasFound = false;
    while (!wasFound && enumeration.hasMoreElements())
      {
      employee = (Employee) enumeration.nextElement();
      wasFound = targetName.equals(employee.getName());
      }

    return wasFound ? employee : null;
    }

  ... code for getTargetName, setTargetName, etc. ...
  }

About the Author

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

Upcoming Training Events

0 AM
Visual Studio Live! San Diego
September 8-12, 2025
Live! 360 Orlando
November 16-21, 2025
Cloud & Containers Live! Orlando
November 16-21, 2025
Data Platform Live! Orlando
November 16-21, 2025
Visual Studio Live! Orlando
November 16-21, 2025