package com.sun.j2ee.blueprints.customer.ejb;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
import javax.ejb.CreateException;
import javax.naming.NamingException;
import javax.naming.InitialContext;
import com.sun.j2ee.blueprints.customer.account.ejb.AccountLocal;
import com.sun.j2ee.blueprints.customer.account.ejb.AccountLocalHome;
import com.sun.j2ee.blueprints.customer.profile.ejb.ProfileLocal;
import com.sun.j2ee.blueprints.customer.profile.ejb.ProfileLocalHome;
public abstract class CustomerEJB implements javax.ejb.EntityBean {
private EntityContext context = null;
public abstract String getUserId();
public abstract void setUserId(String userId);
public abstract AccountLocal getAccount();
public abstract void setAccount(AccountLocal account);
public abstract ProfileLocal getProfile();
public abstract void setProfile(ProfileLocal profile);
public String ejbCreate(String userId) throws CreateException {
setUserId(userId);
return null;
}
public void ejbPostCreate(String userId) throws CreateException {
try {
InitialContext ic = new InitialContext();
AccountLocalHome alh = (AccountLocalHome) ic.lookup("java:comp/env/ejb/Account");
AccountLocal account = alh.create(AccountLocalHome.Active);
setAccount(account);
ProfileLocalHome plh = (ProfileLocalHome) ic.lookup("java:comp/env/ejb/Profile");
ProfileLocal profile = plh.create(ProfileLocalHome.DefaultPreferredLanguage,
ProfileLocalHome.DefaultFavoriteCategory, ProfileLocalHome.DefaultMyListPreference,
ProfileLocalHome.DefaultBannerPreference);
setProfile(profile);
} catch (NamingException ne) {
throw new CreateException ("could not lookup ejb. Exception is " + ne.getMessage());
}
}
public void setEntityContext(EntityContext c) {
context = c;
}
public void unsetEntityContext() { }
public void ejbRemove() throws RemoveException { }
public void ejbActivate() { }
public void ejbPassivate() { }
public void ejbStore() { }
public void ejbLoad() { }
}