Skip to content

Commit

Permalink
SEAMJMS-15 Added disposers for built in producers.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnament committed Feb 13, 2011
1 parent d8646ce commit 79b5701
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -25,6 +25,7 @@

import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
Expand Down Expand Up @@ -60,6 +61,10 @@ public TopicPublisher createTopicProducer(InjectionPoint ip, Session s) throws J
return TopicPublisher.class.cast(s.createProducer(t));
}

public void disposeTopicProducer(@Disposes @Any TopicPublisher tp) throws JMSException {
tp.close();
}

@Produces
@JmsDestination
public TopicSubscriber createTopicSubscriber(InjectionPoint ip, Session s) throws JMSException
Expand All @@ -69,6 +74,10 @@ public TopicSubscriber createTopicSubscriber(InjectionPoint ip, Session s) throw
return TopicSubscriber.class.cast(s.createConsumer(t));
}

public void disposesTopicSubscriber(@Disposes @Any TopicSubscriber ts) throws JMSException {
ts.close();
}

@Produces
@JmsDestination
public QueueSender createQueueSender(InjectionPoint ip, Session s) throws JMSException
Expand All @@ -78,6 +87,10 @@ public QueueSender createQueueSender(InjectionPoint ip, Session s) throws JMSExc
return QueueSender.class.cast(s.createProducer(q));
}

public void disposesQueueSender(@Disposes @Any QueueSender qs) throws JMSException {
qs.close();
}

@Produces
@JmsDestination
public QueueReceiver createQueueReceiver(InjectionPoint ip, Session s) throws JMSException
Expand All @@ -86,4 +99,8 @@ public QueueReceiver createQueueReceiver(InjectionPoint ip, Session s) throws JM
Queue q = anyQueue.select(d).get();
return QueueReceiver.class.cast(s.createConsumer(q));
}

public void disposesQueueReceiver(@Disposes @Any QueueReceiver qr) throws JMSException {
qr.close();
}
}

0 comments on commit 79b5701

Please sign in to comment.