eclipse+JBoss 5+EJB3¿ª·¢Ö¸ÄÏ(1)£º±àдµÚÒ»¸öÎÞ״̬µÄSessionBean - ±à³ÌÈëÃÅÍø
System.out.println(greeter.greet("ÀîÄþ"));
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ System.out.println(greeter.getAllGreetings().get(0).getName());
¡¡¡¡¡¡ }
}
eclipse+JBoss 5+EJB3¿ª·¢Ö¸ÄÏ(1)£º±àдµÚÒ»¸öÎÞ״̬µÄSessionBean(6)ʱ¼ä:2011-09-18 blogjava ¹þ·ðУѵÔÚÉÏÃæµÄ´úÂëÖУ¬Ê¹ÓÃÁËContext.PROVIDER_URLÉèÖÃÁË·þÎñ¶ËµÄIPºÍ¶Ë¿ÚºÅ¡£ ÉÏÃæ»ý´úÂëµÄÔËÐнá¹ûÈ磺 ÄúºÃ ÀîÄþ bill gates ³ýÁËÔÚ³ÌÐòÖÐÉèÖÃÊôÐÔÖµÍ⣬Ҳ¿ÉÒÔͨ¹ýjndi.propertiesÎļþ½øÐÐÉèÖ᣸ÃÎļþÓ¦·ÅÔÚEclipse¹¤³Ì µÄsrcĿ¼ÖС£¸ÃÎļþµÄÄÚÈÝÈçÏ£º java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=192.168.17.105:1099 Èç¹ûʹÓÃjndi.propertiesÎļþ£¬¾Í²»ÐèÒªÔÚ¿Í»§¶Ë³ÌÐòÖÐÉèÖÃÏàÓ¦µÄÊôÐÔÖµÁË£¬Òò´Ë£¬¿ÉÒÔʹÓÃÈçÏ µÄ´úÂëÀ´µ÷ÓÃSession Bean£º package test; import javax.naming.Context; import javax.naming.InitialContext; import service.Greeter; public class Client { ¡¡¡¡¡¡ public static void main(String[] args) throws Exception ¡¡¡¡¡¡ { ¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // ²»ÐèÒªÔÚ³ÌÐòÖÐÉèÖÃÏàÓ¦µÄÊôÐÔÖµ ¡¡¡¡¡¡¡¡¡¡¡¡¡¡ InitialContext ctx = new InitialContext(); ¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // ¿ªÊ¼µ÷ÓÃGreeter½Ó¿ÚµÄ·½·¨ ¡¡¡¡¡¡¡¡¡¡¡¡¡¡ Greeter greeter = (Greeter) ctx.lookup("GreeterBean/remote"); ¡¡¡¡¡¡¡¡¡¡¡¡¡¡ System.out.println(greeter.greet("ÀîÄþ")); ¡¡¡¡¡¡¡¡¡¡¡¡¡¡ System.out.println(greeter.getAllGreetings().get(0).getName()); ¡¡¡¡¡¡ } } ×¢Ò⣺ÔÚ±àд¿Í»§¶Ë³ÌÐòʱ£¬ÐèÒªÒýÓÃ<JBoss°²×°Ä¿Â¼>\clientĿ¼ÖеÄËùÓÐjarÎļþ¡£ |
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»! |