2016-07-08 4 views
1

春の統合タグで使用されるクラスを知りたいので、クラスのjavadocを使ってタグの詳細を取得できます。stdin-channel-adapterで使用されるスプリング統合クラスは何ですか?

私は2つの基本的な質問があります。<bean class=".." />タグに変換する(例えば標準入力チャンネル・アダプタ)

  1. を春の統合XMLタグですか?
  2. スプリング統合タグに関連付けられたBeanクラスを理解する方法はありますか?ここで

春の統合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> 

おかげ

+1

1)* "のタグがタグに変換しますか?" *えを、何?!? --- 2)コードを実行し、次にBeanファクトリからBeanを取得し、それが何であるかを確認します。それは[経験的証拠](https://en.wikipedia.org/wiki/Empirical_evidence)(観察によって得られた知識)と呼ばれています。 – Andreas

+0

1)申し訳ありませんがフォーマットの問題でした。もう少し明確にするために質問を更新しました。 2)あなたの解決策はそれを実行する1つの方法です。ありがとう。 – kevin

答えて

5

。アンドレアスのコメントを参照してください。

とにかく答えはあなたのようです。

Springのカスタムタグは、特にNamespaceHandlerによるハンドラです。通常は、特定の春の瓶でMETA-INF/spring.handlersのようにファイルのターゲットのimplを見つけることができます例:あなたが判断することができるどこ

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

:手の中に

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

次のようなコードを見つけることができます<stdin-channel-adapter>タグの解析およびインスタンス化Beanは、ConsoleInboundChannelAdapterParserが担当します。

そして、そこに次のようなコードを見つけることができます:

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

+0

優れた説明とこれが私が探していたものです。ありがとう。 – kevin

関連する問題