Spring Boot + Spring Integration ã§ãããã試ãã¦ã¿ã ( ãã®ï¼ )( AcceptOnceFileListFilter ãã»ãããã¦ããªãã¯ãã® FileReadingMessageSource ã§åããã¡ã¤ã«ãï¼åº¦å¦çãããªãçç±ã¨ã¯ï¼ )
æ¦è¦
è¨äºä¸è¦§ã¯ãã¡ãã§ãã
FileReadingMessageSource ã« AcceptOnceFileListFilter ãã»ãããã¦ããªãã«ãé¢ããããin ãã£ã¬ã¯ããªã«åããã¡ã¤ã«ãã³ãã¼ãã¦ãï¼åç®ä»¥éã¯å¦çãããªãåå ã調æ»ãã¾ãã
åç §ãããµã¤ãã»æ¸ç±
ç®æ¬¡
- çæãã FileReadingMessageSource ã®ã¤ã³ã¹ã¿ã³ã¹ã®å 容ã Debugger ã§è¦ã¦ã¿ã
- ã©ã㧠AcceptOnceFileListFilter ãã»ãããã¦ããã®ãï¼
- AcceptOnceFileListFilter ãå¤ãã¦åããã¡ã¤ã«ãå¦çããããã¨ã確èªãã
æé
çæãã FileReadingMessageSource ã®ã¤ã³ã¹ã¿ã³ã¹ã®å 容ã Debugger ã§è¦ã¦ã¿ã
src/main/java/ksbysample/eipapp/dirchecker/eip/endpoint ã®ä¸ã® InDirChecker.java ã® inDirFileReadingMessageSource ã¡ã½ããã®ä»¥ä¸ã®å ´æã« Breakpoint ãè¨å®ãã¾ãã
Debug å®è¡ã㦠Breakpoint ã§å¦çãæ¢ã¾ã£ãå¾ãçæãã FileReadingMessageSource ã®ã¤ã³ã¹ã¿ã³ã¹ãè¦ã¦ã¿ã㨠fileFilters ã« IgnoreHiddenFileListFilter, AcceptOnceFileListFilter ãæ¢ã«ã»ããããã¦ãã¾ããã
ã©ã㧠AcceptOnceFileListFilter ãã»ãããã¦ããã®ãï¼
FileReadingMessageSource ã¯ã©ã¹ã®ã½ã¼ã¹ãè¦ãã¨ããã£ã¼ã«ã scanner ã«åæå¤ã¨ã㦠DefaultDirectoryScanner ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ãã»ãããã¦ããã
DefaultDirectoryScanner ã¯ã©ã¹ã®ã½ã¼ã¹ãè¦ãã¨ãã³ã³ã¹ãã©ã¯ã¿ã§ AcceptOnceFileListFilter ãã»ãããã¦ãã¾ããã
å度 FileReadingMessageSource ã¯ã©ã¹ã®ã½ã¼ã¹ãè¦ã㨠onInit ã¡ã½ããã§ãã£ã¼ã«ã filter ãã»ããããã¦ããå ´åã«ã¯ scanner.setFilter ã¡ã½ãããå¼ã³åºã㦠scanner ã® filter ã®è¨å®ãå¤æ´ããããã«ãªã£ã¦ãã¾ããã
çµè«ã¨ãã¦ã¯ã
- filter 㯠FileReadingMessageSource ã¯ã©ã¹ã®ãã£ã¼ã«ã scanner ã«ã»ããããã¦ãããã®ã使ç¨ããã¾ãã
- ããã©ã«ãã§ã¯ scanner ã«ã¯ DefaultDirectoryScanner ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ãã»ãããããDefaultDirectoryScanner ã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ã§ AcceptOnceFileListFilter ãã»ããããã¾ãã
- FileReadingMessageSource#setFilter ã¡ã½ãããå¼ã³åºãã¦ç¬èªã® filter ãã»ããããã°ãscanner ã® filter ã¯ãã®å 容ã«ä¸æ¸ãããã¾ã ( 追å ã§ã¯ããã¾ãã )ã
AcceptOnceFileListFilter ãå¤ãã¦åããã¡ã¤ã«ãå¦çããããã¨ã確èªãã
AcceptOnceFileListFilter ãå¤ãæ¹æ³ã¯ï¼ã¤ããã¾ãã
- å®å ¨ã« filter ã空ã«ããããªãã° FileReadingMessageSource#setScanner ã¡ã½ãããå¼ã³åºã㦠filter ã空㮠DirectoryScanner ã¤ã³ã¿ã¼ãã§ã¼ã¹ã®å®è£ ã¯ã©ã¹ãå®è£ ãã¦ã»ãããã¾ãã
- filter ã空ã«ããªããªãã° FileReadingMessageSource#setFilter ã¡ã½ãããå¼ã³åºãã¦ä¸æ¸ããã filter ãã»ãããã¾ãã
ä»å㯠IgnoreHiddenFileListFilter ã¯ã»ãããã¦ããããã®ã§ FileReadingMessageSource#setFilter ã¡ã½ãããå¼ã¶æ¹æ³ã§è©¦ãã¦ã¿ã¾ãã
src/main/java/ksbysample/eipapp/dirchecker/eip/endpoint ã®ä¸ã® InDirChecker.java ã® inDirFileReadingMessageSource ã¡ã½ããã§ã IgnoreHiddenFileListFilter ã ããã»ããããã filter ãã»ãããã¾ãã
@Bean public FileReadingMessageSource inDirFileReadingMessageSource() { FileReadingMessageSource source = new FileReadingMessageSource(); source.setDirectory(Paths.get(IN_DIR_PATH).toFile()); CompositeFileListFilter<File> filter = new CompositeFileListFilter<>(); filter.addFilter(new IgnoreHiddenFileListFilter()); source.setFilter(filter); return source; }
äºåæºåã¨ã㦠user_info, user_role ãã¼ãã«ã以ä¸ã®ç¶æ ã«ãã¾ãã
in ãã£ã¬ã¯ããªãerror ãã£ã¬ã¯ããªã¯ç©ºã«ãã¾ãã
bootRun ã¿ã¹ã¯ãå®è¡ã㦠Tomcat ãèµ·åãã¾ãã
in ãã£ã¬ã¯ããªã« TestData01.xlsx ãã³ãã¼ããã¨ãã¡ã¤ã«ãæ£å¸¸å¦çããã¦åé¤ããã¾ããã
âââ
user_info, user_role ãã¼ãã«ãè¦ãã¨ãã¼ã¿ãç»é²ããã¦ãããã¨ã確èªã§ãã¾ãã
åã³ in ãã£ã¬ã¯ããªã« TestData01.xlsx ãã³ãã¼ããã¨ä»åº¦ããã¡ã¤ã«ãæ£å¸¸å¦çããã¦åé¤ããã¾ããã
âââ
user_info, user_role ãã¼ãã«ãè¦ãã¨æ´ã«ãã¼ã¿ãç»é²ããã¦ãããã¨ã確èªã§ãã¾ãã
åããã¡ã¤ã«ã in ãã£ã¬ã¯ããªã«ã³ãã¼ãã¦ãå¦çããããã¨ã確èªã§ãã¾ãããCtrl+F2 ãæ¼ã㦠Tomcat ãåæ¢ãã¾ãã
user_info, user_role ãã¼ãã«ã«è¿½å ããããã¼ã¿ã¯åé¤ãã¾ããã¾ãä»åã®å¤æ´ã¯ commit ãã¾ããã
ã½ã¼ã¹ã³ã¼ã
å±¥æ´
2016/09/10
åççºè¡ã