我很想知道spring集成标记中使用的类,以便通过遍历类的javadoc来获取标记的更多细节。
我有两个基本问题:
<bean class=".." />
标签?以下是spring integration xml上下文文件的一个简单示例:
<?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>
由于
答案 0 :(得分:5)
我认为你的第一个问题有些错误。见Andreas&#39;评价。
无论如何,答案就像是。
Spring中的任何自定义标记都由特定的NamespaceHandler
处理。通常,您可以在特定Spring jar中的META-INF/spring.handlers
文件中找到目标impl,例如:
http\://www.springframework.org/schema/integration/stream=org.springframework.integration.stream.config.StreamNamespaceHandler
有了这些,您可以找到如下代码:
this.registerBeanDefinitionParser("stdin-channel-adapter", new ConsoleInboundChannelAdapterParser());
您可以确定ConsoleInboundChannelAdapterParser
负责<stdin-channel-adapter>
标记的解析和实例化bean。
在那里你可以找到如下代码:
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.integration.stream.CharacterStreamReadingMessageSource");
因此,目标bean实例的真实类是CharacterStreamReadingMessageSource
。但那还不是全部。
请在此处查看设计和型号:http://docs.spring.io/spring-integration/docs/4.3.0.RELEASE/reference/html/overview.html#programming-tips