Created
April 8, 2010 01:30
-
-
Save jganoff/359673 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jboss.seam.jms.impl.inject; | |
import javax.enterprise.context.RequestScoped; | |
import javax.enterprise.inject.Any; | |
import javax.enterprise.inject.Instance; | |
import javax.enterprise.inject.Produces; | |
import javax.enterprise.inject.spi.InjectionPoint; | |
import javax.inject.Inject; | |
import javax.jms.JMSException; | |
import javax.jms.Queue; | |
import javax.jms.QueueReceiver; | |
import javax.jms.QueueSender; | |
import javax.jms.Session; | |
import javax.jms.Topic; | |
import javax.jms.TopicPublisher; | |
import javax.jms.TopicSubscriber; | |
import org.jboss.seam.jms.annotations.JmsDestination; | |
public @RequestScoped | |
class MessagePubSubProducer | |
{ | |
@Inject | |
@Any | |
Instance<Topic> anyTopic; | |
@Inject | |
@Any | |
Instance<Queue> anyQueue; | |
@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 TopicSubscriber createTopicSubscriber(InjectionPoint ip, Session s) throws JMSException | |
{ | |
Topic t = anyTopic.select(ip.getAnnotated().getAnnotation(JmsDestination.class)).get(); | |
return TopicSubscriber.class.cast(s.createConsumer(t)); | |
} | |
@Produces | |
@JmsDestination | |
public QueueSender createQueueSender(InjectionPoint ip, Session s) throws JMSException | |
{ | |
Queue q = anyQueue.select(ip.getAnnotated().getAnnotation(JmsDestination.class)).get(); | |
return QueueSender.class.cast(s.createProducer(q)); | |
} | |
@Produces | |
@JmsDestination | |
public QueueReceiver createQueueReceiver(InjectionPoint ip, Session s) throws JMSException | |
{ | |
Queue q = anyQueue.select(ip.getAnnotated().getAnnotation(JmsDestination.class)).get(); | |
return QueueReceiver.class.cast(s.createConsumer(q)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment