ãã®è£œåã®éçºãžã®çŽæ¥ã®åå è ãšããŠãJRebelãååšããçç±ãšããããJavaéçºè ã«ã©ã®ããã«åœ¹ç«ã€ããæ確ã«ããããšæããŸãã
足ã¯ã©ãããæé·ããŸããïŒ
æåã®åé¡ã¯ãJavaã䜿çšããã»ãšãã©ãã¹ãŠã®éçºè ã«ç¥ãããŠããŸãããããžã§ã¯ããå€æŽããåŸãçµæã確èªããã«ã¯ãã³ã³ããã§ãã«ãããã³ãããã€ããã®ã«å€ãã®æéãããããŸãã éçºããã»ã¹ãå éãŸãã¯èªååããæ¹æ³ã«é¢ããHabréã®åªããèšäºããã§ã«å ¬éãããŠããã®ã§ãããã§ã¯ç¹°ãè¿ããŸããã ããããå®éã«ã¯ãåè¿°ã®ã¡ãœããã«ã¯ç¬èªã®æ¬ ç¹ããããŸãããã¹ãŠã®å€æŽããããã€ãããã¢ããªã±ãŒã·ã§ã³ã«éåžžã®æ¹æ³ã§ãªãŒããŒããŒããããããšã¯ãããŸããã ã³ã³ãããåèµ·åããå¿ èŠãããã¡ã¢ãªãªãŒã¯ãååŸããã®ã¯éåžžã«ç°¡åã§ãã æè¡çãªè©³çŽ°ã¯ãåœç€Ÿã®ãŠã§ããµã€ãã®äžé£ã®èšäºã«ããæãããŠããŸã-奜å¥å¿theçãªèªè ã«ãã²ãèªã¿ãã ããã
æéã¯ã©ãã«è¡ããŸããïŒ
Webã¢ããªã±ãŒã·ã§ã³éçºãµã€ã¯ã«ã¯ãå€å žçãªåœ¢åŒã§ã¯ã©ã®ããã«èŠããŸããïŒ
1.ã³ãŒãïŒãŸãã¯ãªãœãŒã¹ïŒãå€æŽããŸãã
2.çµã¿ç«ãŠãããJAR / WAR / EAR
3.åä¿¡ããã¢ãŒã«ã€ããã³ã³ããã«å±éããŸãã
4.ãããã€ãããã¢ããªã±ãŒã·ã§ã³ãéããããã€ãã®æäœã®åŸããããã®äœæ¥ã®çµæã確èªããŸããã
ã¢ããªã±ãŒã·ã§ã³ã®ãµã€ãºã䜿çšãããã³ã³ãããããã³ãã®ä»ã®ããã€ãã®èŠå ã«å¿ããŠãæé 2ã3ãããã³4ãæ°ç§ããå®å šã«çã£ãæ°ã«ãªãããšããããŸãã åœç€Ÿã¯ã䜿çšãããŠããæè¡ãšã¢ããªã±ãŒã·ã§ã³ã®å±éã«èŠããæéã«é¢ããéçºè ãžã®èª¿æ»ãå®æœããŸããã çµå±ã®ãšãããå¹³åçãªå±éã«ã¯äžåºŠã«çŽ3åã1æéã«çŽ10åããããŸãã å±éã«30å以äžãããåããããã±ãŒã¹ã§ã¯ããã®ããã»ã¹ã1æéã«äœåç¹°ãè¿ãããšãã§ããããå°ããã®ãæå³ããããŸããã çãã¯æããã§ãã
ã³ã³ãã/ã¢ããªã±ãŒã·ã§ã³ã®åèµ·åã«æ°ç§ãããå Žåãäžèšã®åé¡ã¯ããã»ã©æããããŸããã ãã ãããããžã§ã¯ããæé·ããããè€éã«ãªããšãäžäŸ¿ãæããããŸãã ããã¯ããªããèããããšãã§ããå Žæã§ãïŒå€åJRebelã¯ããªããå¿ èŠãªãã®ã§ããïŒ
JRebelãå©ãã«ïŒ
ãããã£ãŠãJRebelã¯ãéçºäžã«ã¢ããªã±ãŒã·ã§ã³ãåãããã€ããåé¡ãæé€ããããã«èšèšãããããŒã«ã§ãã å€ãã®æéãç¯çŽã§ããŸãã
JRebelã䜿çšããå Žåã®å©ç¹ã¯æ¬¡ã®ãšããã§ãã
1. JRebelã¯ã¯ãŒã¯ã¹ããŒã¹ãããªãœãŒã¹ãçŽæ¥ããŒãã§ãããããå®å šãªã¢ããªã±ãŒã·ã§ã³ã¢ãŒã«ã€ãïŒJAR / WAR / EARïŒãã³ã³ãã€ã«ããå¿ èŠã¯ãããŸããã å€æŽãããã³ãŒããã³ã³ãã€ã«ããã ãã§ãã¢ãŒã«ã€ãã®å®å šãªã¢ã»ã³ããªãããã¯ããã«çãæéã§æžã¿ãŸãã
2.ã¢ããªã±ãŒã·ã§ã³ã®åãããã€ã¯ãããŸãã-ããã§ãæéãç¯çŽã§ããŸãã
3.æ°ããã¯ã©ã¹ããŒããŒã¯äœæãããªããããæŽæ°äžã«ã¡ã¢ãªãªãŒã¯ã®ãªã¹ã¯ãå°ãªããªããŸãã ãããã£ãŠãã³ã³ããèªäœã匷å¶çã«åèµ·åããæéãç¯çŽã§ããŸãã
4.ãªããžã§ã¯ãããã³ãŠãŒã¶ãŒã»ãã·ã§ã³ã®ç¶æ ãä¿åãããŸãã ãããã£ãŠãçæ³çã«ã¯ãåãããŒãžã«ãšã©ãŸããå€æŽã®çµæã確èªã§ããŸã-F5ããŒãæŒãã ãã§ãã
ã€ã³ã¹ããŒã«ãšã»ããã¢ãã
ããã€ãã®ã€ã³ã¹ããŒã«ãªãã·ã§ã³ããããŸãã ãªããªã ã»ãšãã©ã®éçºè ã¯ãŸã EclipseãNetBeansãIntelliJãªã©ã®IDEã䜿çšããŠäœæ¥ããŠãããããã€ã³ã¹ããŒã«ããèªç¶ãªæ¹æ³ã¯ãåäžã®IDEã«ãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ããããšã§ãã
EclipseãŠãŒã¶ãŒã¯ãã€ã³ã¹ããŒã«ã®ããã«ãEclipse MarketplaceãµãŒãã¹ã䜿çšã§ããŸãã NetBeansããã³IntelliJIDEAãŠãŒã¶ãŒã¯ããã©ã°ã€ã³ã®ãªã¹ãã§JRebelãèŠã€ããããšãã§ããŸãã 詳现ãªæé ã«ã€ããŠã¯ã ãã¡ããã芧ãã ãã ã ãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ããåŸã圌ãã¯ç»é²ããŠã©ã€ã»ã³ã¹ãååŸããã®ããããšããªãã«ç¥ãããŸã
ç»é²åŸã JRebelãé£ã¹ãæºåãã§ããŸããã
å®éãJRebelã¯ç¹å®ã®éçºç°å¢ã«é¢é£ä»ããããŠããŸããã IDEã§ã¯ãªããã¢ããªã±ãŒã·ã§ã³ãå®è¡ãããŠããå Žæã§åäœããŸã-ã€ãŸã 次ã®ãããª-javaagentåŒæ°ã䜿çšããŠJVMããã»ã¹ã«é¢é£ä»ããããŸãã
java -javaagentïŒ/opt/jrebel/jrebel.jar -cp my.awesome.Application
æ§æ
ã»ãšãã©ã®å ŽåãJRebelã¯è¿œå ã®æ§æãå¿ èŠãšãããIDEãã©ã°ã€ã³ã䜿çšããŠèªåçã«çæã§ããæ§æãã¡ã€ã«-rebel.xmlã®ã¿ãå¿ èŠãšããŸãã
äžçªäžã®è¡ã¯ãJRebelã§ãããšãŒãžã§ã³ãïŒjavaagentïŒããã³ã³ãã€ã«ãããã¯ã©ã¹ã®å Žæãšéçãã¡ã€ã«ïŒhtmlãcssãªã©ïŒãç¥ã£ãŠããå¿ èŠããããšããããšã§ãã ããã«ãããå¿ èŠãªãã¹ãŠã®ãªãœãŒã¹ãããããã€ãããã¢ãŒã«ã€ãããã§ã¯ãªããããã°ã©ããŒãå€æŽãå ãããããžã§ã¯ãããçŽæ¥ããŠã³ããŒãã§ããŸãã
ãã¹ãŠã®ãããžã§ã¯ãããæšæºããã£ã¬ã¯ããªæ§é ã«åŸããéåžžã®IDEããŒã«ã®ã¿ã䜿çšããŠã³ã³ãã€ã«ãããå Žåãããããæ§æãã¡ã€ã«ã¯å¿ èŠãªãã§ããããIDEãããã¹ãŠã®ãããžã§ã¯ãæ å ±ãååŸããããæ £äŸã«åŸã£ãŠåäœããã ãã§ãã ãããããã¹ãŠã®éçºè ãæšæºã«ã€ããŠç¬èªã®ã¢ã€ãã¢ãæã£ãŠãããããJRebelã«ã¯ããã€ãã®ãã³ããå¿ èŠã§ãã
æ§æãã¡ã€ã«èªäœã®æ§é ã¯ããªãåçŽã§ããã¯ã©ã¹ãã¹ãšéçãªãœãŒã¹ã®å Žæãèšå®ããã ãã§ãã
<?xml version="1.0" encoding="UTF-8"?> <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd"> <classpath> <dir name="c:\myWorkspace\myWar\target\classes"/> <dir name="c:\myWorkspace\myWar\src\main\resources"/> </classpath> <web> <link target="/"> <dir name="c:\myWorkspace\myWar\src\main\webapp"/> </link> <link target="/jsps/"> <dir name="c:\myWorkspace\myWar\src\main\jsps"/> </link> </web> </application>
<?xml version="1.0" encoding="UTF-8"?> <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd"> <classpath> <dir name="c:\myWorkspace\myWar\target\classes"/> <dir name="c:\myWorkspace\myWar\src\main\resources"/> </classpath> <web> <link target="/"> <dir name="c:\myWorkspace\myWar\src\main\webapp"/> </link> <link target="/jsps/"> <dir name="c:\myWorkspace\myWar\src\main\jsps"/> </link> </web> </application>
ã芧ã®ãšããããã®ãããªãã¡ã€ã«ã䜿çšãããšãæãéæšæºçãªãããžã§ã¯ãæ§é ã衚瀺ã§ããŸããç§ã®çµéšã§ã¯ããã®ãããªèŠä»¶ã¯é »ç¹ã«çºçããŸãã rebel.xmlã®ãªãã·ã§ã³ã®è©³çŽ°ãªèª¬æã¯ã ããã¥ã¡ã³ãã«èšèŒãããŠããŸã ã
éèŠïŒ JRebelãæ§æãæ£ããèªã¿åãããã«ã¯ãrebel.xmlããããã€æžã¿ã¢ããªã±ãŒã·ã§ã³ã«é©çšããå¿ èŠããããŸããWebã¢ããªã±ãŒã·ã§ã³ã®å Žåãrebel.xmlã¯WEB-INF / classesã«ããå¿ èŠããããŸãã JARãã¡ã€ã«ã®å Žåãrebel.xmlã¯ã¢ãŒã«ã€ãã®ã«ãŒãã«ããå¿ èŠããããŸãã
çæ³çãªã±ãŒã¹ã§ã¯ãweb.xmlãšrebel.xmlã®ã¿ãã¢ãŒã«ã€ãã«å«ãŸããä»ã®ãªãœãŒã¹ã¯rebel.xmlã®ãã¹ãä»ããŠè¡šç€ºã§ããŸãã
Mavenãããžã§ã¯ãã®å Žåãæ§æãã¡ã€ã«ãçæããŠé©åãªå Žæã«ä¿åã§ãããã©ã°ã€ã³ã䜿çšããããšãã§ããŸãã
æã¡äžã
IDEããã®èµ·åã¯éåžžã«ç°¡åã§ãã IntelliJIDEAã®å Žåããã©ã°ã€ã³ã®ã€ã³ã¹ããŒã«åŸã«è¡šç€ºãããæ°ããã¹ã¿ãŒããã¿ã³ã䜿çšããã ãã§ãã
Eclipseã§ã¯ãæ°ããããã¯ããŒã¯ãèµ·åæ§æã«è¿œå ãããJRebelããã®èµ·åãšä»ã®ããã€ãã®ãªãã·ã§ã³ã§æå¹ã«ãªããã©ããã確èªã§ããŸãã
éçºç°å¢å€ã§ã³ã³ãããå®è¡ããå Žåã¯ãéžæããã³ã³ããã®ã¹ã¯ãªããã®-javaagentãã©ã¡ãŒã¿ã§jrebel.jarãžã®æ£ãããã¹ãè¿œå ããã ãã§ãã æ§æã¬ã€ãã«ã¯ãããŸããŸãªJVMããã³OSã§å®è¡ãããµã³ãã«ã¹ã¯ãªãããå«ãã³ã³ããã®ãªã¹ããå«ãŸããŠããŸãã
ç¹åŸŽ
JRebelã¯ã䟿å©ãªèªååããŒã«ã§ãããããã€æžã¿ã¢ããªã±ãŒã·ã§ã³ã§ãããžã§ã¯ãã衚瀺ããããšã«å ããŠãããã«å€ãã®æ©èœãæäŸããŸãã ãŸã第äžã«ãããã¯äž»ãªæ©èœã§ã-ã³ãŒãã®å€æŽããªãŒããŒããŒãããŸãã äœæ¥ã®éçšã§ãããã¿ããªãã¡ã¯ã¿ãªã³ã°ãããããªæ¹æ³ã«ã€ãŸããããšããŸãããã èšããããšããã«ãextractã¡ãœãããåŒã³åºããŸããããã«ãããã¯ã©ã¹ã«æ°ããã¡ãœãããè¿œå ãããŸãã ã³ãŒãããªãŒããŒããŒãããããã®æšæºããŒã«HotSwapã¯ããã®ãããªå€æŽãåŠçã§ããŸããã 次ã«ãJRebelã¯ã¯ã©ã¹ããªãŒããŒããŒãããããã«ã€ããŠã³ã³ãœãŒã«ã«æžã蟌ã¿ãŸãã ãªãŒããŒããŒãã¯ãå€æŽãããã¯ã©ã¹ã䜿çšãããç¬éã«è¡ãããããã«ãããJavaã«åºæã®é 延åäœãã·ãã¥ã¬ãŒãããŸãã
ããã«ããã¬ãŒã ã¯ãŒã¯å ã®èšå®ã«æ³šéã䜿çšãããšããŸãã ããšãã°ã
@RequestMapping
ã®å€
@RequestMapping
ãã³ã³ãããŒã©ãŒã䜿çšã§ãããã¹ã決å®ããããã«äœ¿çšãããŸãã ã¢ãããŒã·ã§ã³ã®å€ãå€æŽããããšã«ãããã¢ããªã±ãŒã·ã§ã³ã§æ°ããæ¹æ³ã§ãªãœãŒã¹ãèŠã€ããããšãæåŸ ãããŸãã
次ã®ããã«æ©èœããŸããã³ã³ãã€ã«åŸãã¢ãããŒã·ã§ã³å€ã¯ã¯ã©ã¹ã®æ°ããããŒãžã§ã³ã§äœ¿çšå¯èœã«ãªããŸãã 泚éã¯å®è¡å¯èœã³ãŒãã§ã¯ãªãããã¬ãŒã ã¯ãŒã¯èªäœããã®åäœãå€æŽããã¡ã¿ããŒã¿ã«å¿ããã¡ã¿ããŒã¿ã§ãã ã¯ã©ã¹ã®æ°ããããŒãžã§ã³ãããŒããããããã«ãªã£ãã®ã§ãã¡ã¿ããŒã¿ãå€æŽãããåäœãæŽæ°ãã䟡å€ãããããšããã¬ãŒã ã¯ãŒã¯ã«ç¥ãããå¿ èŠããããŸãã ãã®ãããªå ŽåãJRebelã«ã¯åãã¬ãŒã ã¯ãŒã¯ãŸãã¯ã³ã³ãããŒã®ç¹å¥ãªçµ±åãå¿ èŠã§ãã
泚éãšåæ§ã«ããã¬ãŒã ã¯ãŒã¯ãå€éšæ§æã«äŸåããŠããå Žåãç¹å¥ãªçµ±åãå¿ èŠã§ãã ããšãã°ãSpring Frameworkã®å Žåãæ§æã¯æ³šéãšXMLãã¡ã€ã«ã®äž¡æ¹ã§æå®ã§ããŸãã
ããšãã°ãXMLæ§æã«æ°ããã³ã³ããŒãã³ãïŒ bean ïŒãè¿œå ãã
@Autowired
ã¢ãããŒã·ã§ã³ã䜿çšããŠãæ°ããäœæããã³ã³ããŒãã³ããã³ã³ãããŒã©ãŒã«è»¢éããŸãã
å¶éäºé
Habréããã³JRebelã§èª¬æãããŠãããã¹ãŠã®ã¢ãããŒããšåæ§ã«ãããã€ãã®æè¡çãªå¶éããããŸãã
ãã®èšäºã®å·çæç¹ã§ã¯ãã¯ã©ã¹éå±€ã®å€æŽã¯ãµããŒããããŠããŸããã ããã°ã©ã ã§1ã€ã®ã¯ã©ã¹ããã§ã«ãA extends BããšããŠèšè¿°ãããŠããå ŽåããA extends Cãã«å€æŽããããšã¯ã§ããŸããã ã€ã³ã¿ãŒãã§ã€ã¹ã®ãªã¹ãã®å€æŽã«ãåãããšãåœãŠã¯ãŸããŸããã¯ã©ã¹å®£èšããã€ã³ã¿ãŒãã§ã€ã¹ãè¿œå ãŸãã¯åé€ããããšã¯ã§ããŸããã
èæ ®ãã¹ãç¹ãããã€ããããŸãã
éçåæåã JRebelã¯ããã§ã«ã¡ã¢ãªã«äœæãããŠãããªããžã§ã¯ãã®ç¶æ ãä¿æããããšããŸãã ãããã£ãŠãã³ã³ã¹ãã©ã¯ã¿ãŒãŸãã¯éçåæåãããã¯ã®åèµ·åã¯ãããŸããã ããããããã€ãã®çµæãçããŸãã
éçãã£ãŒã«ãã®å€ãå€æŽããããšã«ãããã¯ã©ã¹ã®æ°ããããŒãžã§ã³ã§ãã®æ°ããå€ã衚瀺ãããããšãæåŸ ãããŸãã å®éããã®å€ã¯ãJRebelãåèµ·åããªãã£ãéçãããã¯ã§å²ãåœãŠãããŸãã ãããã£ãŠãæ°ããæå³ã¯è¡šç€ºãããŸããã çŸåšãJRebelã¯ãæ°ããéçãã£ãŒã«ããè¿œå ãããå Žåã«ã®ã¿éçãããã¯ãåèµ·åããŸãã
ãã®åäœã®çç±ã¯ãéçãããã¯ã§çºçããããšããªããžã§ã¯ãã®ç¶æ ã«ç¡æéã«åœ±é¿ãäžããå¯èœæ§ããããããJRebelã¯æã極端ãªå Žåã«ã®ã¿ãªããžã§ã¯ããåèµ·åããããšããããã§ãã
JRebelãã³ã³ã¹ãã©ã¯ã¿ãŒãåèµ·åããªããšããäºå®ããçãã2çªç®ã®çµæã¯ãæ°ãããã£ãŒã«ããã¯ã©ã¹ã«è¿œå ããããšããã®ã¿ã€ãã®ããã©ã«ãå€ãå²ãåœãŠãããããšã§ãã ã€ãŸã ã¿ã€ããããªããã£ãã§ã¯ãªããã£ãŒã«ããè¿œå ãããšãå²ãåœãŠãããå€ã¯nullã«ãªããŸãããã®ãã£ãŒã«ããæ¢åã®ãªããžã§ã¯ãã«å¯ŸããŠéåç §ããããšãäžè¬ã«NullPointerExceptionãçºçããå¯èœæ§ããããŸãã
JRebel SDK
åè¿°ã®ããã«ãJRebelã®ãã¬ãŒã ã¯ãŒã¯æ§æããµããŒãããã«ã¯ç¹å¥ãªçµ±åãå¿ èŠã§ãã ãã§ã«ããããçš®é¡ã®çµ±åãå®è£ ããããã«ããªãã®åŽåãšæéãè²»ãããŠããããµããŒããããŠãããã¬ãŒã ã¯ãŒã¯ã®ãªã¹ãã¯éåžžã«å°è±¡çã§ãã äžéšã®ãã¬ãŒã ã¯ãŒã¯ã䜿çšããå Žåãçµ±åã¯äžèŠã§ãããJRebelã¯ããã«äœ¿çšã§ããŸãã äŸã«è¡ãå¿ èŠã¯ãããŸãããVaadinã®ç¹å¥ãªçµ±åããªããã° ãJRebelã¯éåžžã«ããŸãæ©èœããŸãããã£ã³ã©ã³ãã®ååã¯ãJRebelãç¬èªã®ãã¬ãŒã ã¯ãŒã¯ã§äœ¿çšã§ããããšãéåžžã«åãã§ããŸãã
æ®å¿µãªããããã®ãããªäŸã¯å€ããããŸããã ã»ãšãã©ã®ãã¬ãŒã ã¯ãŒã¯ã¯å€éšæ§æã«äŸåããŠãããããè¿œå ã®çµ±åãå¿ èŠã§ãã ç§ãã¡ã¯ãã¹ãŠã®äººãšãã¹ãŠã®ãµããŒããåãã§å®çŸããŸããããã¹ãŠã®æªç¥ã®ãã¬ãŒã ã¯ãŒã¯ã«è¿œãã€ãããšã¯ã§ãããå€ãã®äŒæ¥ãç¬èªã®ããã€ã¯ããäœæããŸãã ãã®ãããªå ŽåãJRebelã«ã¯ç¬èªã®çµ±åãäœæããæ©èœããããŸãã åŒç€Ÿã®ãµã€ãã«ã¯ãããŒãºã«åãããŠJRebelãµããŒããå®è£ ããæ¹æ³ã«é¢ããå°ããªã¬ã€ãããããŸãã
è³æº
補åã«èå³ãããã補åãšãã®äœ¿çšæ¹æ³ã®è©³çŽ°ãç¥ãããå Žåã¯ãããã€ãã®ãªãœãŒã¹ãžã®ãªã³ã¯ãæäŸã§ããŸãã
JavaPassionã®äœæè ã¯ãããŸããŸãªã³ã³ããããã¬ãŒã ã¯ãŒã¯ãIDEã§ã®JRebelã®äœ¿çšã«é¢ããè³æãåéããã³æŽæ°ããããŒãžããªãŒãããŠããŸã ã
ããªãé »ç¹ã«ãç¡æã§ç»é²ããŠåå ã§ããããŒãå¥ãŠã§ãããŒãéå¬ããŠããŸã-ã©ã€ããããã¯ã«ã€ããŠè³ªåããŠãã ããã
Vimeoã«ã¯JRebelãã£ã³ãã«ãããããŠã§ãããŒã®é²ç»ãããããçš®é¡ã®ãã¢é²ç»ãèŠã€ããããšãã§ããŸãã
åèš
ãã®èšäºã®åŸãåå¿è ã®èªè ãJRebelãäœã§ãããã©ã®ããã«äœ¿çšã§ããããç解ããããšãé¡ã£ãŠããŸãã 質åãããå Žåã¯ãã³ã¡ã³ãã§ãçãããŸãã
ãã§ã«ããã䜿çšããŠããããã®ãœãããŠã§ã¢ã®åäœã«æ¬ é¥ãããå Žåã¯ã ãã©ãŒã©ã ã§ç§ãã¡ã«é£çµ¡ãããããã¯ãã«ã«ãµããŒããµãŒãã¹ã«é£çµ¡ããããšãnotããªãã§ãã ããã
ãæž èŽããããšãããããŸããïŒ