01: /*
02: * $Id: ProcessControllerFactory.java,v 1.6 2004/12/03 10:20:04 kowap Exp $
03: *
04: * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
05: * Berne University of Applied Sciences
06: * School of Engineering and Information Technology
07: * All rights reserved.
08: */
09: package bexee.core;
10:
11: import org.apache.commons.logging.Log;
12: import org.apache.commons.logging.LogFactory;
13:
14: import bexee.util.BexeeProperties;
15: import bexee.util.Constants;
16:
17: /**
18: * Abstract factory class for creating <code>ProcessControllerFactory</code>
19: * implementations.
20: *
21: * @version $Revision: 1.6 $, $Date: 2004/12/03 10:20:04 $
22: * @author Patric Fornasier
23: * @author Pawel Kowalski
24: */
25: public class ProcessControllerFactory {
26:
27: private static Log log = LogFactory
28: .getLog(ProcessControllerFactory.class);
29:
30: /**
31: * Creates a new <code>ProcessController</code>. The actual type is
32: * defined by the property <code>bexee.controller</code>.
33: * <p>
34: * If it is not set then {@link ProcessControllerImpl}will be created.
35: *
36: * @return a <code>ProcessController</code> implementation
37: */
38: public static ProcessController createProcessController() {
39:
40: ProcessController controller = null;
41:
42: String className = BexeeProperties
43: .getProperty(Constants.OPT_CONTROLLER);
44:
45: // if option is not set, create default factory
46: if (className == null) {
47: log.debug(Constants.OPT_DAO_FACTORY
48: + " not set, creating default implementation: "
49: + ProcessControllerImpl.class.getName());
50: controller = new ProcessControllerImpl();
51: } else {
52: try {
53: // try to instantiate indicated class
54: Class clazz = Class.forName(className);
55: controller = (ProcessController) clazz.newInstance();
56: } catch (Exception e) {
57: log.warn("unable to create " + className
58: + ", creating default implementation: "
59: + ProcessControllerImpl.class.getName());
60: controller = new ProcessControllerImpl();
61: }
62: }
63:
64: return controller;
65: }
66: }
|