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

📄 userbean.java

📁 《Java网络程序设计.rar》包括三个网络程序的源代码。
💻 JAVA
字号:
/* */package org.impact.stars.organizationmd.user.ejb;import java.util.Collection;import java.util.Locale;import java.rmi.RemoteException;import javax.rmi.PortableRemoteObject;import javax.naming.InitialContext;import javax.ejb.DuplicateKeyException;import javax.ejb.CreateException;import javax.ejb.EJBException;import javax.ejb.RemoveException;import javax.ejb.SessionBean;import javax.ejb.SessionContext;import javax.ejb.FinderException;import org.impact.stars.organizationmd.stakeholder.model.StakeholderModel;import org.impact.stars.organizationmd.stakeholder.ejb.StakeholderLocal;import org.impact.stars.organizationmd.stakeholder.ejb.StakeholderLocalHome;/*import org.impact.stars.organizationmd.stakeholder.exceptions.StakeholderAppException;import org.impact.stars.organizationmd.stakeholder.exceptions.StakeholderAppLongIdException;import org.impact.stars.organizationmd.stakeholder.exceptions.StakeholderAppInvalidCharException;*/import org.impact.stars.organizationmd.user.exceptions.UserAppLongIdException;import org.impact.stars.organizationmd.user.exceptions.UserAppInvalidCharException;import org.impact.stars.organizationmd.user.exceptions.UserAppException;import org.impact.stars.util.JNDINames;/** * Session Bean implementation for UserEJB EJB. The user is a run time  * instance of a user login */public class UserBean implements SessionBean {    StakeholderLocalHome stakeholderHomeRef = null;    SessionContext context = null;    /**     * Constructor - does nothing     */    public UserBean() {}    /**     * Sets the session context     * @param sc the <code>SessionContext</code> for this instance     */    public void setSessionContext(SessionContext sc) {        this.context = sc;    }    private void getReferences() {        try {            Object objref;            InitialContext initial = new InitialContext();                if(stakeholderHomeRef == null) {                    objref = initial.lookup(JNDINames.STAKEHOLDER_EJBHOME);                    stakeholderHomeRef = (StakeholderLocalHome)                    PortableRemoteObject.narrow(objref, StakeholderLocalHome.class);                }                        } catch (javax.naming.NamingException ne) {            throw new EJBException ("Naming Ex while getting facade " +                                    "references : " + ne);        }        return;    }    /**     * the ejbCreate methods that just gets the references     */    public void ejbCreate() {        getReferences();    }    /**     * the ejbRemove methods that does nothing     */    public void ejbRemove() {    }    /**     * the ejbActivate methods that just gets the references     */    public void ejbActivate() {       getReferences();    }    /**     * the ejbPassivate methods that resets the references     */    public void ejbPassivate() {        stakeholderHomeRef = null;      //  orderHomeRef = null;    }    /**     * Gets the stakeholder details give an user id     * @param userId a string that represents the user Id     * @return the <code>StakeholderModel</code> that has the stakeholder information     *         corresponding to a customer's stakeholder.     * @throws <code>RemoteException</code> for irrecoverable errors     * @throws <code>FinderException</code> if the user details was not found     */    public StakeholderModel getStakeholderDetails(String userId) throws                                   RemoteException, FinderException {        try {           if(stakeholderHomeRef == null)               getReferences();           StakeholderLocal stkhdr = stakeholderHomeRef.findByPrimaryKey(userId);         return(new StakeholderModel(stkhdr.getFirstName(), stkhdr.getLastName(), stkhdr.getGroupId()));        }             catch (FinderException fe) {             throw new FinderException(fe.getMessage());             }    }}

⌨️ 快捷键说明

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