2 Replies Latest reply on Oct 9, 2013 11:23 AM by Chris Ritchie

    Accessing ManagedThreadFactory via @Resource and JNDI

    Chris Ritchie Newbie

      Hi, I am trying to access a ManagedThreadFactory using @Resource. Here is what I have:


      public class ReportBean {
          private ManagedThreadFactory threadFactory;
          public void runReports() {
               ReportTask reportTask = new ReportTask();
               Thread thread = threadFactory.newThread(reportTask);



      And in the standalone.xml within the ee subsystem:


          <default-managed-executor-service hung-task-threshold="60000" core-threads="5" max-threads="25" keepalive-time="5000"/>
          <default-managed-scheduled-executor-service hung-task-threshold="60000" core-threads="2" keepalive-time="3000"/>
              <managed-thread-factory name="myManagedThreadFactory" priority="1"/>



      I have tried all sorts of variations including these below, but I can't get it to inject my managed thread factory defined above.




      I actually thought that this was working but realised that if an invalid name attribute is passed through to @Resource, then the default ManagedThreadFactory is used, with out any errors being displayed. Is this the correct behaviour? What do I need to do to inject my own ManagedThreadFactory.


      Thanks in advance,