JBuilder9+Weblogic7ʵսƪ
SESSION BEANƪ
×÷Õߣº»Æ ¿
E_mail£º[email protected]
µÚ¶þƪ SESSION BEAN µÄÔËÓÃ
Ò»¡¢´´½¨ EJBs
1.Ôڲ˵¥À¸Ñ¡ÔñFile/New...£»
2.µã»÷Enterprise×ÓÒ³£»
3.Ñ¡ÔñEJB ModuleÈ»ºóµã»÷OK£¬³öÏÖEJB Module´°¿Ú£»
4.ÔÚNameºóÊäÈëMath£»
5.½«Version¸ü¸ÄΪEJB 2.0 compliant£»
6.µã»÷OK¡£ EJB µÄÉè¼ÆÔÚÎĵµ´°¿ÚÖнøÐС£
7.ÔÚÓÒ±ßMath×ÓÒ³ÖУ¬µã»÷µÚÒ»¸öCreate EJBµÄͼ±ê£¬µ¯³ö²Ëµ¥ºó£¬ÕÒµ½²¢µã»÷Session Bean;
8.ÔÚBean nameºóÊäÈëMathEJB;
9.½«Êó±êÒƵ½MathEJBÉÏ£¬°´ÓÒ¼ü£¬µ¯³ö²Ëµ¥£»
10.Ñ¡ÔñAdd/Method£¬Õâʱ³öÏÖÒ»¸ö»á»°¿ò£¬Äã¿ÉÒÔÔÚÉÏÃæ¶ÔÕâ¸ö·½·¨µÄÊôÐÔ½øÐÐÉèÖã»
11.ÔÚMethod nameºóÊäÈëadd£»
12.ÔÚReturn typeºóÊäÈëint£»
13.InterfacesÑ¡Ôñremote£»
14.ÓÒ¼üµ¥»÷add£¬ÔÚµ¯³ö²Ëµ¥ÖÐÑ¡ÔñView Bean source£»
15.ÕâʱEJBµÄÔ´´úÂë¾ÍÏÔʾ³öÀ´ÁË£¬¸ü¸Äadd·½·¨ÈçÏ£º
public int add(int num1, int num2){
int result = num1 + num2;
return result;
}
16.ÔÚ¹¤³Ì´°¿ÚÖÐ<Project Source>/mathsample°üÖÐÕÒµ½MathEJB.javaÎļþ£¬Ë«»÷´ò¿ªËü£»
17.½«
public int add() throws RemoteException;
Ì滻Ϊ£º
public int add(int num1, int num2) throws RemoteException;
18.ÔÚ¹¤³Ì´°¿ÚÖÐÕ¹¿ªMathÄ£¿é£»
19.Ë«»÷MathEJB£¬ÔÚÎĵµ´°¿ÚµÄGeneral×ÓÒ³Öн«Home JNDI name:µÄÄÚÈݸü¸ÄΪejb/MathEJB£»
20.File/Save ALL£»
21.MathÄ£¿éÓÒ¼ü´ò¿ª²Ëµ¥£¬Ñ¡ÔñMakeÒÔ±àÒëEJB classes£»
½ÓÏÂÀ´ÎÒÃDzâÊÔÒ»ÏÂÕâ¸öBeanÊÇ·ñÄÜÕý³£¹¤×÷¡£
¶þ¡¢´´½¨Ò»¸ö¿Í»§¶ËÓÃÀ´²âÊÔÕâ¸öBean
JBuilderΪÎÒÃÇÌṩÁËÒ»¸öÕâÑùµÄ²âÊÔ¿Í»§¶Ë¡£
1.Ôڲ˵¥À¸Ñ¡ÔñFile/New...£»
2.µã»÷Enterprise×ÓÒ³£»
3.Ñ¡ÔñEJB Test ClientÈ»ºóµã»÷OK£¬³öÏÖEJB Test Client´°¿Ú£»
4.µã»÷Next£¬È·ÈÏEJB nameºóµÄÄÚÈÝÊÇMathEJB£»
5.ֻѡÖÐGenerate Main Function£¬È»ºóµã»÷Finish£»
6.ÔÚÎĵµ´°¿ÚÖÐÑ¡ÖÐMathEJBTestClient1×ÓÒ³£¬ÔÚ´úÂë¶ÎÇëÈ·ÈÏÊÇ·ñº¬Óд˾䣺
Object ref = context.lookup("ejb/MathEJB");
7.ÔÙÈ·ÈÏURLÊÇ·ñΪ£º
String url = "t3://localhost:7001";
8.ÔÚmain·½·¨ÖÐÌí¼Ó£º
try {
MathEJBHome home = client.getHome();
MathEJB test = home.create();
System.out.println("Result is: "+test.add(12,12));
}
catch (Exception e) {
System.out.println(e.toString());
9.Save ALL;
×¢£ºÒÔÏÂÕâ²½·Ç±ØÐëµÄ£¬ÄãÖ±½ÓÊÖ¹¤Æô¶¯WeblogicÒ²¿ÉÒÔ£¬µ«ÊDZØÐëÒ²Ö»ÐèÆô¶¯Ò»¸ö¡£
Èý¡¢ÅäÖà server
1.Ôڲ˵¥À¸Ñ¡ÔñRun/Configurations...£»
2.Ñ¡ÔñRun×ÓÒ³£»
3.µã»÷New£»
4.ÔÚNameºóÊäÈëServer£»
5.ÔÚTypeÖÐÑ¡ÔñServer£»
6.µã»÷OK¡£
ËÄ¡¢²¿ÊðºÍÔËÐÐ
1.ÔÚ¹¤¾ßÀ¸ÖÐͨ¹ýrun projestÑ¡ÔñÖ´ÐÐServer£¬Æô¶¯Weblogic£»
2.È»ºóÔÚ¹¤³Ì´°¿ÚÖÐÕÒµ½MathÄ£¿éϵÄMath.jar£¬ÓÒ¼ü´ò¿ª²Ëµ¥£¬Ñ¡ÔñDeployOptions for "Math.jar"/Deploy½«ÆäÔÚWeblogicÖв¿Êð£»
3.ÔÚ¹¤³Ì´°¿ÚÖÐÕÒµ½MathEJBTestClient1.java£¬ÓÒ¼ü´ò¿ª²Ëµ¥£¬µã»÷Run using "MathEJBTestClient1"£»
4.ÔÚÐÅÏ¢´°¿ÚÖУ¬ÎÒÃÇ¿ÉÒÔ¿´¼û£º
Result is: 24
OK£¬ÖÁ´ËÄã³É¹¦µØ×öÁ˵ÚÒ»¸öµÄSession BeanÁË¡£
ÇмǣºWeblogicÖ»ÒªÆô¶¯Ò»¸ö¾Í¿ÉÒÔÁË£¬¶Ë¿ÚÒ»¶¨ÒªÊÇ7001£¬Èç¹û²»ÊǾÍÒª½«¡°String url = "t3://localhost:7001";¡±¸Ä³ÉÄã¶ÔÓ¦µÄ¶Ë¿Ú¡£
ÎÒµÄÎÄÕÂÊ×·¢Å£¶úÂÛ̳£¨www.newer.com.cn/bbs£©ºÍ³ÌÐòÔ±ÂÛ̳£¨www.csdn.net£©£¬»¶ÓתÔØ£¬²»¹ý£¬Çë±£Áô×÷ÕßÒÔ¼°ÐÞ¶©ÕßµÄÃû×Ö£¬Ð»Ð»¡£
±¾ÎĵØÖ·£ºhttp://com.8s8s.com/it/it17506.htm