List of usage examples for org.springframework.integration.channel AbstractMessageChannel setDatatypes
public void setDatatypes(Class<?>... datatypes)
From source file:org.springframework.xd.dirt.plugins.stream.ModuleTypeConversionPlugin.java
private void configureModuleConverters(String contentTypeString, Module module, boolean isInput) { if (logger.isDebugEnabled()) { logger.debug("module " + (isInput ? "input" : "output") + "Type is " + contentTypeString); }/* w w w . ja v a 2 s . c om*/ SimpleModule sm = (SimpleModule) module; try { MimeType contentType = resolveContentType(contentTypeString, module); AbstractMessageChannel channel = getChannel(module, isInput); CompositeMessageConverter converters = null; try { converters = converterFactory.newInstance(contentType); } catch (ConversionException e) { throw new ModuleConfigurationException(e.getMessage() + "(" + module.getName() + " --" + (isInput ? "input" : "output") + "Type=" + contentTypeString + ")"); } Class<?> dataType = MessageConverterUtils.getJavaTypeForContentType(contentType, sm.getApplicationContext().getClassLoader()); if (dataType == null) { throw new ModuleConfigurationException("Content type is not supported for " + module.getName() + " --" + (isInput ? "input" : "output") + "Type=" + contentTypeString); } else { channel.setDatatypes(dataType); channel.setMessageConverter(converters); } } catch (Throwable t) { throw new ModuleConfigurationException(t.getMessage(), t); } }
From source file:org.springframework.xd.dirt.plugins.stream.ModuleTypeConversionSupport.java
/** * Configure the message converters for the given message channel and content type. * Detect the data types from the provided class loader. * * @param channel the message channel to configure the message converters * @param contentType the content type to use * @param classLoader the classloader to search the dataType(s) classes */// ww w. j a v a2 s. c o m public void configureMessageConverters(AbstractMessageChannel channel, MimeType contentType, ClassLoader classLoader) { CompositeMessageConverter converters = null; try { converters = converterFactory.newInstance(contentType); } catch (ConversionException e) { throw new ModuleConfigurationException( e.getMessage() + "(" + channel.getComponentName() + "Type=" + contentType + ")"); } Class<?> dataType = MessageConverterUtils.getJavaTypeForContentType(contentType, classLoader); if (dataType == null) { throw new ModuleConfigurationException( "Content type is not supported for " + channel.getComponentName() + "Type=" + contentType); } else { channel.setDatatypes(dataType); channel.setMessageConverter(converters); } }