NIFI-5120 AbstractListenEventProcessor supports expression language

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #2659.
This commit is contained in:
sbouchex 2018-04-25 22:40:45 +02:00 committed by Pierre Villard
parent 23937835f3
commit 3719a6268c
1 changed files with 3 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.annotation.lifecycle.OnScheduled;
import org.apache.nifi.annotation.lifecycle.OnUnscheduled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.AbstractProcessor;
import org.apache.nifi.processor.DataUnit;
import org.apache.nifi.processor.ProcessContext;
@ -62,6 +63,7 @@ public abstract class AbstractListenEventProcessor<E extends Event> extends Abst
.Builder().name("Port")
.description("The port to listen on for communication.")
.required(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.PORT_VALIDATOR)
.build();
public static final PropertyDescriptor CHARSET = new PropertyDescriptor.Builder()
@ -175,7 +177,7 @@ public abstract class AbstractListenEventProcessor<E extends Event> extends Abst
@OnScheduled
public void onScheduled(final ProcessContext context) throws IOException {
charset = Charset.forName(context.getProperty(CHARSET).getValue());
port = context.getProperty(PORT).asInteger();
port = context.getProperty(PORT).evaluateAttributeExpressions().asInteger();
events = new LinkedBlockingQueue<>(context.getProperty(MAX_MESSAGE_QUEUE_SIZE).asInteger());
final String nicIPAddressStr = context.getProperty(NETWORK_INTF_NAME).evaluateAttributeExpressions().getValue();