java - Deltaspike + Quartz + CronExpressions from custom property file -


i've achieved configuring cronexpression propery file, property file apache-deltaspike.properties, inside .jar file. need take cron expression 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 when set property: quartzjob=0 25 17 * * ? inside apache-deltaspike.properties, when set in own property file, get:

java.lang.illegalstateexception: no config-value found config-key: quartzjob  

researching, found property file loaded right after quartz initialization, , explains why. now, read in deltaspike doc it's possible property file loaded whenever want, using deltaspike_ordinal inside property file. tried, seems ignore deltaspike_ordinal=500, , error keeps arising.

so, know how sort out? deltaspike doc talks configsource , so, it's not clear , there no examples.

thanks in advance!

got it. key javadoc of propertyfileconfig:

  1. automatic pickup via java.util.serviceloader mechanism in case have ear or you need configured values during cdi container start can register propertyfileconfig via java.util.serviceloader mechanism. not have configuration picked twice required annotate own propertyfileconfig implementation org.apache.deltaspike.core.api.exclude.exclude.

the serviceloader mechanism requires have file meta-inf/services/org.apache.deltaspike.core.api.config.propertyfileconfig containing qualified class name of own propertyfileconfig implementation class.
com.acme.my.own.somespecialpropertyfileconfig implementation following:

@exclude   public class somespecialpropertyfileconfig implements propertyfileconfig      {       public string getpropertyfilename() {           return "myconfig/specialconfig.properties"       }       public boolean isoptional() {           return false;       }   } 

worked charm


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -