2016-07-07 2 views
0

助けてください。 blueprint.xmlで宣言されたBeanをCamelプロセッサに挿入する方法は? Jboss Fuse 6.1コンテナに配置するOSGIバンドルを作成しています。私の現在のblueprint.xml:ブループリントビーンをラクダプロセッサーに注入する

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:camel="http://camel.apache.org/schema/blueprint" 
       xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf" 
       xmlns:cxf="http://cxf.apache.org/blueprint/core" 
       xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws" 

       xsi:schemaLocation=" 
      http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd 
      http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd 
      http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd 
      http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd 
    http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd" 
    > 
<bean id="MyProcessor" class="com.test.MyProcessor" /> 
<bean id="Sender" class="com.test.Sender" scope="prototype"> 
     <property name="senderId" value="admin" /> 
     <property name="password" value="admin" /> 
    </bean> 
      <camelContext trace="false" id="blueprintContext" xmlns="http://camel.apache.org/schema/blueprint"> 
      <route> 
       <from uri="activemq:queue:paymentsqueue?username=admin&amp;password=admin" id="NotificationRoute"> 
        <description/> 
       </from> 
       <log message="The message contains ${body}"/> 
       <process ref="MyProcessor"/> 
      </route> 
     </camelContext> 
    </blueprint> 

これはラクダプロセッサ:

import org.apache.aries.blueprint.annotation.Inject; 
    public class MyProcessor implements Processor { 

    @Inject 
    private Sender sender; 

    @Override 
    public void process(Exchange x) throws Exception { 
     log.info("test: " +sender.getSenderId()); 
    } 

しかし、私はNullPointerExceptionが取得します。コンテナで作成したBean SenderをMyProccessorに挿入することは可能ですか?それはどうやってできるの?

答えて

0

注入によって達成したいのは何ですか?サポートされていないプロセッサを注入http://camel.apache.org/bean-integration.htmlに係るほか

public void process(Exchange x) throws Exception { 
    from("direct://start") 
    .to("MyProcessor")   
    log.info("test: " +sender.getSenderId()); 
} 

通常、プロセッサは、このように使用されます。

+0

コンテナ(IoC)で作成されたクラス初期化が必要です。そして初期化されたクラス(私の例ではSender.classです)がラクダプロセッサに挿入されます。 – Maciavelli

+0

さて、どのようにしてプロセッサーを使用できるかを示しました。 –

関連する問題