EJB遠程接口
?
CabinRemotere""o





















???????????? ShipRemote ship = (ShipRemote)
???????????????PortableRemoteObject.narrow(ref,ShipRemote.class);//返回一個實現了指定Remote接口的存根

3,當使用javax.ejb.Handle.getEJBObject()方法得到一個遠程EJB對象引用時:
???Handle handle = .....//得到Handle
???Object ref = handle.getEJBObject();
???CabinRemote cabin = (CabinRemote);
???PortableRemoteObject.narrow(ref,CabinRemote.class);
4,當使用javax.ejb.HomeHandle.getEJBHome()方法得到一個遠程EJBhome引用時:
???homeHandle home = ........//得到home Handle
???EJBHome ref = homeHandle.getEJBHome();
???CabinHomeRemoteObject.narrow(ref,CabinHomeRemote.class);
5,當使用javax.ejb.EJBMetadata.getEJBHome()方法得到一個遠程EJB home引用時:
???EJBMetaData metaDta = homeHandle.getEJBMetaData();
???EJBHome ref = homeHandle.getEJBHome();
???CabinHomeRemoteObject.narrow(ref,CabinHomeRemote.class);
6,當由人和業務方法返回一個寬(即較一般)的遠程EJB對象類型時;以下是一個假象例子:
???//officer擴展了Crewman
???ShipHomeRemote?shipHome?=?

???CrewmanRemote crew = ship.getrCrewman("Buns","john","lst liutenant");
????OfficerRemote burns = (officerRemote)
???PortableRemoteObject.narrow(ref,CabinRemote.class);
//當方法簽名中制定了遠程類型時,則不需要PortableRemoteObject.narrow();方法。
posted on 2007-01-24 17:59 youngturk 閱讀(321) 評論(0) 編輯 收藏 所屬分類: 關于EJB學習