@Override
 protected void found(final Class<ActEventListener> target, final App app) {
     final EventBus bus = app.eventBus();
     ParameterizedType ptype = null;
     Type superType = target.getGenericSuperclass();
     while (ptype == null) {
         if (superType instanceof ParameterizedType) {
             ptype = (ParameterizedType) superType;
         } else {
             if (Object.class == superType) {
                 logger.warn("Event listener registration failed: cannot find generic information for %s", target.getName());
                 return;
             }
             superType = ((Class) superType).getGenericSuperclass();
         }
     }
     Type[] ca = ptype.getActualTypeArguments();
     for (Type t : ca) {
         if (t instanceof Class) {
             final Class tc = (Class) t;
             if (ActEvent.class.isAssignableFrom(tc)) {
                 app.eventBus().bind(AppEventId.DEPENDENCY_INJECTOR_LOADED, new AppEventListenerBase() {
                     @Override
                     public void on(EventObject event) throws Exception {
                         ActEventListener listener = (ActEventListener) app.newInstance(target);
                         bus.bind(tc, listener);
                     }
                 });
                 return;
             }
         }
     }
 }
예제 #2
0
 @Before
 public void prepare() {
   config = mock(AppConfig.class);
   when(config.secret()).thenReturn("secret");
   crypto = new AppCrypto(config);
   app = mock(App.class);
   when(app.config()).thenReturn(config);
   when(app.crypto()).thenReturn(crypto);
   when(app.sign(anyString())).thenCallRealMethod();
   when(app.encrypt(anyString())).thenCallRealMethod();
   when(app.decrypt(anyString())).thenCallRealMethod();
   resolver = new SessionManager.CookieResolver(app);
   session = new H.Session();
   session.put("foo", "bar");
   flash = new H.Flash();
   flash.put("foo", "bar");
 }
 public StringValueResolverManager(App app) {
   super(app);
   registerPredefinedResolvers();
   registerBuiltInResolvers(app.config());
 }