01: /**
02: * $Id: AttributeDisplayHandlerFactory.java,v 1.1 2005/02/20 22:20:25 pd109850 Exp $
03: * Copyright 2004 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.admin.cli.display;
14:
15: import java.util.Properties;
16: import java.io.IOException;
17:
18: public class AttributeDisplayHandlerFactory {
19:
20: public static final String HANDLER_FILE_NAME = "attrDisplayHandlers.properties";
21:
22: /**
23: * @returns null if no handler is found or if the properties file does not
24: * exits or there is problem loading it.
25: */
26: public static AttributeDisplayHandler getAttrDisplayHandler(
27: String componentName) {
28: Properties props = new Properties();
29: try {
30: props
31: .load(Class
32: .forName(
33: "com.sun.portal.fabric.common.AttributeDisplayHandlerFactory")
34: .getClassLoader().getResourceAsStream(
35: HANDLER_FILE_NAME));
36: } catch (ClassNotFoundException cnfe) {
37: //TODO:log
38: //impossible exception
39: //ignore
40: } catch (IOException ioe) {
41: //TODO:log
42: //problem loading the properties file
43: //ignore
44: }
45:
46: String className = props.getProperty(componentName);
47: AttributeDisplayHandler dispHandler = null;
48: if (className != null) {
49: try {
50: dispHandler = (AttributeDisplayHandler) (Class
51: .forName(className).newInstance());
52: } catch (ClassNotFoundException cnfe) {
53: //TODO:log
54: dispHandler = null;
55: } catch (NoClassDefFoundError ncdfe) {
56: //TODO:log
57: dispHandler = null;
58: } catch (IllegalAccessException iae) {
59: //TODO:log
60: dispHandler = null;
61: } catch (ClassCastException cce) {
62: //TODO:log
63: dispHandler = null;
64: } catch (InstantiationException ie) {
65: //TODO:log
66: dispHandler = null;
67: } catch (SecurityException se) {
68: //TODO:log
69: dispHandler = null;
70: }
71: }
72: return dispHandler;
73: }
74: }
|