Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ScheduledJobLoader |
|
| 0.0;0 |
1 | package org.apache.turbine.modules; | |
2 | ||
3 | ||
4 | /* | |
5 | * Licensed to the Apache Software Foundation (ASF) under one | |
6 | * or more contributor license agreements. See the NOTICE file | |
7 | * distributed with this work for additional information | |
8 | * regarding copyright ownership. The ASF licenses this file | |
9 | * to you under the Apache License, Version 2.0 (the | |
10 | * "License"); you may not use this file except in compliance | |
11 | * with the License. You may obtain a copy of the License at | |
12 | * | |
13 | * http://www.apache.org/licenses/LICENSE-2.0 | |
14 | * | |
15 | * Unless required by applicable law or agreed to in writing, | |
16 | * software distributed under the License is distributed on an | |
17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
18 | * KIND, either express or implied. See the License for the | |
19 | * specific language governing permissions and limitations | |
20 | * under the License. | |
21 | */ | |
22 | ||
23 | ||
24 | import org.apache.turbine.Turbine; | |
25 | import org.apache.turbine.pipeline.PipelineData; | |
26 | import org.apache.turbine.services.schedule.JobEntry; | |
27 | ||
28 | /** | |
29 | * ScheduledJobs loader class. | |
30 | * | |
31 | * @author <a href="mailto:mbryson@mindspring.com">Dave Bryson</a> | |
32 | * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> | |
33 | * @version $Id: ScheduledJobLoader.java 1854786 2019-03-04 18:29:18Z tv $ | |
34 | */ | |
35 | public class ScheduledJobLoader | |
36 | extends GenericLoader<ScheduledJob> | |
37 | { | |
38 | /** The single instance of this class. */ | |
39 | 27 | private static ScheduledJobLoader instance = new ScheduledJobLoader(); |
40 | ||
41 | /** | |
42 | * These ctor's are private to force clients to use getInstance() | |
43 | * to access this class. | |
44 | */ | |
45 | private ScheduledJobLoader() | |
46 | { | |
47 | 27 | super(ScheduledJob.class, |
48 | 0 | () -> Turbine.getConfiguration().getInt(ScheduledJob.CACHE_SIZE_KEY, |
49 | ScheduledJob.CACHE_SIZE_DEFAULT)); | |
50 | 27 | } |
51 | ||
52 | /** | |
53 | * Attempts to load and execute the external ScheduledJob. | |
54 | * | |
55 | * @param job The JobEntry. | |
56 | * @param name Name of object that will execute the job. | |
57 | * @throws Exception a generic exception. | |
58 | */ | |
59 | public void exec(JobEntry job, String name) | |
60 | throws Exception | |
61 | { | |
62 | // Execute job | |
63 | 42 | getAssembler(name).run(job); |
64 | 42 | } |
65 | ||
66 | /** | |
67 | * Attempts to load and execute the external ScheduledJob. | |
68 | * | |
69 | * HELP! - THIS IS UGLY! | |
70 | * | |
71 | * I want the cache stuff from GenericLoader, BUT, I don't think | |
72 | * the scheduler needs the PipelineData object. The scheduler runs | |
73 | * independently of an HTTP request. This should not extend | |
74 | * GenericLoader! Thoughts?? | |
75 | * | |
76 | * @param pipelineData Turbine information. | |
77 | * @param name Name of object that will execute the job. | |
78 | * @throws Exception a generic exception. | |
79 | * @deprecated | |
80 | */ | |
81 | @Deprecated | |
82 | @Override | |
83 | public void exec(PipelineData pipelineData, String name) | |
84 | throws Exception | |
85 | { | |
86 | 0 | throw new Exception("PipelineData objects not accepted for Scheduled jobs"); |
87 | } | |
88 | ||
89 | /** | |
90 | * The method through which this class is accessed. | |
91 | * | |
92 | * @return The single instance of this class. | |
93 | */ | |
94 | public static ScheduledJobLoader getInstance() | |
95 | { | |
96 | 42 | return instance; |
97 | } | |
98 | } |