Search code examples
javaspring-integrationmessaging

what are the spring integration classes used stdin-channel-adapter?


I am interested to know the classes used in spring integration tag so that I can get more details of the tags by going through the javadoc of the classes.

I have two basic questions:

  1. Do the spring integration xml tags (for example stdin-channel-adapter) convert to <bean class=".." /> tags?
  2. how to figure out the bean class associated with the spring integration tags?

Here is a simple example of spring integration xml context file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-4.0.xsd
        http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream-4.0.xsd">


<int-stream:stdin-channel-adapter id="producer" channel="messageChannel" />
<int:poller id="defaultPoller" default="true" max-messages-per-poll="2" fixed-rate="100" />

<int-stream:stdout-channel-adapter id="consumer" channel="messageChannel" append-newline="true" /> 

<int:channel id="messageChannel" /> 

</beans>

Thanks


Solution

  • I think you have some mistake in your first question. See Andreas' comment.

    Anyway the answer for you is like.

    Any custom tags in Spring are handler by the particular NamespaceHandler. Typically you can find the target impl in file like META-INF/spring.handlers in the particular Spring jar, e.g.:

    http\://www.springframework.org/schema/integration/stream=org.springframework.integration.stream.config.StreamNamespaceHandler
    

    With that in hands you can find the code like:

    this.registerBeanDefinitionParser("stdin-channel-adapter", new ConsoleInboundChannelAdapterParser());
    

    Where you can determine that a ConsoleInboundChannelAdapterParser is responsible for parsing and instantiation beans for <stdin-channel-adapter> tag.

    And there you can find the code like:

    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
                "org.springframework.integration.stream.CharacterStreamReadingMessageSource");
    

    So, the real class for target bean instance is CharacterStreamReadingMessageSource. But that's not all.

    Please, look here for the design and model: http://docs.spring.io/spring-integration/docs/4.3.0.RELEASE/reference/html/overview.html#programming-tips