This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue #42 - scheduler class with simple CRON scheduling methods
- Loading branch information
James Simone
committed
Jul 21, 2017
1 parent
289ce88
commit 1b77de5
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/************************************************************************************************* | ||
* This file is part of the Nebula Framework project, released under the MIT License. * | ||
* See LICENSE file or go to https://github.com/jongpie/NebulaFramework for full license details. * | ||
*************************************************************************************************/ | ||
public class Scheduler { | ||
//CRON order - Seconds, Minutes, Hours, Day_of_month, Month, Day_of_week, Optional_year | ||
public final static String DAILY_CRON = '0 {0} {1} * * ?'; | ||
public final static String HOURLY_CRON = '0 {0} * * * ?'; | ||
private final Schedulable scheduledClass; | ||
|
||
public Scheduler (Schedulable scheduledClass) { | ||
this.scheduledClass = scheduledClass; | ||
} | ||
|
||
public String scheduleHourly(String jobName, String startingMinuteInHour) { | ||
String hourlyCRON = String.format(HOURLY_CRON, new List<String>{startingMinuteInHour}); | ||
return this.schedule(jobName, hourlyCRON); | ||
} | ||
|
||
public String scheduleDaily(String jobName, List<String> startingHourAndMinute) { | ||
String dailyCRON = String.format(DAILY_CRON, startingHourAndMinute); | ||
return this.schedule(jobName, dailyCRON); | ||
} | ||
|
||
public String schedule(String jobName, String cronExpression) { | ||
return System.schedule(jobName, cronExpression, this.scheduledClass); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>39.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |