use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class IbisJobDetail method compareWith.
public boolean compareWith(IJob otherJobDef) {
IJob thisJobDef = getJobDef();
// If the CRON expression is different in both jobs, it's not equal!
if (!StringUtils.equals(thisJobDef.getCronExpression(), otherJobDef.getCronExpression())) {
return false;
}
// If the Interval expression is different in both jobs, it's not equal!
if (thisJobDef.getInterval() != otherJobDef.getInterval()) {
return false;
}
Locker thisLocker = thisJobDef.getLocker();
Locker otherLocker = otherJobDef.getLocker();
// If one is NULL but the other isn't, (locker has been removed or added, it's not equal!
if ((thisLocker == null && otherLocker != null) || (thisLocker != null && otherLocker == null)) {
return false;
}
// If both contain a locker but the key is different, it's not equal!
if (thisLocker != null && otherLocker != null && !StringUtils.equals(thisLocker.getObjectId(), otherLocker.getObjectId())) {
return false;
}
// If at this point the message is equal in both jobs, the jobs are equal!
if (thisJobDef instanceof SendMessageJob && otherJobDef instanceof SendMessageJob) {
String msg1 = ((SendMessageJob) thisJobDef).getMessage();
String msg2 = ((SendMessageJob) otherJobDef).getMessage();
return StringUtils.equals(msg1, msg2);
}
return true;
}
use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class SchedulerAdapter method getJobGroupNamesWithJobsToXml.
/**
* Get all jobgroups, jobs within this group, the jobdetail and the
* associated triggers in XML format.
*/
public XmlBuilder getJobGroupNamesWithJobsToXml(Scheduler theScheduler, IbisManager ibisManager) {
XmlBuilder xbRoot = new XmlBuilder("jobGroups");
try {
// process groups
List<String> jgnames = theScheduler.getJobGroupNames();
for (int i = 0; i < jgnames.size(); i++) {
XmlBuilder el = new XmlBuilder("jobGroup");
String jobGroupName = jgnames.get(i);
el.addAttribute("name", jobGroupName);
// process jobs within group
XmlBuilder jb = new XmlBuilder("jobs");
Set<JobKey> jobKeys = theScheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroupName));
for (JobKey jobKey : jobKeys) {
XmlBuilder jn = new XmlBuilder("job");
String jobName = jobKey.getName();
jn.addAttribute("name", jobName);
// details for job
JobDetail jobDetail = theScheduler.getJobDetail(jobKey);
XmlBuilder jd = jobDetailToXmlBuilder(jobDetail);
jn.addSubElement(jd);
// get the triggers for this job
List<? extends Trigger> triggers = theScheduler.getTriggersOfJob(jobKey);
XmlBuilder tr = getJobTriggers(triggers);
jn.addSubElement(tr);
JobDataMap jobDataMap = jobDetail.getJobDataMap();
XmlBuilder datamap = jobDataMapToXmlBuilder(jobDataMap);
jn.addSubElement(datamap);
jb.addSubElement(jn);
IJob jobDef = null;
if (ibisManager != null) {
for (Configuration configuration : ibisManager.getConfigurations()) {
jobDef = configuration.getScheduledJob(jobName);
if (jobDef != null) {
break;
}
}
}
XmlBuilder ms = getJobMessages(jobDef);
jn.addSubElement(ms);
XmlBuilder jrs = getJobRunStatistics(jobDef);
jn.addSubElement(jrs);
}
el.addSubElement(jb);
xbRoot.addSubElement(el);
}
} catch (SchedulerException se) {
log.error(se);
}
return xbRoot;
}
use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class ScheduleManager method close.
@Override
public void close() throws Exception {
if (!inState(BootState.STOPPED)) {
// Call this just in case...
stop();
}
while (!getSchedulesList().isEmpty()) {
IJob job = getSchedulesList().get(0);
unRegister(job);
}
}
use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class DigesterRuleBase method begin.
@Override
public final void begin(String uri, String elementName, Attributes attributes) throws Exception {
Object top = getBean();
Map<String, String> map = copyAttrsToMap(attributes);
if (top instanceof INamedObject) {
// We must set the name first, to improve logging and configuration warnings
String name = map.remove("name");
if (StringUtils.isNotEmpty(name)) {
BeanUtils.setProperty(top, "name", name);
}
}
// They are however still required for the JobFactory to determine the correct job class, in order to avoid ConfigurationWarnings.
if (top instanceof IJob && !(top instanceof Job)) {
map.remove("function");
}
handleBean();
for (Entry<String, String> entry : map.entrySet()) {
String attribute = entry.getKey();
if (log.isTraceEnabled()) {
log.trace("checking attribute [" + attribute + "] on bean [" + getObjectName() + "]");
}
handleAttribute(attribute, entry.getValue(), map);
}
}
use of nl.nn.adapterframework.scheduler.job.IJob in project iaf by ibissource.
the class ScheduleManager method stop.
/**
* remove all registered jobs
*/
@Override
public void stop() {
if (!inState(BootState.STARTED)) {
log.warn("forcing [" + this + "] to stop while in state [" + getState() + "]");
}
updateState(BootState.STOPPING);
log.info("stopping all adapters in AdapterManager [" + this + "]");
List<IJob> scheduledJobs = getSchedulesList();
Collections.reverse(scheduledJobs);
for (IJob jobDef : scheduledJobs) {
log.info("removing trigger for JobDef [" + jobDef.getName() + "]");
try {
getSchedulerHelper().deleteTrigger(jobDef);
} catch (SchedulerException se) {
log.error("unable to remove scheduled job [" + jobDef + "]", se);
}
}
updateState(BootState.STOPPED);
}
Aggregations