55import act .app .event .AppEventId ;
66import act .db .DbService ;
77import act .db .di .DaoInjectionListenerBase ;
8+ import act .event .AppEventListenerBase ;
89import org .osgl .$ ;
910import org .osgl .inject .BeanSpec ;
1011import org .osgl .util .Generics ;
11- import org .osgl .util .S ;
1212
1313import java .lang .reflect .Type ;
14+ import java .util .EventObject ;
1415import java .util .List ;
1516
1617public class EbeanDaoInjectionListener extends DaoInjectionListenerBase {
@@ -22,6 +23,10 @@ public Class[] listenTo() {
2223
2324 @ Override
2425 public void onInjection (Object injectee , BeanSpec spec ) {
26+ final EbeanDao dao = $ .cast (injectee );
27+ if (dao .ebeanServerProvided ()) {
28+ return ;
29+ }
2530 List <Type > typeParameters = spec .typeParams ();
2631 if (typeParameters .isEmpty ()) {
2732 typeParameters = Generics .typeParamImplementations (spec .rawType (), EbeanDao .class );
@@ -34,14 +39,13 @@ public void onInjection(Object injectee, BeanSpec spec) {
3439 DbService dbService = App .instance ().dbServiceManager ().dbService (resolved ._2 );
3540 if (dbService instanceof EbeanService ) {
3641 final EbeanService service = $ .cast (dbService );
37- final EbeanDao dao = $ .cast (injectee );
38- Act .jobManager ().on (AppEventId .DB_SVC_LOADED , S .concat (resolved ._2 , "-ebean-on-dao-injection" ), new Runnable () {
42+ Act .eventBus ().bind (AppEventId .DB_SVC_LOADED , new AppEventListenerBase () {
3943 @ Override
40- public void run () {
44+ public void on ( EventObject eventObject ) throws Exception {
4145 dao .ebean (service .ebean ());
4246 dao .modelType (resolved ._1 );
4347 }
44- }, true );
48+ });
4549 }
4650 }
4751}
0 commit comments