????JOOQ??????·?????о?????Spring??Java?????????и??д??????????????????????
????????????????????jooq.org???????????jOOQ?????й???Java??SQL??????????????е???????
?????????????????????????????Spring API Bingo???ζ??????????Spring????????????????????????????????????£?
????FactoryAdvisorAdapterHandlerLoader
????ContainerPreTranslatorInfoDisposable
????BeanFactoryDestinationResolver
????LocalPersistenceManagerFactoryBean
?????????????????????????????????????????????????Spring API Bingo???
???????????Spring API????ò????????????……
????????
????“???????????????????????????????Ч??????????????????”–Tim Bray quoting Phil Karlton
??????Java???????м???????????????????????????????????????????????????????????????????????????
??????y???PaymentServce??????PaymentServiceImpl?????????????????PaymentServiceImplTest??????PaymentServiceTest??
????——Tom Bujok(@tombujok)2014??10??8??
????????Impl?????????????????????????????????????????????????????????
???????vs????
????Java??????????????Java??????????????????????????????????????????Щ???????????????????????????????Ada????????????Ada??PL/SQL????Ada????PL/SQL?????????????????Щ????????????????????????????????specification???????壨body????????????????????
????--Specification
????package Example is
????procedure Print_and_Increment(j:in out Number);
????end Example;
????--Body
????package body Example is
????procedure Print_and_Increment(j:in out Number)is
????begin
????--[...]
????end Print_and_Increment;
????begin
????--[...]
????end Example;
???????????????????????????????????Example????????????浽?????????????У????????Example.ads??ad??????Ada??s??????specification?????????????Example.adb??b????body????PL/SQL???????淶????package????????Example.pks??Example.pkb??pk???Package??Java????????????·?????????????????????з????
??????????????????壬????????????????????????????????????ж?????????
????????????????????????в????????????????????????????????????嶼?е????????????
??????ν???Щ????Java?е?????
?????????????????????????????????????????????????????????????????Ada??????У?????????????????????????????????????API?????????????á???????JOOQ??????????????JOOQ??????????????2???????????
????*Impl
???????е?????interface?????????????????????壩????Impl???????????????????????????Щ??????????????????????org.jooq.impl????????磺
????Cursor??????????????CursorImpl??
????DAO??????????????DAOImpl??
????Record???????????RecordImpl??
?????????????????????????????????????????????????????????Java????????????Ada???????????и???????????……
????Abstract*
????……?????????ж??????????á??????????????????????????????????????????????????????????????????????????????????????????????к????????????????????????Щ??????????????Abastract??????????£???Щ??????????????????????????org.jooq.impl????
???????磺
????Field???????????????AbstractField??
????Query???????????????AbstractQuery??
????ResultQuery???????????????AbstractResultQuery??
?????????ResultQuery????????Query?????thusAbstractResultQuery??????????theAbstractQuery??????????????????????theAbstractQuery??????????????????????????в?????????????API????????????????API??????????DSL??Domain-Specific Language??????????????????????Fieldreally??????????????г????????????????????Substring??
????Default*
??????????y???????κ???API???????顣????Java SE API???????????????Ч??????磺
????Collections
????Streams
????JDBC
????DOM
???????????y???????κ???SPI???????????????????顣API??SPI???????????????????????API???????API?????????????????SPI?????????????á??????????JDK?????????????Щ????????????????????????????????????API?????????·?????
??????????????????С??汾??????????????????????????????κ????????????DSL???????????Field??286????????????DSL??677???????????????????????SPI????????????????????????????SPI??????????????·???——??????Java8????????????????????????????????????????????к??
??????????????????????????????????JDK??????????????????????????????ɡ??????????????????????????????????????????????Defaultimplementation??????ExecuteListener??????????????DefaultExecuteListener??
????public interface ExecuteListener{
????void start(ExecuteContext ctx);
????void renderStart(ExecuteContext ctx);
????//[...]
????}
????public class DefaultExecuteListener
????implements ExecuteListener{
????@Override
????public void start(ExecuteContext ctx){}
????@Override
????public void renderStart(ExecuteContext ctx){}
????//[...]
????}
????????????Default*??????????API??????????????ò???????????????????????????????SPI???????е?????????e??????????????????????Java 6??Java 7′?????????????????????????????????????????????????
?????????????Java 8??汾
???????????????????????Java 8????SPI???????????????y?????????з???????????????????塣???JOOQ?????Java 6????????????????????????????ExecuteListener??
????public interface ExecuteListener{
????default void start(ExecuteContext ctx){}
????default void renderStart(ExecuteContext ctx){}
????//[...]
????}
????*Utils????*Helper
??????????????mock??testing??coverage???????????????????и?“?????”???????????????????????????????????????????????????????????“????”?е?????????
??????????????????
??????????и?????????????????????????????£??????????????????????????????????*Utils???????????????????????????????????е???к?????????????????????????????????檔??????????β??ò???????????????????????????????????????????????org.jooq.impl.Utils?????????????????????????
????import static org.jooq.impl.Utils.*;
??????????й??????????“??????”?????????????????“???”??????????????????????????“???????mock”?????????????????????????????
????????
?????????????????????????????????????????????????????????Tom BujokTweet????????????????????????
????@tombujok????PaymentServiceImplTestImpl!—Konrad Malawski(@ktosopl)October 8??2014
????@tombujok??????y??
????—Simon Martinelli(@simas_ch)October 8??2014
????@tombujok?????е????????Impl?????
????—Bartosz Majsak(@majson)October 8??2014
????@tombujok@lukaseder@ktosopl?????????????????*Impl???????????????????????????????????—Peter Kofler(@codecopkofler)October 9??2014