perspectivecontroller.java

来自「<Java网络程序设计 J2EE>随书源码」· Java 代码 · 共 102 行

JAVA
102
字号
/* */package org.impact.stars.control.ejb;import java.rmi.RemoteException;import javax.naming.InitialContext;import javax.naming.NamingException;import javax.ejb.CreateException;import javax.ejb.DuplicateKeyException;import javax.ejb.FinderException;import javax.ejb.EJBException;import org.impact.stars.util.Debug;import org.impact.stars.util.JNDINames;import org.impact.stars.util.EJBUtil;import org.impact.stars.util.EJBKeys;import org.impact.stars.perspectivemd.perspective.ejb.PerspectiveLocal;import org.impact.stars.perspectivemd.perspective.ejb.PerspectiveLocalHome;import org.impact.stars.organizationmd.profilemgr.ejb.ProfileMgrLocal;import org.impact.stars.organizationmd.profilemgr.ejb.ProfileMgrLocalHome;import org.impact.stars.control.event.PerspectiveEvent;import org.impact.stars.control.event.StarsEvent;import org.impact.stars.control.exceptions.StarsEventException;import org.impact.stars.perspectivemd.perspective.exceptions.PerspectiveAppException;import org.impact.stars.control.exceptions.StarsAppException;public class PerspectiveController extends StateControllerSupport {        public void perform(StarsEvent event) throws StarsEventException {        PerspectiveEvent pe = (PerspectiveEvent)event;                switch (pe.getActionType()) {            case PerspectiveEvent.CREATE_PERSPECTIVE_DATA: {                Debug.println("PerspectiveController (ejb): CREATE_PERSPECTIVE_DATA event");                try {                    PerspectiveLocalHome home = EJBUtil.getPerspectiveLocalHome();                    PerspectiveLocal cpt = home.create(pe.getPerspectiveID(), pe.getName(), pe.getConceptID(),                    pe.getStakeholderID(), pe.getDeclaretime(), pe.getProjectID(),                    pe.getPurpose(), pe.getContext(), pe.getContent());                    System.out.println("pe. stakeholder" + pe.getStakeholderID());                    Debug.println("PerspectiveController: created Perspective Perspective for " + pe.getPerspectiveID());                } catch (CreateException cre) {                    Debug.println(cre.toString());                    throw new StarsAppException("Unable to create a new Perspective for " + pe.getPerspectiveID() + " at this time");                }  catch (javax.naming.NamingException nme) {                    Debug.println(nme.toString());                    throw new EJBException("Irrecoverable error creating Perspective: " + pe);                }            } break;            case PerspectiveEvent.UPDATE_PERSPECTIVE_DATA: {                Debug.println("PerspectiveController (ejb): UPDATE_PERSPECTIVE event");                try {                    Debug.println("PerspectiveController (ejb): updating Perspective Perspective for " + pe.getPerspectiveID());                    PerspectiveLocalHome home = EJBUtil.getPerspectiveLocalHome();                    PerspectiveLocal cpt = home.findByPrimaryKey(pe.getPerspectiveID());                    cpt.updatePerspective(pe.getName(), pe.getConceptID(),                    pe.getStakeholderID(), pe.getDeclaretime(), pe.getProjectID(),                    pe.getPurpose(), pe.getContext(), pe.getContent());                } catch (javax.ejb.FinderException fde) {                    Debug.println(fde.toString());                                        throw new StarsAppException("Unable to find an Perspective/profile with Perspective id : " + pe.getPerspectiveID());                } catch (javax.ejb.NoSuchEntityException nee) {                    Debug.println(nee.toString());                                        throw new StarsAppException("Unable to find an Perspective/profile with Perspective id : " + pe.getPerspectiveID());                } catch (javax.naming.NamingException nme) {                    Debug.println("PerspectiveController naming exception: " + nme);                    throw new EJBException("Irrecoverable error while updating Perspective : " + nme);                }            } break;            case PerspectiveEvent.DELETE_PERSPECTIVE: {                Debug.println("PerspectiveController (ejb): DELETE_PERSPECTIVE event");                try {                    Debug.println("PerspectiveController (ejb): deleting Perspective Perspective for " + pe.getPerspectiveID());                    PerspectiveLocalHome home = EJBUtil.getPerspectiveLocalHome();                    PerspectiveLocal psp = home.findByPrimaryKey(pe.getPerspectiveID());                    psp.remove();                }catch (javax.ejb.FinderException fe) {                    throw new StarsAppException("Unable to find an Perspective/profile with Perspective id : " + pe.getPerspectiveID());                } catch (javax.ejb.RemoveException rme) {                    throw new StarsAppException("Unable to remove an Perspective/profile with Perspective id : " + pe.getPerspectiveID());                } catch (javax.naming.NamingException nme) {                    Debug.println("PerspectiveController naming exception: " + nme);                    throw new EJBException("Irrecoverable error while updating Perspective : " + nme);                }            } break;            default:                Debug.print("Error: not implemented yet");                break;        }    }}

⌨️ 快捷键说明

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