I've achieved configuring CronExpression from a propery file, but this property file is apache-deltaspike.properties, which is inside the .jar file. I need to take the cron expression from my custom config file:
import org.apache.deltaspike.core.api.config.PropertyFileConfig;
public class myOwnPropertyFileConfig implements PropertyFileConfig {
private static final long serialVersionUID = 1L;
@Override
public String getPropertyFileName() {
return "cfg/myOwnPropFile.properties";
}
@Override
public boolean isOptional() {
return false;
}
}
myOwnPropFile.properties
deltaspike_ordinal=500
property1=value1
property2=value2
QuartzJob=0 25 17 * * ?
the job:
@Scheduled(cronExpression = "{QuartzJob}")
public class MyQuartzJob implements Job {
//job code
}
Everything goes good when I set this property: QuartzJob=0 25 17 * * ? inside apache-deltaspike.properties, but when I set it in my own property file, I get:
java.lang.IllegalStateException: No config-value found for config-key: QuartzJob
Researching, I found that my property file is loaded right after Quartz initialization, and that explains the why. Now, I read in Deltaspike doc that it's possible to get my property file loaded whenever I want, using deltaspike_ordinal inside my property file. So I tried, but it seems to ignore the deltaspike_ordinal=500, and error keeps arising.
So, does someone know how to sort this out? Deltaspike doc also talks about a ConfigSource and so, but it's not so clear and there are no examples.
Thanks in advance!