01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.taskadmin.context;
06:
07: import java.io.IOException;
08: import java.io.FileNotFoundException;
09:
10: import java.util.Properties;
11:
12: import javax.servlet.ServletContext;
13:
14: import com.sun.portal.util.ResourceLoader;
15: import com.sun.portal.desktop.context.ContextError;
16: import com.sun.portal.taskadmin.TaskAdminConstants;
17:
18: public class UserTaskAdminContextFactoryManager implements
19: TaskAdminConstants {
20: private static UserTaskAdminContextFactory tcf = null;
21:
22: public static synchronized UserTaskAdminContextFactory getFactory() {
23: if (tcf == null) {
24: String tcfClassName = null;
25: try {
26: Properties contextProps = ResourceLoader.getInstance(
27: System.getProperties()).getProperties(
28: CONTEXT_CONFIG_FILE_NAME);
29: tcfClassName = contextProps
30: .getProperty(USER_TASKADMIN_CONTEXT_FACTORY_CLASS_NAME);
31: } catch (FileNotFoundException fnfe) {
32: throw new ContextError(
33: "UserTaskAdminContextFactoryManager.getFactory(): ",
34: fnfe);
35: } catch (IOException ioe) {
36: throw new ContextError(
37: "UserTaskAdminContextFactoryManager.getFactory(): ",
38: ioe);
39: }
40:
41: if (tcfClassName == null) {
42: throw new ContextError(
43: "UserTaskAdminContextFactoryManager.getFactory(): tcf class name was null from config file");
44: }
45:
46: try {
47: tcf = (UserTaskAdminContextFactory) (Class
48: .forName(tcfClassName).newInstance());
49: tcf.init();
50: } catch (ClassNotFoundException cnfe) {
51: throw new ContextError(
52: "TaskAdminContextFactoryManager.getFactory(): ",
53: cnfe);
54: } catch (NoClassDefFoundError ncdfe) {
55: throw new ContextError(
56: "TaskAdminContextFactoryManager.getFactory(): ",
57: ncdfe);
58: } catch (IllegalAccessException iae) {
59: throw new ContextError(
60: "TaskAdminContextFactoryManager.getFactory(): ",
61: iae);
62: } catch (ClassCastException cce) {
63: throw new ContextError(
64: "TaskAdminContextFactoryManager.getFactory(): ",
65: cce);
66: } catch (InstantiationException ie) {
67: throw new ContextError(
68: "TaskAdminContextFactoryManager.getFactory(): ",
69: ie);
70: } catch (SecurityException se) {
71: throw new ContextError(
72: "TaskAdminContextFactoryManager.getFactory(): ",
73: se);
74: }
75: }
76:
77: return tcf;
78: }
79:
80: }
|