[weld-dev] Dynamic Injection Question
Jordan Ganoff
jganoff at gmail.com
Wed Apr 7 21:45:33 EDT 2010
I was testing out a simple idea for another JMS injection type and ran into
an issue with Instance.get() and additional select annotations. The
InjectionPoint of the producer lacked the additional selected annotations.
I'm trying to create a TopicProducer and need to dynamically inject a
topic. When the topic producer is invoked the InjectionPoint does not
contain the JmsDestination (the annotations are only @Inject and @Any, which
seems like @Inject shouldn't be there either). Is there a better way to do
this?
Here's the code:
@Inject @Any Instance<Topic> anyTopic;
@Produces @JmsDestination
public TopicPublisher createTopicProducer(InjectionPoint ip, Session s)
throws JMSException
{
Topic t =
anyTopic.select(ip.getAnnotated().getAnnotation(JmsDestination.class)).get();
return TopicPublisher.class.cast(s.createProducer(t));
}
...
@Produces
@JmsDestination
public Topic getTopic(InjectionPoint ip, @Module Context c) throws
NamingException
{
JmsDestination d = ip.getAnnotated().getAnnotation(JmsDestination.class);
return (Topic) c.lookup(d.jndiName());
}
Thanks in advance.
P.S. Actual code links:
http://gist.github.com/359673
<http://gist.github.com/359673>
http://github.com/jganoff/seam3-jms/blob/master/src/main/java/org/jboss/seam/jms/impl/inject/DestinationProducer.java
--
Jordan Ganoff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20100407/97dc8833/attachment-0001.html
More information about the weld-dev
mailing list