Search in sources :

Example 1 with PayaraClusteredCDIEventImpl

use of fish.payara.appserver.micro.services.PayaraClusteredCDIEventImpl in project Payara by payara.

the class ClusteredCDIEventBusImpl method onOutboundEvent.

void onOutboundEvent(@Observes @Outbound Serializable event, EventMetadata meta) throws IOException {
    PayaraClusteredCDIEvent clusteredEvent;
    // read the metadata on the Outbound Annotation to set data into the event
    boolean loopBack = false;
    String eventName = "";
    String[] instanceName = new String[0];
    for (Annotation annotation : meta.getQualifiers()) {
        if (annotation instanceof Outbound) {
            Outbound outboundattn = (Outbound) annotation;
            eventName = outboundattn.eventName();
            loopBack = outboundattn.loopBack();
            instanceName = outboundattn.instanceName();
        }
    }
    clusteredEvent = new PayaraClusteredCDIEventImpl(runtime.getLocalDescriptor(), event);
    clusteredEvent.setLoopBack(loopBack);
    clusteredEvent.setProperty(EVENT_PROPERTY, eventName);
    clusteredEvent.setProperty(INSTANCE_PROPERTY, serializeArray(instanceName));
    Set<Annotation> qualifiers = meta.getQualifiers();
    if (qualifiers != null && !qualifiers.isEmpty()) {
        clusteredEvent.addQualifiers(qualifiers);
    }
    runtime.publishCDIEvent(clusteredEvent);
}
Also used : Outbound(fish.payara.micro.cdi.Outbound) PayaraClusteredCDIEventImpl(fish.payara.appserver.micro.services.PayaraClusteredCDIEventImpl) PayaraClusteredCDIEvent(fish.payara.micro.event.PayaraClusteredCDIEvent) Annotation(java.lang.annotation.Annotation)

Aggregations

PayaraClusteredCDIEventImpl (fish.payara.appserver.micro.services.PayaraClusteredCDIEventImpl)1 Outbound (fish.payara.micro.cdi.Outbound)1 PayaraClusteredCDIEvent (fish.payara.micro.event.PayaraClusteredCDIEvent)1 Annotation (java.lang.annotation.Annotation)1