FileDocCategorySizeDatePackage
PersonFacadeBean.javaAPI DocExample1902Sun Jul 20 18:35:18 BST 2003antipatterns.ejbs

PersonFacadeBean

public class PersonFacadeBean extends Object implements SessionBean
Created Jan 1, 2003 10:34:21 PM Code generated by the Forte For Java EJB Builder
author
jon

Fields Summary
private SessionContext
context
private LocalEJBPersonHome
personHome
Constructors Summary
Methods Summary
public voidejbActivate()

public voidejbCreate()

        try {
            InitialContext ic = new InitialContext();
            personHome = (LocalEJBPersonHome)ic.lookup("java:comp/env/ejb/local/Person");
        } catch(Exception ex) {
            throw new EJBException("Error looking up PersonHome: " + ex, ex);
        }
    
public voidejbPassivate()

public voidejbRemove()

public PeopleDTOfindByName(java.lang.String firstName, java.lang.String lastName)

        Collection c = null;
        if (firstName != null && lastName != null) {
            c = personHome.findByName(firstName, lastName);
        } else if (firstName != null) {
            c = personHome.findByFirstName(firstName);
        } else if (lastName != null) {
            c = personHome.findByLastName(lastName);
        } else {
            c = personHome.findAll();
        }
        
        return getDTOFromCollection(c);
    
private PeopleDTOgetDTOFromCollection(java.util.Collection people)

        PeopleDTO dto = new PeopleDTO();
        
        for (Iterator i = people.iterator(); i.hasNext();) {
            LocalEJBPerson ejbPerson = (LocalEJBPerson)i.next();
        
            dto.addPerson(new Person(ejbPerson.getFirstName(), 
                                     ejbPerson.getLastName(), 
                                     ejbPerson.getPhoneNumber()));
        }
    
        return dto;
    
public voidsetSessionContext(SessionContext aContext)

        context=aContext;