34
34
import org .slf4j .LoggerFactory ;
35
35
36
36
@ Component (
37
- service = ResourceChangeListener .class ,
37
+ service = { ResourceChangeListener .class , AutomaticScriptScheduler . class } ,
38
38
immediate = true ,
39
39
property = {
40
40
ResourceChangeListener .PATHS + "=glob:" + ScriptRepository .ROOT + "/automatic/**/*.groovy" ,
@@ -54,12 +54,6 @@ public class AutomaticScriptScheduler implements ResourceChangeListener {
54
54
description = "Schedules automatic scripts on instance up and script changes" )
55
55
public @interface Config {
56
56
57
- @ AttributeDefinition (
58
- name = "Boot Delay" ,
59
- description = "Time in milliseconds to delay the boot job execution"
60
- )
61
- long bootDelay () default 1000 * 10 ; // 10 seconds
62
-
63
57
@ AttributeDefinition (
64
58
name = "User Impersonation ID" ,
65
59
description =
@@ -138,6 +132,14 @@ public void onChange(List<ResourceChange> changes) {
138
132
}
139
133
}
140
134
135
+ public void bootOnDemand () {
136
+ LOG .info ("Automatic scripts booting on demand - job scheduling" );
137
+ unscheduleBoot ();
138
+ scheduleBoot ();
139
+ LOG .info ("Automatic scripts booting on demand - job scheduled" );
140
+ }
141
+
142
+ // TODO on AEMaaCS scheduler refuses to schedule job during activate
141
143
private void bootWhenInstanceUp () {
142
144
LOG .info ("Automatic scripts booting on instance up - job scheduling" );
143
145
unscheduleBoot ();
@@ -157,8 +159,7 @@ private void unscheduleBoot() {
157
159
}
158
160
159
161
private void scheduleBoot () {
160
- Date bootDate = new Date (System .currentTimeMillis () + config .bootDelay ());
161
- scheduler .schedule (bootJob (), configureScheduleOptions (BOOT_JOB_NAME , scheduler .AT (bootDate )));
162
+ scheduler .schedule (bootJob (), configureScheduleOptions (BOOT_JOB_NAME , scheduler .NOW ()));
162
163
}
163
164
164
165
private ScheduleOptions configureScheduleOptions (String name , ScheduleOptions options ) {
0 commit comments