OSGiã«ããæå©
Javaã§çã®ã¢ãžã¥ã©ãŒã¢ãŒããã¯ãã£ãäœæããã«ã¯ãOSGiïŒOpen Services Gateway InitiativeïŒ-Javaã¢ããªã±ãŒã·ã§ã³çšã®åçã¢ãžã¥ã©ãŒã·ã¹ãã ããã³ãµãŒãã¹ãã©ãããã©ãŒã ã®ä»æ§ïŒOSGi AllianceãéçºïŒã䜿çšã§ããŸãã ã³ã³ããŒãã³ããã¢ãžã¥ã©ãŒã¢ããªã±ãŒã·ã§ã³ã®3ã€ã®äž»èŠãªå±æ§ãæã€ãœãããŠã§ã¢éçºã¢ãã«ã«ã€ããŠèª¬æããŸãã ã«ãã»ã«åïŒåã¢ãžã¥ãŒã«ã¯å®è£ ãå€éšç°å¢ããé ããŸãïŒã匱ãæ¥ç¶ïŒã¢ãžã¥ãŒã«ã¯ä»¥åã«åæããå¥çŽãšã®ã¿çžäºäœçšããŸãïŒãããã³ãã€ãããºã ïŒã³ã³ããŒãã³ãã¯ã¢ããªã±ãŒã·ã§ã³å šäœãåæ¢ããã«ãã®å Žã§äº€æã§ããŸãïŒã«ã€ããŠè©±ããŸãã OSGiã³ã³ã»ããã®åºç€ã¯ããã³ãã«ãšãµãŒãã¹ã®2ã€ã®ãšã³ãã£ãã£ã§ãã
ãã³ãã«
Javaã§ãœãããŠã§ã¢ãéçºããå ŽåãååãšããŠããµãŒãããŒãã£ã®ã©ã€ãã©ãªã䜿çšãããŸãã äžçã§ã¯ãJavaã©ã€ãã©ãªãŒã¯ãJavaã¯ã©ã¹ïŒ.classæ¡åŒµåãæã€ãã¡ã€ã«ïŒãå«ãéåžžã®ZIPã¢ãŒã«ã€ãã§ããJARæ¡åŒµåïŒJava ARchiveïŒãæã€ãã¡ã€ã«ã«ããã±ãŒãžåãããŠããŸãã ããã«ãã©ã€ãã©ãªã®äœ¿çšã«ã¯ç¹å®ã®å°é£ã䌎ãå ŽåããããŸãã
ã©ã€ãã©ãªã®äœ¿çšãéå§ãããšãååãšããŠãã©ã€ãã©ãªå ã®ãã¹ãŠã®ã¯ã©ã¹ã䜿çšå¯èœã«ãªããŸãã å®éãã©ã€ãã©ãªéçºè ã«ã¯ãå éšããžãã¯ã®å®è£ ã«äœ¿çšãããã¯ã©ã¹ãé衚瀺ã«ããæ©èœããããŸããã ãããã£ãŠãã©ã€ãã©ãªã®å€éšã§äœ¿çšããããšãæå³ããŠããªãã³ãŒãã䜿çšãããšãã©ã€ãã©ãªã®æ°ããããŒãžã§ã³ã䜿çšãããšãã«éäºææ§ãçºçããããæ£ããæ©èœãæãªããããããå¯èœæ§ããããŸãã
ãã1ã€ã®åé¡ã¯ãããããJARå°çã§ããããã«ã€ããŠãéçºè ã¯å€§éã®ã³ããŒãç Žå£ããŸããã ãã®æ¬è³ªã¯æ¬¡ã®ãšããã§ããåãã©ã€ãã©ãªã®ç°ãªãããŒãžã§ã³ã䜿çšãå§ãããšããã«ïŒããã¯æéãšãšãã«é²åãã倧èŠæš¡ãªãããžã§ã¯ãã§çºçããŸãïŒãåãã¯ã©ã¹ãã©ã€ãã©ãªã®ç°ãªãããŒãžã§ã³ã§ç°ãªãã¡ãœãããæã€ãšããäºå®ã«ééããå¯èœæ§ããããŸãã Javaã¯ãã¯ã©ã¹ããŒããŒãæ€åºããã©ã€ãã©ãªã®æåã®ããŒãžã§ã³ã䜿çšãããããã«èšèšãããŠããŸãã ãããã£ãŠãããã°ã©ã ã®å®è¡äžã«ã³ãŒãå ã®ã¯ã©ã¹ãåç §ãããšãã¢ã¯ã»ã¹ããŠããã¡ãœãããååšããªããšãããšã©ãŒã衚瀺ãããŸãã ããã¯ãå®è¡æã«ãJavaãç¹å®ã®ã±ãŒã¹ã§äœ¿çšãããã©ã€ãã©ãªã®ããŒãžã§ã³ã«ã€ããŠäœãç¥ããªããšããäºå®ã«ãããã®ã§ãã
OSGiéçºè ã¯ãã¢ãžã¥ãŒã«æ§ã確ä¿ããããã«JARãã¡ã€ã«ã®æ§é ãå€æŽããŸããã§ããããOSGiç°å¢ã§äœ¿çšãããè¿œå æ å ±ãåã«è¿œå ããŸããã ããã«ããã®æ å ±ã¯ãéåžžã®Javaã¢ããªã±ãŒã·ã§ã³ã§ã®JARãã¡ã€ã«ã®äœ¿çšã«ã¯ãŸã£ãã圱é¿ããŸããã ãããã£ãŠãJARãã¡ã€ã«ãOSGiã»ããã«ããããã«ãExport-PackageïŒãã®ã»ããã®ããã±ãŒãžã¯å€éšã§äœ¿çšå¯èœïŒãšImport-PackageïŒãã®ã»ãããæ©èœããããã«å¿ èŠãªä»ã®ã»ããã®ããã±ãŒãžïŒãå®çŸ©ããããŒã¿ãè¿œå ãããŸãã ãã®å Žåãã»ãããä»ã®ã»ããã«æäŸããAPIã®ããŒãžã§ã³ãšããã®ã»ãããäœæ¥ã®ããã«å¿ èŠãšããAPIã®ããŒãžã§ã³ãŸãã¯ããŒãžã§ã³ã®ç¯å²ã®äž¡æ¹ãæå®ããããšãã§ããŸãã ãšã¯ã¹ããŒããããã»ã¯ã·ã§ã³ã«ãªããã¹ãŠã®ã³ã¬ã¯ã·ã§ã³ã¯ã©ã¹ã¯ãã³ã¬ã¯ã·ã§ã³ïŒãã©ã€ããŒãïŒã®å€éšããã¢ã¯ã»ã¹ã§ããŸããã ãã®ããã«ããŠãOSGiã¹ã€ãŒãã¯åŒ±ãæ¥ç¶èŠä»¶ãæºãããŸãã
ä»æ¥ãã»ãšãã©ã®Javaã©ã€ãã©ãªã¯ãã§ã«OSGiã«å¯Ÿå¿ããŠããŸãã OSGiã³ã³ããã§å®è¡ã§ããããã«ããããã®æ å ±ãå«ãŸããŠããŸãã ããã«ãéåžžã®JARãã¡ã€ã«ããOSGiçšã®ã¢ãžã¥ãŒã«ãäœæã§ããå€ãã®ããŒã«ãšãŠãŒãã£ãªãã£ããããŸãã
å³ 1ã
OSGiã§ã¯ãã»ãããšãããã®ã»ããã«ãã£ãŠæäŸãããã€ã³ã¿ãŒãã§ã€ã¹éã®äŸåé¢ä¿ã«æ確ãªããŒãžã§ã³ããããããJAR Hellã®ç¶æ³ãç°¡åã«åé¿ã§ããŸãã å®è¡æã«æ°ããã»ãããåçã«ããŒãããã³ã¢ã³ããŒãã§ããŸãã OSGiã¯ã»ããéã®äŸåé¢ä¿ã远跡ããããããåçã«è§£æ±ºããŸãã
ãµãŒãã¹
ãããã£ãŠãOSGi-kitã®å©ããåããŠãã€ã³ã¿ãŒãã§ãŒã¹ïŒAPIïŒãä»ããŠå¯Ÿè©±ããã¢ãžã¥ãŒã«åŒã¢ããªã±ãŒã·ã§ã³ãéçºã§ããŸãã ããããå¿ èŠãªã€ã³ã¿ãŒãã§ã€ã¹ãå®è£ ããã¯ã©ã¹ã¯ã©ãã§å ¥æã§ããŸããïŒ ãªãã·ã§ã³ãã»ããAPIã«è¿œå ãã¯é©åããŸãã-ã¢ãžã¥ã©ãŒã¢ãŒããã¯ãã£ã®äžéšãšããŠããããã®ã»ããå€ã®ã»ããã®å éšã¯ã©ã¹ã䜿çšããªãããšã«åæããŸããã å¥ã®è§£æ±ºçã¯ãã€ã³ã¿ãŒãã§ã€ã¹ãå®è£ ããŠãã¡ã¯ããªAPIãé©çšããã³ã¬ã¯ã·ã§ã³APIã«è¿œå ããããšã§ãã ããããããŸãæåããŠããŸããããªããªãã ã€ã³ã¿ãŒãã§ã€ã¹ã®å®è£ ãé ãã«ã¯ãæ¯åæ°ããã¯ã©ã¹ãéçºããå¿ èŠããããŸãã
OSGiã§ã®ã€ã³ã¿ãŒãã§ãŒã¹ã®å®è£ ã®æ€çŽ¢ã¯ããµãŒãã¹ã¬ãžã¹ããªã䜿çšããŠå®è¡ãããŸãã ãã®ã¬ãžã¹ããªã§ã¯ãã³ã¬ã¯ã·ã§ã³ã¯ããããèšè¿°ããã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšããŠå®è£ ãç»é²ã§ããŸãã å¥ã®ã»ããã®ã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšããã»ããã¯ãã¬ãžã¹ããªã§ç®çã®ã€ã³ã¿ãŒãã§ã€ã¹ã®å¿ èŠãªå®è£ ãèŠã€ããããšãã§ããŸãã éåžžãOSGiã³ã³ãããŒã§å®è¡ãããå Žåãã»ããã¯ç»é²ãµãŒãã¹ãèšå®ããŸãã ããã«ãç°ãªãå®è£ ãšè¿œå ã®èå¥ããŒã¿ãåããåãã€ã³ã¿ãŒãã§ãŒã¹ããµãŒãã¹ã¬ãžã¹ããªã«ç»é²ã§ããŸãã ãã£ã«ã¿ãªã³ã°ã䜿çšãããšãã»ããã¯ã¬ãžã¹ããªã§æ瀺ããããµãŒãã¹ã®äžã§æãé©åãªãã®ãéžæã§ããŸãã
å³ 2ã
ãã€ã¯ããµãŒãã¹Javaä»®æ³ãã·ã³
ãã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ã¯ãç¬ç«ããã¢ãžã¥ãŒã«ã®ã»ãã-åå¥ã®ã¢ããªã±ãŒã·ã§ã³ã§ãã ãããã®éã®çžäºäœçšã¯ã軜éãããã³ã«ïŒRESTããããã³ã«ãããã¡ãŒãMQãªã©ïŒã䜿çšããŠæ確ã«å®çŸ©ãããã€ã³ã¿ãŒãã§ã€ã¹ãä»ããŠçºçããŸãã å®éãåã¢ãžã¥ãŒã«ã¯1ã€ã®ç¹å®ã®ã¿ã¹ã¯ãå®è¡ãããã€ã¯ããµãŒãã¹ã§ãããéåžžãæå°éã®ã³ãŒããå«ãŸããŠããŸãã ãœãããŠã§ã¢éçºã«å¯Ÿãããã®ã¢ãããŒãã®å©ç¹ïŒ
- 軜ãïŒãã€ã¯ããµãŒãã¹ã®éçºæã«ã¯ãããã°ã©ã ã®æ©èœã®äžéšã®ã¿ãå®è£ ãããŸãïŒã
- 亀æã®å®¹æãïŒãµãŒãã¹ããã®ã¿ã¹ã¯ã«å¯Ÿå¿ããŠããªãå ŽåãçŸåšã®ãœãããŠã§ã¢ãåæ¢ããã«æžãæããŠæ°ããããŒãžã§ã³ã«çœ®ãæããããšãã§ããŸãïŒã
- åå©çšïŒãã€ã¯ããµãŒãã¹ã¯é©åãªå Žæã§åå©çšã§ããŸãïŒã
OSGiã䜿çšããã¢ãžã¥ã©ãŒã¢ããªã±ãŒã·ã§ã³ã®éçºè ã¯ãããããã¹ãŠã®å©ç¹ãé·ãé享åããŠããŸããããJavaä»®æ³ãã·ã³å ã§ã®ã¿ã§ãã ã¬ãžã¹ããªã«ãµãŒãã¹ãå ¬éããåOSGiã¹ã€ãŒãã¯ãJavaä»®æ³ãã·ã³JVMå ã®ãã€ã¯ããµãŒãã¹ã§ãïŒOSGiã®äžçã§ã¯ããããã®ãã€ã¯ããµãŒãã¹ã¯ÂµServicesãšåŒã°ããŸãïŒã
Red Hat JBoss Fuse
Jetã§ã¯ãéä¿¡äºæ¥è ãä¿éºãããã³åŠçäŒç€Ÿåãã®ãœãããŠã§ã¢ãéçºããéã«ãOSGiã®ãã¹ãŠã®å©ç¹ã掻çšããŠããŸãã ãããè¡ãã«ã¯ãRed Hat JBoss FuseïŒFuse Fabricèšå®ïŒã䜿çšããŸãã ãã®ãã©ãããã©ãŒã ã¯ãã¢ãžã¥ã©ãŒã¢ããªã±ãŒã·ã§ã³ãå®è¡ããããã®æè»ãªOSGiç°å¢ãæäŸããŸãã
ã¢ããªã±ãŒã·ã§ã³æäœã®ç¶ç¶æ§ãç°¡åãªæ°Žå¹³ã¹ã±ãŒãªã³ã°ãå±éã®å®¹æããã¯ã©ã¹ã¿ãŒãœãããŠã§ã¢ã®ã¯ã©ã¹ã¿ãŒç®¡çããŒã«ã®å¯çšæ§-ãããã®æ©èœã¯ãã¹ãŠãFuse Fabricã§å©çšã§ããŸãã ãã®ãã¯ãããžãŒã«ãããRed Hat JBoss Fuseã®è€æ°ã®ã€ã³ã¹ã¿ã³ã¹ããããã€ããããããã¯ã©ã¹ã¿ãŒã«çµåããããšãã§ããŸãããŸããçµæã®ç°å¢ã管çããããã®éäžããŒã«ãæäŸããŸãã
Fuse Fabricã«ã¯æ¬¡ã®æœè±¡åããããŸãã
æ©èœ ïŒæ©èœïŒ-ä»»æã®æ©èœãå®è£ ããOSGiã»ããã®ã»ããã
ãããã¡ã€ã« ïŒãããã¡ã€ã«ïŒ-åãã³ã³ããå ã§å®è¡ããå¿ èŠãããæ©èœã®ã»ãããããã³æ©èœã«å«ãŸããã»ããã®æ§æèšå®ã
ã³ã³ãããŒã¯ãRed Hat JBoss Fuseã³ã³ãããŒã®å¶åŸ¡äžã§Fuse Fabricã¯ã©ã¹ã¿ãŒã®ç¹å®ã®ããŒãã§å®è¡ãããåã ã®JVMããã»ã¹ã§ãã
å³ 3ã
Fuse Fabricãã¯ãããžã«åºã¥ããœãããŠã§ã¢ã¯ãæ©èœã«ã°ã«ãŒãåãããäºåå®çŸ©ããããããã¡ã€ã«ã«åŸã£ãŠ1ã€ä»¥äžã®ã¯ã©ã¹ã¿ãŒããŒãã«åå¥ã®JVMããã»ã¹ã®äžéšãšããŠãããã€ãããOSGiã»ããã§æ§æãããŸãã
Fuse Fabricç°å¢ã«ã¯ãçæãããã¯ã©ã¹ã¿ãŒãç°¡åã«ç®¡çããããã®å€ãã®ããŒã«ãçšæãããŠããŸãã ãããã¡ã€ã«ïŒããã³ãããã«åºã¥ãã³ã³ãããŒïŒã®äœæãã¯ã©ã¹ã¿ãŒå ã®ä»»æã®ãã¹ãã§ã®ã³ã³ãããŒã®äœæ/åé€/éå§/åæ¢ãæ°ããã¯ã©ã¹ã¿ãŒããŒãã®æ¥ç¶ãªã©ãã§ããŸãã ãããŠããã®ãã¹ãŠããªã³ã©ã€ã³ã§-ã¯ã©ã¹ã¿ãŒã®æ®ãã®ããŒãã®æ©èœãäžæããããšãªãã ãããã¡ã€ã«ãæ©èœãOSGiã»ããã®è€æ°ã®ããŒãžã§ã³ãä¿åããããšãã§ããŸãã
åæ£OSGiãã¯ãããžãŒã®ãããã§ãçµæãšããŠçããç°å¢ã§ã¯ãOSGiãããã¯åããŸãã¯ç°ãªãã³ã³ãããŒå ãããã«ã¯ç°ãªããã¹ãå ã§çžäºäœçšã§ããŸãã ããã«ïŒæå°éã®éçºã³ã¹ãã§ïŒOSGiã¹ã€ãŒããæäŸããåãµãŒãã¹ã¯ãå€éšã·ã¹ãã ããåŒã³åºãããšãã§ããREST / WebãµãŒãã¹ã«å€æã§ããŸãã
ãããã£ãŠãFuse Fabricã䜿çšãããšãæ§æãšå±éã®å®¹æããJVMããã»ã¹å ã§ã®ãµãŒãã¹ã®ç¬ç«ããå®è¡ïŒã¬ããŒãžã³ã¬ã¯ã¿ãŒã®ããŸããŸãªèšå®ãªã©ã®ç¹å®ã®èšå®ïŒããµããŒããããã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ãäœæã§ããŸãã軜éãããã³ã«ã䜿çšãããããã¯ãŒã¯ã
ãªããªã Red Hat JBoss Fuseã¯ãApache ServiceMixãã¯ãããžãŒã®ãªãŒãã³ãœãŒã¹ã¹ã¿ãã¯ã«åºã¥ããŠãããApache ActiveMQïŒJMSä»æ§ã®å®è£ ïŒãApache CamelïŒãšã³ã¿ãŒãã©ã€ãºã¢ããªã±ãŒã·ã§ã³çµ±åãã¿ãŒã³ã®å®è£ ïŒãApache CXFïŒREST / Webéçºçšã©ã€ãã©ãªïŒãªã©ã®åŒ·åãªãã¯ãããžãŒãèªç±ã«äœ¿çšã§ããŸããµãŒãã¹ïŒããã«ãŒããªã³ãïŒäŸåæ§æ³šå ¥æ©èœãæäŸïŒãSpringãªã©ã ãããã®ãã¯ãããžãŒã¯Red Hat JBoss Fuseã§äºãã«ã·ãŒã ã¬ã¹ã«çµ±åããããããããã«ããå¿ èŠãªæ©èœã®éçºæéãå€§å¹ ã«ççž®ãããŸãã
ãã®è³æã¯ãJet Infosystems Software Solutions Centerã®å°é家ã«ãã£ãŠäœæãããŸããã