protected void publishEvent(Object event, ResolvableType eventType) {
    Assert.notNull(event, "Event must not be null");
    if (logger.isTraceEnabled()) {
      logger.trace("Publishing event in " + getDisplayName() + ": " + event);
    }

    // Decorate event as an ApplicationEvent if necessary
    ApplicationEvent applicationEvent;
    if (event instanceof ApplicationEvent) {
      applicationEvent = (ApplicationEvent) event;
    } else {
      applicationEvent = new PayloadApplicationEvent<Object>(this, event);
      if (eventType == null) {
        eventType =
            ResolvableType.forClassWithGenerics(PayloadApplicationEvent.class, event.getClass());
      }
    }

    // Multicast right now if possible - or lazily once the multicaster is initialized
    if (this.earlyApplicationEvents != null) {
      this.earlyApplicationEvents.add(applicationEvent);
    } else {
      getApplicationEventMulticaster().multicastEvent(applicationEvent, eventType);
    }

    // Publish event via parent context as well...
    if (this.parent != null) {
      if (this.parent instanceof AbstractApplicationContext) {
        ((AbstractApplicationContext) this.parent).publishEvent(event, eventType);
      } else {
        this.parent.publishEvent(event);
      }
    }
  }
  @Test
  public void decode() {
    DataBuffer fooBuffer = stringBuffer("foo");
    DataBuffer barBuffer = stringBuffer("bar");
    Flux<DataBuffer> source = Flux.just(fooBuffer, barBuffer);
    Flux<ByteBuffer> output =
        this.decoder.decode(
            source,
            ResolvableType.forClassWithGenerics(Publisher.class, ByteBuffer.class),
            null,
            Collections.emptyMap());

    StepVerifier.create(output)
        .expectNext(ByteBuffer.wrap("foo".getBytes()), ByteBuffer.wrap("bar".getBytes()))
        .expectComplete()
        .verify();
  }
 @Override
 public ResolvableType getResolvableType() {
   return ResolvableType.forClassWithGenerics(getClass(), this.entity.getClass());
 }
 public SmartGenericTestEvent(Object source, T payload) {
   super(source, payload);
   this.resolvableType = ResolvableType.forClassWithGenerics(getClass(), payload.getClass());
 }
 private ResolvableType createGenericEventType(Class<?> payloadType) {
   return ResolvableType.forClassWithGenerics(PayloadApplicationEvent.class, payloadType);
 }