Java⢠API for RESTful Web Services (JAX-RS) 2.0 ã¯ã WebSphere® Application Server traditional V9㧠Enterprise JavaBeans (EJB) ããã³ Contexts and Dependency Injection (CDI) ã¨çµ±åãã¾ãã JAX-RS 2.0 ãã¨ã³ã¿ã¼ãã©ã¤ãº Bean ã¨ã¨ãã«æ©è½ããããã«ã¯ã @Path ã使ç¨ã㦠Bean ã®ã¯ã©ã¹ã«ã¢ããã¼ã·ã§ã³ãä»ãããããã«ã¼ãã»ãªã½ã¼ã¹ã»ã¯ã©ã¹ã«å¤æããå¿ è¦ãããã¾ãã EJB ã¨ã®çµ±åã«ãããEJB Bean ã«ã¢ããã¼ã·ã§ã³ãä»ãã¦ãããã REST ã¨ã³ããã¤ã³ãã¨ãã¦ç¤ºããã¨ãã§ãã¾ãã ã¾ããJava Transaction API (JTA) ããã³ EJB ã®ã»ãã¥ãªãã£ã¼æ©è½ã使ç¨ãããã¨ãã§ã
ã¨ã³ã¿ã¼ãã©ã¤ãºããæã¡ã®å ´åJavaBeansãã¼ã«ã« ã¤ã³ã¿ã¼ãã§ã¼ã¹ ãã¥ã¼ã使ç¨ãã¦å ¬éããã (EJB) ã¢ããªã±ã¼ã·ã§ã³ã®å ´åãJava⢠API for RESTful Web Services (JAX-RS) ã使ç¨ãã¦ãã¨ã³ã¿ã¼ãã©ã¤ãº Bean ã« RESTful ã¤ã³ã¿ã¼ãã§ã¼ã¹ãå ¬éã§ãã¾ãã JAX-RSã¢ããã¼ã·ã§ã³ä»ãã¨ã³ã¿ã¼ãã©ã¤ãºBeanãå®è£ ãããã¨ã§ããã©ã³ã¶ã¯ã·ã§ã³ãµãã¼ãã Java EEã³ã³ãã¼ãã³ãã¨ãªã½ã¼ã¹ãããã³ãã®ä»ã® EJB ã»ãã·ã§ã³ Bean æ©è½ã EJB以å3.1 EJB ãã¼ã«ã« ã¯ã©ã¤ã¢ã³ã ãã¥ã¼ãå¿ è¦ã¨ããã¨ã³ã¿ã¼ãã©ã¤ãº Bean ã«ã¯ããã¼ã«ã« ãã¥ã¼ ã¡ã½ããã宣è¨ããå¥ã® Java ã¤ã³ã¿ã¼ãã§ã¤ã¹ (é常ã¯å¥ã®ãã¡ã¤ã«å ) ãå¿ è¦ã§ããã ã¨ã³ã¿ã¼ãã©ã¤ãº Bean ã¯ããããã¤ã¡ã³ãè¨è¿°åã¾ã㯠EJB ã¢
2010å¹´4æ7æ¥ at 8:32 åå¾ EJB 3.1 ã®æ°æ©è½ããã¬ã¼ã³å½¢å¼ã§ã¾ã¨ãã¦ã¿ã¾ããã ããããã«æ¦è¦ãç´¹ä»ãã¾ãã EJB 3.0 ãã EJB 3.1 ã«ãªããããããéçºã«åãã¦å¤ãã®æ¹åãæ½ããã¦ãã¾ããã¾ããããã±ã¼ã¸ã®ç°¡ç¥åãæãããã¾ããä»ã¾ã§ã¢ããªã±ã¼ã·ã§ã³ã®ç¨®é¡ã«å¿ã㦠.ear, .war çã®ã¢ã¼ã«ã¤ãã«ã¾ã¨ããå¿ è¦ãããã¾ããããEJB ã³ã³ãã¼ãã³ãã .war ã«å«ãããã¨ãã§ããããã«ãªã£ãããéçºæã®æéãå¤§å¹ ã«åæ¸ããã¾ããã¾ããEJB 3.1 Lite ãæä¾ãããã« Java EE ã®æ©è½ã®ä¸é¨ã®æ©è½ã ããå©ç¨ã§ããããã«ãªã£ãããããã« Java EE ã®æ©è½ãå¿ è¦ãªãã客æ§ã«ã¨ã£ã¦ã¯ä¸è¦ãªã¡ã¢ãªãªã½ã¼ã¹ãæ¶è²»ããã«éç¨ã§ããçã®ã¡ãªãããããã¾ãã 次ã®ãã¤ã³ãã¯ãã¼ã«ã«ãã¸ãã¹ã¤ã³ã¿ãã§ã¼ã¹ã®å®è£ ãå¿ è¦ãªããªã£ãç¹ã§ããããã¯éçºè
ä¸ã«åºã¦ããEJBã®èª¬æã¯ã¯ã½ã¿ãããªãã®ãå¤ããç°¡æ½ã«æ©è½ãç¹å¾´ãè¨è¿°ãã¦ãããã®ãè¦å½ãããªãã®ã§æ¸ãã¾ãããJava EE 6, 7ã対象ã¨ãã¦æ¸ãã¦ãã¾ãã EJBã¨ããã®ã¯Java EEã¢ããªã±ã¼ã·ã§ã³ãµã¼ãä¸ã§å©ç¨ã§ããJavaã®ã³ã³ãã¼ãã³ãã§ãããã©ã³ã¶ã¯ã·ã§ã³å¶å¾¡ãªã©ã®ç ©éãªé¨åãEJBãèªåçã«é¢åãè¦ã¦ãããã®ã§ãéçºè ã¯EJBã®åºæ¬çãªã«ã¼ã«ãæãããã¨ã¯ãã¸ãã¹ãã¸ãã¯ã®è¨è¿°ã«éä¸ãããã¨ãã§ãããã¨ãããã®ã§ããEJBã«ã¯4種é¡ããã¾ãã åºæ¬ã¨ãªãã¹ãã¼ãã¬ã¹ã»ãã·ã§ã³ãã¼ã³ (Stateless Session Bean, SLSB) ç¶æ ãä¿æã§ããã¹ãã¼ããã«ã»ãã·ã§ã³ãã¼ã³ (Stateful Session Bean, SFSB) åä¸ã¤ã³ã¹ã¿ã³ã¹ã®ã·ã³ã°ã«ãã³ã»ãã·ã§ã³ãã¼ã³ (Singleton Session Bean, SSB) ã¡ãã»ã¼ã¸(
ãã®ç¨åº¦ã®è¦ä»¶ã§ããã°ãEJBã®ã¢ããã¼ã·ã§ã³ï¼@Statelessã¨ã@EJBã¨ãï¼ã¯ã使ãçç±ãç¡ãã®ã§ããï¼ ãªãã§ããDIãAOPããã©ã³ã¶ã¯ã·ã§ã³ç®¡çã«é¢ãã¦ã¯ãæ¢ã« CDI 㨠JTA ã ãã§å¯¾å¿ã§ãã¾ãããå¤ãã®å ´åãã®æ¹ãããã©ã¼ãã³ã¹ãè¯ãã§ãã å¤ã® J2EE ã¯ä½ã§ãããã§ã EJB ã«è©°ãè¾¼ãã§ãã¾ããããã®å½æã®é¸æã¨ãã¦ã¯ééã£ã¦ã¯ããªãã£ãã®ã§ããããã¾ãã«å¤§ããéããªãéãããããç¾å¨ã§ã¯ CDI ãçé ã¨ããå¨è¾ºã®ä»æ§ã«æ©è½ã移管ãå§ãã¦ãã¾ã (æçµçã«ã¯ EJB ãåé¤ãããå¯è½æ§ãããã¾ã)ãäºææ§ã®ãããã°ããã®é㯠EJB ã¨ä»£æ¿ä»æ§ã®å ±åã«ãªãã§ãããããæ°è¦éçºæã«ã¯åºæ¬çã« EJB ã§ã¯ãªãæ¹ã®ä»æ§ãåªå ããæ¹ãè¯ãã§ããããå ·ä½çã«ã¯ãCDI ã EJB ãã§è¿·ã£ãã¨ãã«ã¯ãç¹å¥ãªçç±ããªããã° CDI ãé¸æããæ¹ãå¾çã§ãã ç¾æç¹ã§
ãã®ãããã¯ã§ã¯ãã¨ã³ã¿ã¼ãã©ã¤ãºã使ç¨ããå ´åã®ã¢ããªã±ã¼ã·ã§ã³ã®ããã±ã¼ã¸åã«ã¤ãã¦èª¬æãã¾ãã JavaBeans ï¼EJBï¼ 3.xè±ã EJBã使ç¨ããã¢ããªã±ã¼ã·ã§ã³ã®ããã±ã¼ã¸å3.xè±ã®çµã¿ç«ã¦è¦ä»¶ã¯ã Java⢠Platform, Enterprise Editionï¼ Java EE ï¼ 1.4ã¢ããªã±ã¼ã·ã§ã³: ã³ã³ãã¼ãã³ãã¯ã¢ã¸ã¥ã¼ã«ã«ããã±ã¼ã¸åãããã¢ã¸ã¥ã¼ã«ã¯ã¢ããªã±ã¼ã·ã§ã³ ã¨ã³ã¿ã¼ãã©ã¤ãº ã¢ã¼ã«ã¤ã (EAR) ãã¡ã¤ã«ã«ããã±ã¼ã¸åããã¾ãã ã³ã³ãã¼ãã³ãããã³ã¢ã¸ã¥ã¼ã«ã«ã¯ãã¨ãã«ãExtensible Markup Language (XML) ãããã¤ã¡ã³ãè¨è¿°åå ã§è¨è¿°ã¡ã¿ãã¼ã¿ãæä¾ããã¦ãã¾ãã EJB 3.x ä»æ§ã§ã¯ãã¡ã¿ãã¼ã¿ã®è¨è¿°ããã³ãã¼ã·ã¹ã¿ã³ã¹ã»ã¦ãããã®ããã±ã¼ã¸åã®è¿½å ã®ã¡ã½ããããµãã¼ãããã¦ãã¾ãã EAR ãã¡
ã¨ã³ã¿ã¼ãã©ã¤ãº Bean ã§ã¯ãEJB ã¿ã¤ãã¼ã»ãµã¼ãã¹ã使ç¨ããæéãã¼ã¹ã®ã¤ãã³ããã¹ã±ã¸ã¥ã¼ã«ã§ãã¾ãã EJB 3.1 ä»æ§ããµãã¼ããã¦ãéãã¼ã·ã¹ã¿ã³ã EJB ã¿ã¤ãã¼ãä½æã§ãã¾ãã æ¬è£½åã¯ãã¿ã¤ãã¼ãããã°ã©ã ã§ä½æã§ããããã«æ¡å¼µ TimerService API ã ãµãã¼ããã¦ãã¾ãã ã¾ããã¢ããªã±ã¼ã·ã§ã³ãéå§ãããèªåçã«ã¿ã¤ãã¼ãä½æ ããããã« EJB ã³ã³ããã¼ãæ§æãããã¨ãã§ãã¾ãã WebSphere® Application Serverã¨ã³ã¿ã¼ãã©ã¤ãºãå®è£ ããJavaBeans(EJB ) ã¿ã¤ãã¼ãµã¼ãã¹ã ãã¸ãã¹ã®ãã¼ãºã«åºã¥ãããã¼ã·ã¹ã¿ã³ãã»ã¿ã¤ãã¼ã¾ãã¯éãã¼ã·ã¹ã¿ã³ãã»ã¿ã¤ãã¼ã使ç¨ã§ãã¾ãã ãã¼ã·ã¹ã¿ã³ãã»ã¿ã¤ãã¼ã¯ããµã¼ãã¼ã®ã©ã¤ããµã¤ã¯ã«ãè¶ãã¦åç¶ãããã¨ãè¦æ±ãããæéãã¼ã¹ã®ã¤ãã³ãã«å¯¾ãã¦ã¿ã¤ãã¼ãä½æãã
ç°å¢æ§ç¯ã¯ ãã¡ãã ã½ã¼ã¹ã³ã¼ã㯠GitHub ã«ããã¦ãã¾ãã https://github.com/opengl8080-javaee-samples/ejb #EJB ã¨ã¯ Enterprise Java Beans ã®ç¥ã ãã¸ãã¹ãã¸ãã¯ãç°¡æ½ã«å®è£ ã§ããããã«ãã¦ãããä»çµã¿ã»ãã¬ã¼ã ã¯ã¼ã¯ã ãã¸ãã¹ãã¸ãã¯ãæã¤ã¯ã©ã¹ã¯ POJO ã§ä½æã§ããã¨ã³ã¿ã¼ãã©ã¤ãºã¢ããªã±ã¼ã·ã§ã³ã§å¿ è¦ã«ãªããã©ã³ã¶ã¯ã·ã§ã³å¶å¾¡ããªã½ã¼ã¹ï¼JNDI, ä»ã® EJB ãªã©ï¼ã®åå¾ãã»ãã¥ãªãã£å¶å¾¡ã AOP ãªã©ãªã©ã®æ©è½ã¯ã³ã³ãããã»ã¨ãã©èªåã§æä¾ãã¦ãããã ããã«ãããããã°ã©ãã¼ã¯ãã¸ãã¹ãã¸ãã¯ã®å®è£ ã«éä¸ã§ããããã«ãªãã #ããã¸ã§ã¯ãä½æ ã³ã³ããã¹ãã«ã¼ãã ejb ã«ãªãããã«ã NetBeans 㧠Web ããã¸ã§ã¯ããä½æããã #Hello World
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}