Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could do it like that (downside, you can only do your task every 1s or more):</p> <h2>Connector class</h2> <pre><code>package com.test.Connector; @Component public class Connector { @Value("${connector.user}") private String user; @Value("${connector.password}") private String password; @Value("${connector.connectionAttemptDelayMillis:0}") private long attemptDelayMillis; @Scheduled(cron = "${connector.connectionAttemptCron}") public checkConnection() { // do the check } } </code></pre> <h2>Xml context</h2> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"&gt; &lt;context:annotation-config /&gt; &lt;context:component-scan base-package="com.test" /&gt; &lt;context:property-placeholder location="classpath:connector.properties" /&gt; &lt;task:scheduler id="connectorScheduler" pool-size="10"/&gt; &lt;task:annotation-driven scheduler="connectorScheduler" /&gt; &lt;/beans&gt; </code></pre> <h2>Properties</h2> <pre><code>connector.user = someuser connector.password = somepassword connector.connectionAttemptDelayMillis = 5000 connector.connectionAttemptCron = */5 * * * * * </code></pre> <p>This works because <code>cron</code> need a string.</p> <h2>References</h2> <ul> <li><a href="http://static.springsource.org/spring/docs/3.0.x/reference/scheduling.html" rel="noreferrer">http://static.springsource.org/spring/docs/3.0.x/reference/scheduling.html</a></li> <li><a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/scheduling/annotation/Scheduled.html#cron()" rel="noreferrer">http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/scheduling/annotation/Scheduled.html#cron()</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload