camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Checkoway <dchecko...@gmail.com>
Subject Bug? @EndpointInject not injected in superclasses
Date Tue, 01 Feb 2011 14:20:49 GMT
Before I report this in JIRA as a bug in Camel 2.6.0, I want to make sure
what I'm trying to do is actually supported.

When I use @EndpointInject in a bean in my spring app context, the endpoint
gets injected no problem on either a ProducerTemplate or Endpoint.  But when
I use @EndpointInject on a *SUPERCLASS* of my bean(s), the endpoint does NOT
get injected and I end up getting a NullPointerException when I try to use
it.

Pseudo-code below...please let me know if what I'm trying to do should be
supported.  I believe this is a bug in the annotation processor, where it's
not processing superclasses.

// ================= THIS WORKS:

@Component
public class AllGood {
    @Autowired
    ProducerTemplate producerTemplate;
    @EndpointInject(uri="activemq:queue:my.queue")
    Endpoint myQueue;

    public void send() {
        producerTemplate.sendBody(myQueue, "body");
    }
}

// ================= THIS ALSO WORKS:

@Component
public class AllGood {
    @EndpointInject(uri="activemq:queue:my.queue")
    ProducerTemplate producerTemplate;

    public void send() {
        producerTemplate.sendBody("body");
    }
}

// ================= THIS DOES NOT WORK:

public abstract class BaseClass {
    @Autowired
    ProducerTemplate producerTemplate;
    @EndpointInject(uri="activemq:queue:my.queue")
    Endpoint myQueue;

    public void send() {
        producerTemplate.sendBody(myQueue, "body");
    }
}

@Component
public class SubClass1 extends BaseClass {
    public void doSomeStuff() {
        send();
    }
}

// ================= NEITHER DOES THIS:

public abstract class BaseClass {
    @EndpointInject(uri="activemq:queue:my.queue")
    ProducerTemplate producerTemplate;

    public void send() {
        producerTemplate.sendBody("body");
    }
}

@Component
public class SubClass2 extends BaseClass {
    public void doSomeStuff() {
        send();
    }
}

// =========================

Thanks,
Dan

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message