@Override public void onApplicationEvent(ApplicationEvent event) { System.out.println(event.getClass().getName()); if (event instanceof ContextRefreshedEvent) { subscribe(); } }
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(); } } }
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; }