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.desktop.context;
06:
07: import javax.servlet.ServletContext;
08:
09: public class PSDesktopContextFactoryManager implements
10: PSContextConstants {
11: private static DesktopContextFactory dcf = null;
12:
13: public static synchronized DesktopContextFactory getFactory(
14: ServletContext sc) {
15: if (dcf == null) {
16: String dcfClassName = sc
17: .getInitParameter(SC_CONTEXT_FACTORY_CLASSNAME);
18: if (dcfClassName == null) {
19: throw new ContextError(
20: "DesktopContextFactoryManager.getFactory(): dcf class name was null from servlet context");
21: }
22:
23: try {
24: dcf = (DesktopContextFactory) (Class
25: .forName(dcfClassName).newInstance());
26: dcf.init(sc);
27: } catch (ClassNotFoundException cnfe) {
28: throw new ContextError(
29: "DesktopContextFactoryManager.getFactory(): ",
30: cnfe);
31: } catch (NoClassDefFoundError ncdfe) {
32: throw new ContextError(
33: "DesktopContextFactoryManager.getFactory(): ",
34: ncdfe);
35: } catch (IllegalAccessException iae) {
36: throw new ContextError(
37: "DesktopContextFactoryManager.getFactory(): ",
38: iae);
39: } catch (ClassCastException cce) {
40: throw new ContextError(
41: "DesktopContextFactoryManager.getFactory(): ",
42: cce);
43: } catch (InstantiationException ie) {
44: throw new ContextError(
45: "DesktopContextFactoryManager.getFactory(): ",
46: ie);
47: } catch (SecurityException se) {
48: throw new ContextError(
49: "DesktopContextFactoryManager.getFactory(): ",
50: se);
51: }
52: }
53:
54: return dcf;
55: }
56:
57: }
|