Hallo all,
I’m in need to re-implement this bean in jruby:
package camelinaction;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
public class OrderStatusBean {
private ProducerTemplate template;
public OrderStatusBean() {
}
public OrderStatusBean(CamelContext context) {
setTemplate(context.createProducerTemplate());
}
public void setTemplate(ProducerTemplate template) {
this.template = template;
}
}
Well: the problem is with the overloaded constructor. No problem if I
don’t need the CamelContext (just leave only the no-params constructor).
But when I need to receive the CamelContext I stumble in this problem:
if I omit the no-params constructor camel complains the lack of the
defaults constructor:
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name ‘epiReplicaQuery’ defined in file
[/homel/francesco/sviluppo/camel/epiReplicaPeriodic/target/classes/META-INF/spring/camel-context.xml]:
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class [it.unimore.cesia.EpiReplicaQuery]: No default
constructor found; nested exception is java.lang.NoSuchMethodException:
it.unimore.cesia.EpiReplicaQuery.()
My (non working) translation in jruby is:
require ‘java’
java_import “org.apache.camel.ProducerTemplate”
java_import “org.apache.camel.CamelContext”
java_import “org.slf4j.Logger”
java_import “org.slf4j.LoggerFactory”
java_import “ch.qos.logback.classic.LoggerContext”
java_package “camelinaction”
class OrderStatusBean
def initialize(context)
@template = context.createProducerTemplate
@logger =
LoggerFactory.getLogger(“it.unimore.cesia.#{File.basename(FILE,
“.rb”)}”)
@logger.info(“Hello from #{FILE}.”)
end
def send_msg
@logger.info(“Sent mesg”)
@template.sendBody(“this is a test”);
end
end
Thank you for your help,
Francesco