2016-07-07 4 views
0

도와주세요. blueprint.xml에 선언 된 bean을 Camel processor에 주입하는 방법? 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이 얻을. 그렇다면 컨테이너로 생성 한 빈 센더를 MyProccessor에 삽입 할 수 있습니까? 어떻게 할 수 있니?

답변

0

주입으로 무엇을 원하는가?

일반적으로 프로세서는 다음과 같이 사용된다 :

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

지원하지 않는 프로세서를 주입 http://camel.apache.org/bean-integration.html에 따른 외.

+0

컨테이너 (IoC)로 만든 클래스 초기화를 원합니다. 그리고 초기화 된 클래스 (예를 들어, Sender.class)가 낙타 프로세서에 삽입됩니다. – Maciavelli

+0

글쎄, 어떻게 프로세서를 사용할 수 있는지 보여 주었다. –

관련 문제