01: package org.tigris.scarab.notification;
02:
03: import org.apache.log4j.Logger;
04: import org.apache.turbine.Turbine;
05: import org.tigris.scarab.util.Log;
06:
07: /**
08: * This factory is used to get an instance of the notification manager
09: * configured in scarab.notificationmanager.classname.
10: *
11: * @see org.tigris.scarab.notification.NotificationManager
12: * @author jorgeuriarte
13: */
14: public class NotificationManagerFactory {
15: public static Logger log = Log.get(NotificationManagerFactory.class
16: .getName());
17:
18: private static NotificationManager instance = null;
19:
20: /**
21: * Returns an instance of the currently defined NotificationManager.
22: */
23: public static NotificationManager getInstance() {
24: if (instance == null) {
25: String classname = Turbine
26: .getConfiguration()
27: .getString("scarab.notificationmanager.classname",
28: "org.tigris.scarab.notification.ScarabNotificationManager");
29: try {
30: instance = (NotificationManager) Class.forName(
31: classname).newInstance();
32: } catch (Exception e) {
33: log
34: .error("Could not instantiate notification manager '"
35: + classname
36: + "'. Defaulting to '"
37: + ScarabNotificationManager.class
38: .getName() + "': " + e);
39: instance = new ScarabNotificationManager();
40: }
41: }
42: return instance;
43: }
44: }
|