[jboss-jira] [JBoss JIRA] (AS7-5620) @Resource injection isn't done on static members
John Doyle (JIRA)
jira-events at lists.jboss.org
Fri Apr 26 13:42:53 EDT 2013
[ https://issues.jboss.org/browse/AS7-5620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770465#comment-12770465 ]
John Doyle commented on AS7-5620:
---------------------------------
David, it did get opened as an RFE. Can you give me some info or a link on "Jaikiran's component-level interceptor functionality". Is that something that the customer implements, or a new feature?
> @Resource injection isn't done on static members
> -------------------------------------------------
>
> Key: AS7-5620
> URL: https://issues.jboss.org/browse/AS7-5620
> Project: Application Server 7
> Issue Type: Bug
> Components: CDI / Weld
> Affects Versions: 7.1.3.Final (EAP)
> Reporter: Miroslav Novak
> Assignee: Stuart Douglas
>
> There is a change in behaviour of:
> {code}
> @Resource(mappedName = "java:/JmsXA")
> private static ConnectionFactory cf;
> {code}
> In EAP6/AS7.1.2.Final this property is initialized but in EAP6.0.1.ER2/AS7.1.3.Final is not.
> This could also break backward compatibility. Is there a reason why this feature should not work?
> Used MDB:
> {code}
> import java.util.concurrent.atomic.AtomicInteger;
> import javax.annotation.Resource;
> import javax.ejb.*;
> import javax.jms.*;
> import org.apache.log4j.Level;
> import org.apache.log4j.Logger;
> @MessageDriven(name = "mdb",
> activationConfig = {
> @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
> @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/queue/InQueue")})
> @TransactionManagement(value = TransactionManagementType.CONTAINER)
> @TransactionAttribute(value = TransactionAttributeType.REQUIRED)
> public class LocalMdbFromQueue implements MessageDrivenBean, MessageListener {
> @Resource(mappedName = "java:/JmsXA")
> private static ConnectionFactory cf;
> @Resource(mappedName = "java:/jms/queue/OutQueue")
> private static Queue queue;
> public static AtomicInteger globalCounter = new AtomicInteger();
> private static final long serialVersionUID = 2770941392406343837L;
> private static final Logger log = Logger.getLogger(LocalMdbFromQueue.class.getName());
> private MessageDrivenContext context = null;
> public LocalMdbFromQueue() {
> super();
> }
> @Override
> public void setMessageDrivenContext(MessageDrivenContext ctx) {
> this.context = ctx;
> }
> public void ejbCreate() {
> }
> @Override
> public void ejbRemove() {
> }
> @Override
> public void onMessage(Message message) {
> Connection con = null;
> Session session;
> try {
> long time = System.currentTimeMillis();
> int counter = 0;
> try {
> counter = message.getIntProperty("count");
> } catch (Exception e) {
> log.log(Level.ERROR, e.getMessage(), e);
> }
> String messageInfo = message.getJMSMessageID() + ", count:" + counter;
> log.log(Level.INFO, " Start of message: " + globalCounter.incrementAndGet() + ", message info:" + messageInfo);
> con = cf.createConnection();
> con.start();
> session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
> String text = message.getJMSMessageID() + " processed by: " + hashCode();
> MessageProducer sender = session.createProducer(queue);
> TextMessage newMessage = session.createTextMessage(text);
> newMessage.setStringProperty("inMessageId", message.getJMSMessageID());
> sender.send(newMessage);
> log.log(Level.INFO, " End of " + messageInfo + " in " + (System.currentTimeMillis() - time) + " ms");
> } catch (Exception t) {
> t.printStackTrace();
> log.log(Level.FATAL, t.getMessage(), t);
> } finally {
> if (con != null) {
> try {
> con.close();
> } catch (JMSException e) {
> log.log(Level.FATAL, e.getMessage(), e);
> }
> }
> }
> }
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list