[weld-dev] Dynamic Injection Question
Pete Muir
pmuir at redhat.com
Thu Apr 8 07:38:59 EDT 2010
Are you using Weld 1.0.1 - I fixed this there IIRC.
On 8 Apr 2010, at 02:45, Jordan Ganoff wrote:
> 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://github.com/jganoff/seam3-jms/blob/master/src/main/java/org/jboss/seam/jms/impl/inject/DestinationProducer.java
> --
> Jordan Ganoff
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
More information about the weld-dev
mailing list