01: /**
02: * $Id: AttributeHandlerFactory.java,v 1.3 2005/07/11 20:22:17 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.fabric.common;
14:
15: import com.sun.portal.admin.common.context.PSConfigContext;
16: import com.sun.portal.admin.common.PSMBeanException;
17:
18: public class AttributeHandlerFactory {
19:
20: public static final String DEFAULT_HANDLER_NAME = "default";
21:
22: /**
23: * Creates and returns an attribute habdler. If specific component
24: * handler is not found, then returns the default handler which
25: * is the generic handler. If even the default handler could not
26: * be instantiated or initialized, then thorws PSMBeanException
27: * This method either always returns a handler or throws an exception
28: * but never returns null
29: */
30: public static AttributeHandler getComponentAttrHandler(
31: String componentName, PSConfigContext cc, String domainId,
32: String portalId) throws PSMBeanException {
33: String className = cc.getAttributeHandlerName(componentName);
34:
35: //fix 6247916: This feature was only for development, so commented
36: //out the lines below
37: /*
38: if(className == null) {
39: className = cc.getAttributeHandlerName(DEFAULT_HANDLER_NAME);
40: }
41: */
42:
43: if (className == null) {
44: throw new PSMBeanException(
45: "error.psadmin.handler.not.found");
46: }
47:
48: AttributeHandler attrHandler = null;
49: try {
50: attrHandler = (AttributeHandler) (Class.forName(className)
51: .newInstance());
52: } catch (Exception e) {
53: throw new PSMBeanException(
54: "error.psadmin.handler.creation.failed", e
55: .getMessage(), e);
56: }
57:
58: if (attrHandler != null) {
59: attrHandler.init(componentName, domainId, portalId);
60: } else {
61: throw new PSMBeanException(
62: "error.psadmin.handler.creation.failed",
63: "Handler is null");
64: }
65: return attrHandler;
66: }
67: }
|