mirror of
https://github.com/apache/nifi.git
synced 2025-02-17 15:36:36 +00:00
NIFI-3543 This closes #1548. Added support for using EL when defining brokerURL in jms-cf-service
Signed-off-by: joewitt <joewitt@apache.org>
This commit is contained in:
parent
8ce2a1b3a7
commit
816034bd01
@ -177,17 +177,18 @@ public class JMSConnectionFactoryProvider extends AbstractControllerService impl
|
|||||||
this.setProperty(propertyName, entry.getValue());
|
this.setProperty(propertyName, entry.getValue());
|
||||||
} else {
|
} else {
|
||||||
if (propertyName.equals(BROKER)) {
|
if (propertyName.equals(BROKER)) {
|
||||||
|
String brokerValue = context.getProperty(descriptor).evaluateAttributeExpressions().getValue();
|
||||||
if (context.getProperty(CONNECTION_FACTORY_IMPL).evaluateAttributeExpressions().getValue().startsWith("org.apache.activemq")) {
|
if (context.getProperty(CONNECTION_FACTORY_IMPL).evaluateAttributeExpressions().getValue().startsWith("org.apache.activemq")) {
|
||||||
this.setProperty("brokerURL", entry.getValue());
|
this.setProperty("brokerURL", brokerValue);
|
||||||
} else {
|
} else {
|
||||||
String[] hostPort = entry.getValue().split(":");
|
String[] hostPort = brokerValue.split(":");
|
||||||
if (hostPort.length == 2) {
|
if (hostPort.length == 2) {
|
||||||
this.setProperty("hostName", hostPort[0]);
|
this.setProperty("hostName", hostPort[0]);
|
||||||
this.setProperty("port", hostPort[1]);
|
this.setProperty("port", hostPort[1]);
|
||||||
} else if (hostPort.length != 2) {
|
} else if (hostPort.length != 2) {
|
||||||
this.setProperty("serverUrl", entry.getValue()); // for tibco
|
this.setProperty("serverUrl", brokerValue); // for tibco
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Failed to parse broker url: " + entry.getValue());
|
throw new IllegalArgumentException("Failed to parse broker url: " + brokerValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SSLContextService sc = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
|
SSLContextService sc = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
|
||||||
|
@ -63,7 +63,7 @@ public interface JMSConnectionFactoryProviderDefinition extends ControllerServic
|
|||||||
.displayName("Broker URI")
|
.displayName("Broker URI")
|
||||||
.description("URI pointing to the network location of the JMS Message broker. For example, "
|
.description("URI pointing to the network location of the JMS Message broker. For example, "
|
||||||
+ "'tcp://myhost:61616' for ActiveMQ or 'myhost:1414' for IBM MQ")
|
+ "'tcp://myhost:61616' for ActiveMQ or 'myhost:1414' for IBM MQ")
|
||||||
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
|
.addValidator(new NonEmptyBrokerURIValidator())
|
||||||
.required(true)
|
.required(true)
|
||||||
.expressionLanguageSupported(true)
|
.expressionLanguageSupported(true)
|
||||||
.build();
|
.build();
|
||||||
@ -86,13 +86,28 @@ public interface JMSConnectionFactoryProviderDefinition extends ControllerServic
|
|||||||
*/
|
*/
|
||||||
ConnectionFactory getConnectionFactory();
|
ConnectionFactory getConnectionFactory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link Validator} that ensures that brokerURI's length > 0 after EL evaluation
|
||||||
|
*/
|
||||||
|
static class NonEmptyBrokerURIValidator implements Validator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValidationResult validate(String subject, String input, ValidationContext context) {
|
||||||
|
String value = input;
|
||||||
|
if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) {
|
||||||
|
value = context.getProperty(BROKER_URI).evaluateAttributeExpressions().getValue();
|
||||||
|
}
|
||||||
|
return StandardValidators.NON_EMPTY_VALIDATOR.validate(subject, value, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static class ClientLibValidator implements Validator {
|
static class ClientLibValidator implements Validator {
|
||||||
@Override
|
@Override
|
||||||
public ValidationResult validate(String subject, String input, ValidationContext context) {
|
public ValidationResult validate(String subject, String input, ValidationContext context) {
|
||||||
String libDirPath = context.getProperty(CLIENT_LIB_DIR_PATH).getValue();
|
String libDirPath = context.getProperty(CLIENT_LIB_DIR_PATH).evaluateAttributeExpressions().getValue();
|
||||||
StringBuilder invalidationMessageBuilder = new StringBuilder();
|
StringBuilder invalidationMessageBuilder = new StringBuilder();
|
||||||
if (libDirPath != null) {
|
if (libDirPath != null) {
|
||||||
File file = new File(libDirPath);
|
File file = new File(libDirPath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user