public class SessionProducer {
@Produces
@Dependent
public Session getSession(Connection c, InjectionPoint ip) throws JMSException {
JmsSession s = null;
if (ip != null) {
// Check for JmsSession annotation
if (ip.getAnnotated().isAnnotationPresent(JmsSession.class)) {
s = ip.getAnnotated().getAnnotation(JmsSession.class);
} else {
// Check meta-annotations
for (Annotation a : ip.getAnnotated().getAnnotations()) {
if (a.annotationType().isAnnotationPresent(JmsSession.class)) {
s = a.annotationType().getAnnotation(JmsSession.class);
}
}
}
if (s != null) {
return c.createSession(s.transacted(), s.acknowledgementMode());
}
}
// Default case where we cannot find an annotation
return c.createSession(false, Session.AUTO_ACKNOWLEDGE);