All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fluxtion.api.event.Signal Maven / Gradle / Ivy

/*
 * Copyright (c) 2020, V12 Technology Ltd.
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the Server Side Public License, version 1,
 * as published by MongoDB, Inc.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Server Side Public License for more details.
 *
 * You should have received a copy of the Server Side Public License
 * along with this program.  If not, see 
 * .
 */
package com.fluxtion.api.event;

/**
 * A notification signal is an event that facilitates publishing control signals to event
 * handlers. Signal remove the need to define bespoke control events by
 * using a named signal and filtering .
 * 
* * The {@link Signal#filterString} filters events a receiver will * process. The generated SEP provide all filtering logic within the generated * dispatch code. A node marks a method with a filtered EventHandler annotation * as shown: * *
 * 

Sending

* StaticEventProcessor processor;
* processor.onEvent(new Signall{@literal >}("someKey", new ConcurrentLinkedQueue<>(List.of("1","2","3","4", "5", "6")))); * *

Receiving

* {@literal @}EventHandler(filterString = "filterString")
* public void controlMethod(Signal publishSignal){
* //signal processing logic
* }
*
* * Using the propagate=false will ensure the event is consumed by the signal * handler. Swallowing an event prevents a control signal from executing an * event chain for any dependent nodes of the event processor: *
* *
 *{@literal @}EventHandler(filterString = "filterString", propagate = false)
 * 
* * The Signal also provides an optional value the receiver can * accessed via {@link #getValue() }. * * @author Greg Higgins ([email protected]) */ public class Signal implements Event{ private String filterString; private T value; public Signal() { } public Signal(String filterString) { this(filterString, null); } public Signal(Enum enumFilter){ this(enumFilter.name()); } public Signal(String filterString, T value) { this.filterString = filterString; this.value = value; } public T getValue() { return value; } public void setValue(T value) { this.value = value; } public String getFilterString() { return filterString; } public void setFilterString(String filterString) { this.filterString = filterString; } @Override public String filterString() { return filterString; } @Override public String toString() { return "Signal: {" + "filterString: " + filterString + ", value: " + value + '}'; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy