01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: /* $Id: ServletJobFactory.java 473861 2006-11-12 03:51:14Z gregor $ */
20:
21: package org.apache.lenya.cms.scheduler;
22:
23: import org.apache.log4j.Logger;
24:
25: /**
26: * Factory for building serlvet jobs.
27: */
28: public final class ServletJobFactory {
29:
30: /**
31: * Ctor.
32: */
33: private ServletJobFactory() {
34: // do nothing
35: }
36:
37: private static Logger log = Logger
38: .getLogger(ServletJobFactory.class);
39:
40: /**
41: * Creates a job.
42: * @param jobClassName The name of the Java class used to instanciate the job object.
43: * @return A servlet job.
44: */
45: public static ServletJob createJob(String jobClassName) {
46: try {
47: Class cl = Class.forName(jobClassName);
48:
49: return createJob(cl);
50: } catch (Exception e) {
51: log.error("Cannot create Job instance: " + e);
52:
53: return null;
54: }
55: }
56:
57: /**
58: * Creates a job.
59: * @param cl The Java class used to instanciate the job object.
60: * @return A servlet job.
61: */
62: public static ServletJob createJob(Class cl) {
63: try {
64: ServletJob job = (ServletJob) cl.newInstance();
65:
66: return job;
67: } catch (Exception e) {
68: log.error("Cannot create Job instance: " + e);
69:
70: return null;
71: }
72: }
73:
74: }
|