01: /**
02: * $Id: FabricBaseBean.java,v 1.4 2005/09/21 15:29:42 fo160993 Exp $
03: * Copyright 2005 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.console.fabric;
14:
15: import java.io.IOException;
16: import java.util.logging.Level;
17: import java.util.Set;
18: import java.util.Map;
19: import java.util.Collections;
20:
21: import javax.management.MBeanServerConnection;
22: import javax.management.ObjectName;
23:
24: import com.sun.portal.admin.common.util.AdminUtil;
25: import com.sun.portal.admin.common.util.AdminClientUtil;
26: import com.sun.portal.admin.console.common.PortalBaseBean;
27:
28: public class FabricBaseBean extends PortalBaseBean {
29:
30: protected String getPortalAttribute(String portalId, String name) {
31: String value = null;
32: try {
33: ObjectName objectName = AdminUtil.getPortalMBeanObjectName(
34: AdminUtil.DEFAULT_DOMAIN, portalId);
35:
36: // Setting the params and signature
37: Object[] params = { AdminUtil.PORTAL_MBEAN_TYPE, name };
38: String[] signature = { "java.lang.String",
39: "java.lang.String" };
40:
41: value = (String) getMBeanServerConnection().invoke(
42: objectName, "getAttributeValue", params, signature);
43: } catch (Exception e) {
44: log(
45: Level.SEVERE,
46: "FabricBaseBean.getPortalAttribute(): Failed to get attribute value for portal "
47: + portalId + " and attribute " + name, e);
48: value = "";
49: }
50: return value;
51: }
52:
53: protected Map getInstanceAttributes(String portalId,
54: String instanceId, Set names) {
55: Map values = null;
56: try {
57: ObjectName objectName = AdminUtil
58: .getInstanceMBeanObjectName(
59: AdminUtil.DEFAULT_DOMAIN, portalId,
60: instanceId);
61:
62: // Setting the params and signature
63: Object[] params = {
64: AdminUtil.PORTAL_SERVER_INSTANCE_MBEAN_TYPE, names };
65: String[] signature = { "java.lang.String", "java.util.Set" };
66:
67: values = (Map) getMBeanServerConnection().invoke(
68: objectName, "getMultipleAttributeValues", params,
69: signature);
70: } catch (Exception e) {
71: log(
72: Level.SEVERE,
73: "FabricBaseBean.getInstanceAttributes(): Failed to get attribute value for portal "
74: + portalId + " and attributes " + names, e);
75: values = Collections.EMPTY_MAP;
76: }
77: return values;
78: }
79:
80: /**
81: * Gets a localized string from the resoucebundle
82: * @param key A key string
83: * @return A localized String for the key
84: */
85: protected String getFabricI18N(String key) {
86: return getLocalizedString("fabric", key);
87: }
88:
89: }
|