private ConnectionFactory obtainTargetConnectionFactory(Expression expression, Object rootObject) { if (expression != null && getConnectionFactory() instanceof AbstractRoutingConnectionFactory) { AbstractRoutingConnectionFactory routingConnectionFactory = (AbstractRoutingConnectionFactory) getConnectionFactory(); Object lookupKey; if (rootObject != null) { lookupKey = this.sendConnectionFactorySelectorExpression.getValue(this.evaluationContext, rootObject); } else { lookupKey = this.sendConnectionFactorySelectorExpression.getValue(this.evaluationContext); } if (lookupKey != null) { ConnectionFactory connectionFactory = routingConnectionFactory.getTargetConnectionFactory(lookupKey); if (connectionFactory != null) { return connectionFactory; } else if (!routingConnectionFactory.isLenientFallback()) { throw new IllegalStateException("Cannot determine target ConnectionFactory for lookup key [" + lookupKey + "]"); } } } return getConnectionFactory(); }
private ConnectionFactory obtainTargetConnectionFactory(Expression expression, Object rootObject) { if (expression != null && getConnectionFactory() instanceof AbstractRoutingConnectionFactory) { AbstractRoutingConnectionFactory routingConnectionFactory = (AbstractRoutingConnectionFactory) getConnectionFactory(); Object lookupKey; if (rootObject != null) { lookupKey = this.sendConnectionFactorySelectorExpression.getValue(this.evaluationContext, rootObject); } else { lookupKey = this.sendConnectionFactorySelectorExpression.getValue(this.evaluationContext); } if (lookupKey != null) { ConnectionFactory connectionFactory = routingConnectionFactory.getTargetConnectionFactory(lookupKey); if (connectionFactory != null) { return connectionFactory; } else if (!routingConnectionFactory.isLenientFallback()) { throw new IllegalStateException("Cannot determine target ConnectionFactory for lookup key [" + lookupKey + "]"); } } } return getConnectionFactory(); }