private int invokePartitionSelector(String partitionSelectorClassName, Object key, int partitionCount) {
		if (this.applicationContext.containsBean(partitionSelectorClassName)) {
			return this.applicationContext.getBean(partitionSelectorClassName, PartitionSelectorStrategy.class)
					.selectPartition(key, partitionCount);
		}
		Class<?> clazz;
		try {
			clazz = ClassUtils.forName(partitionSelectorClassName, this.applicationContext.getClassLoader());
		}
		catch (Exception e) {
			logger.error("Failed to load partition selector", e);
			throw new MessageBusException("Failed to load partition selector: " + partitionSelectorClassName, e);
		}
		try {
			Object extractor = clazz.newInstance();
			Assert.isInstanceOf(PartitionKeyExtractorStrategy.class, extractor);
			this.applicationContext.getBeanFactory().registerSingleton(partitionSelectorClassName, extractor);
			this.applicationContext.getBeanFactory().initializeBean(extractor, partitionSelectorClassName);
			return ((PartitionSelectorStrategy) extractor).selectPartition(key, partitionCount);
		}
		catch (Exception e) {
			logger.error("Failed to instantiate partition selector", e);
			throw new MessageBusException("Failed to instantiate partition selector: " + partitionSelectorClassName,
					e);
		}
	}
Determine the partition to which to send this message. If a partition key extractor class is provided, it is
invoked to determine the key. Otherwise, the partition key expression is evaluated to obtain the key value. If a
partition selector class is provided, it will be invoked to determine the partition. Otherwise, if the partition
expression is not null, it is evaluated against the key and is expected to return an integer to which the modulo
function will be applied, using the partitionCount as the divisor. If no partition expression is provided, the
key will be passed to the bus partition strategy along with the partitionCount. The default partition strategy
uses {@code key.hashCode()}, and the result will be the mod of that value.
@param message the message.
@param meta the partitioning metadata.
@return the partition.
spring-xd-messagebus-spi/src/main/java/org/springframework/xd/dirt/integration/bus/MessageBusSupport.java