コード例 #1
0
  @Override
  public void onApplicationEvent(ApplicationEvent event) {
    System.out.println(event.getClass().getName());

    if (event instanceof ContextRefreshedEvent) {
      subscribe();
    }
  }
コード例 #2
0
ファイル: ServiceBean.java プロジェクト: wushujing/dubbo
 public void onApplicationEvent(ApplicationEvent event) {
   if (ContextRefreshedEvent.class.getName().equals(event.getClass().getName())) {
     if (isDelay() && !isExported() && !isUnexported()) {
       if (logger.isInfoEnabled()) {
         logger.info("The service ready on spring started. service: " + getInterface());
       }
       export();
     }
   }
 }
コード例 #3
0
 private ResolvableType getResolvableType(ApplicationEvent event) {
   ResolvableType payloadType = null;
   if (event instanceof PayloadApplicationEvent) {
     PayloadApplicationEvent<?> payloadEvent = (PayloadApplicationEvent<?>) event;
     payloadType =
         payloadEvent.getResolvableType().as(PayloadApplicationEvent.class).getGeneric(0);
   }
   for (ResolvableType declaredEventType : this.declaredEventTypes) {
     if (!ApplicationEvent.class.isAssignableFrom(declaredEventType.getRawClass())
         && payloadType != null) {
       if (declaredEventType.isAssignableFrom(payloadType)) {
         return declaredEventType;
       }
     }
     if (declaredEventType.getRawClass().isAssignableFrom(event.getClass())) {
       return declaredEventType;
     }
   }
   return null;
 }