Example usage for org.springframework.util StringUtils mergeStringArrays

List of usage examples for org.springframework.util StringUtils mergeStringArrays

Introduction

In this page you can find the example usage for org.springframework.util StringUtils mergeStringArrays.

Prototype

@Deprecated
@Nullable
public static String[] mergeStringArrays(@Nullable String[] array1, @Nullable String[] array2) 

Source Link

Document

Merge the given String arrays into one, with overlapping array elements only included once.

Usage

From source file:org.springframework.flex.config.RemotingAnnotationPostProcessor.java

/**
 * // ww  w. j ava2s . com
 * {@inheritDoc}
 */
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

    Set<RemotingDestinationMetadata> remoteBeans = findRemotingDestinations(beanFactory);

    if (remoteBeans.size() > 0) {
        Assert.isInstanceOf(BeanDefinitionRegistry.class, beanFactory,
                "In order for services to be exported via the @RemotingDestination annotation, the current BeanFactory must be a BeanDefinitionRegistry.");
    }

    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;

    for (RemotingDestinationMetadata remotingDestinationConfig : remoteBeans) {

        BeanDefinitionBuilder exporterBuilder = BeanDefinitionBuilder
                .rootBeanDefinition(RemotingDestinationExporter.class);
        exporterBuilder.getRawBeanDefinition().setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

        RemotingDestination remotingDestination = remotingDestinationConfig.getRemotingDestination();

        String messageBrokerId = StringUtils.hasText(remotingDestination.messageBroker())
                ? remotingDestination.messageBroker()
                : BeanIds.MESSAGE_BROKER;
        String destinationId = StringUtils.hasText(remotingDestination.value()) ? remotingDestination.value()
                : remotingDestinationConfig.getBeanName();

        String[] channels = null;
        for (String channelValue : remotingDestination.channels()) {
            channelValue = beanFactory.resolveEmbeddedValue(channelValue);
            String[] parsedChannels = StringUtils
                    .trimArrayElements(StringUtils.commaDelimitedListToStringArray(channelValue));
            channels = StringUtils.mergeStringArrays(channels, parsedChannels);
        }

        exporterBuilder.addPropertyReference(MESSAGE_BROKER_PROPERTY, messageBrokerId);
        exporterBuilder.addPropertyValue(SERVICE_PROPERTY, remotingDestinationConfig.getBeanName());
        exporterBuilder.addDependsOn(remotingDestinationConfig.getBeanName());
        exporterBuilder.addPropertyValue(DESTINATION_ID_PROPERTY, destinationId);
        exporterBuilder.addPropertyValue(CHANNELS_PROPERTY, channels);
        exporterBuilder.addPropertyValue(INCLUDE_METHODS_PROPERTY,
                remotingDestinationConfig.getIncludeMethods());
        exporterBuilder.addPropertyValue(EXCLUDE_METHODS_PROPERTY,
                remotingDestinationConfig.getExcludeMethods());
        exporterBuilder.addPropertyValue(SERVICE_ADAPTER_PROPERTY, remotingDestination.serviceAdapter());

        BeanDefinitionReaderUtils.registerWithGeneratedName(exporterBuilder.getBeanDefinition(), registry);
    }

}