开发者

how to specify a codec in apache camel mina

开发者 https://www.devze.com 2023-02-15 20:31 出处:网络
I\'m trying to use the hl7codec in apache mina.I can see how to do it using spring e.g. beans:bean id=\"hl7codec\" class=\"org.apache.camel.component.hl7.HL7MLLPCodec\"

I'm trying to use the hl7codec in apache mina. I can see how to do it using spring e.g.

beans:bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec"
    beans:property name="charset" value="iso-8859-1"
 /beans:bean

but can't figure out how to do it using POJO / DSL i.e. my route is specified as

from("mina:tcp://0.0.0.0:21110?sync=true&codec=#hl7codec")
  .to("file://test");

but this can't resolve the #hl7codec id.

Given an allergy to 开发者_C百科Spring, can anyone suggest an alternative way of specifying the codec or replicating the Spring dependency injection?


If you are not using Spring at all, you need to enlist the hl7codec in the Camel registry. In pure Java you can do this by

SimpleRegistry reg = new SimpleRegistry();
reg.put("hl7codec", new MyCodecObject());

CamelContext context = new DefaultCamelContext(reg);

The Camel in Action book covers this in chapter 4, section 4.3.1

0

精彩评论

暂无评论...
验证码 换一张
取 消