EJB遠(yuǎn)程接口
?
CabinRemotere""o





















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

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

???CrewmanRemote crew = ship.getrCrewman("Buns","john","lst liutenant");
????OfficerRemote burns = (officerRemote)
???PortableRemoteObject.narrow(ref,CabinRemote.class);
//當(dāng)方法簽名中制定了遠(yuǎn)程類(lèi)型時(shí),則不需要PortableRemoteObject.narrow();方法。
posted on 2007-01-24 17:59 youngturk 閱讀(322) 評(píng)論(0) 編輯 收藏 所屬分類(lèi): 關(guān)于EJB學(xué)習(xí)