synchronized (STRATAGY_FINDER) {
if (subsciptionStrategy != null) {
return subsciptionStrategy;
}
MQTTSubscriptionStrategy strategy = null;
if (subscriptionStrategyName != null && !subscriptionStrategyName.isEmpty()) {
try {
strategy = (MQTTSubscriptionStrategy) STRATAGY_FINDER.newInstance(subscriptionStrategyName);
LOG.debug("MQTT Using subscription strategy: {}", subscriptionStrategyName);
if (strategy instanceof BrokerServiceAware) {
((BrokerServiceAware)strategy).setBrokerService(brokerService);
}
strategy.initialize(this);
} catch (Exception e) {
throw IOExceptionSupport.create(e);
}
} else {
throw new IOException("Invalid subscription strategy name given: " + subscriptionStrategyName);