title: How to go from XML Spring scheduling configuration to annotation/code configuration?
body: <p>I am trying to convert the following Spring task xml configuration to a purely code/annotation based version:</p>
  
  <pre><code>&lt;task:executor id="xyz.executor"
      pool-size="${xyz.job.executor.pool.size:1-40}"
      queue-capacity="${xyz.job.executor.queue.capacity:0}"
      rejection-policy="CALLER_RUNS"/&gt;
  
  &lt;task:scheduler id="xyz.scheduler" pool size="${xyz.job.scheduler.pool.size:4}"  /&gt;
  
  &lt;task:annotation-driven executor="xyz.executor" scheduler="xyz.scheduler" /&gt;
  
  &lt;bean id='xyzProcessor' class="xyz.queueing.QueueProcessor" /&gt; 
  
  &lt;task:scheduled-tasks scheduler="xyz.scheduler" &gt;
      &lt;task:scheduled ref="partitioner" method="createPartitions" cron="${xyz.job.partitioner.interval:0 0 3 * * *}" /&gt;
  &lt;/task:scheduled-tasks&gt;
  </code></pre>
  
  <p>Per the Spring spec, 28.4.1 (<a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/scheduling.html" rel="noreferrer">http://docs.spring.io/spring/docs/current/spring-framework-reference/html/scheduling.html</a>), they say that to go from XML like this:</p>
  
  <pre><code>&lt;task:annotation-driven executor="myExecutor" scheduler="myScheduler"/&gt;
  &lt;task:executor id="myExecutor" pool-size="5"/&gt;
  &lt;task:scheduler id="myScheduler" pool-size="10"/&gt;
  </code></pre>
  
  <p>to code configuration is as simply as enabling either @EnableScheduling and/or @EnableAsync.</p>
  
  <p>However, I don't see anywhere I can actually instantiate the scheduler. The javadoc for @EnableScheduling (<a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/annotation/EnableScheduling.html" rel="noreferrer">http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/annotation/EnableScheduling.html</a>) shows how I can get plug in my own created Executor, though I'm not exactly sure what class it should be (I still want to be able to control the pool size, queue capacity, and rejection policy). It also shows how I can schedule my createPartitions method using the configureTasks override. However, I would like to be able to name my scheduler (so I can identify its threads) and control its pool size.</p>
  
  <p>So, I wish to know these things:</p>
  
  <p>1) What class can I use to set the executor fields that the XML has?</p>
  
  <p>2) Is there a way to create a scheduler instance that I can control the name and pool size of?</p>