001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.desktop.mfwk;
006:
007: import com.sun.mfwk.instrum.server.MfManagedElementServer;
008: import com.sun.mfwk.instrum.server.MfManagedElementServerProperties;
009: import java.util.Hashtable;
010: import java.util.Properties;
011:
012: public class MfwkContext {
013: private Properties properties = new Properties();
014:
015: private static final String CONTEXT_PROPERTY_PREFIX = "com.sun.portal.";
016: private static final String CONFIG_PROPERTY_PREFIX = "com.sun.portal.desktop.";
017:
018: public MfwkContext(Properties properties) {
019: if (properties != null) {
020: this .properties = properties;
021: }
022: }
023:
024: public String getContextProperty(String keySuffix,
025: String defaultValue) {
026: return properties.getProperty(CONTEXT_PROPERTY_PREFIX
027: + keySuffix, defaultValue);
028: }
029:
030: public String getContextProperty(String keySuffix) {
031: return getContextProperty(keySuffix, null);
032: }
033:
034: public String getConfigProperty(String keySuffix,
035: String defaultValue) {
036: return properties.getProperty(CONFIG_PROPERTY_PREFIX
037: + keySuffix, defaultValue);
038: }
039:
040: public String getConfigProperty(String keySuffix) {
041: return getConfigProperty(keySuffix, null);
042: }
043:
044: private void putConfigProperty(Properties configProperties,
045: String keySuffix) {
046: String value = getConfigProperty(keySuffix);
047: if ((value != null) && (value.length() > 0)) {
048: configProperties.setProperty(keySuffix, value);
049: }
050: }
051:
052: public Properties getMeServerConfigProperties() {
053: Properties result = new Properties();
054:
055: String htmlAdaptorPort = getConfigProperty("html.adaptor.port",
056: "0");
057: if (!htmlAdaptorPort.equals("0")) {
058: result.put("ENABLE_HTML_ADAPTOR", "true");
059: result.put("HTML_ADAPTOR_PORT", htmlAdaptorPort);
060: }
061:
062: putConfigProperty(
063: result,
064: MfManagedElementServerProperties.ENABLE_ME_BY_DEFAULT_KEY);
065: putConfigProperty(
066: result,
067: MfManagedElementServerProperties.PRIVATE_CONNECTOR_SERVER_KEYSTORE_PASSWORD_KEY);
068: putConfigProperty(
069: result,
070: MfManagedElementServerProperties.PRIVATE_CONNECTOR_SERVER_KEYSTORE_PATH_KEY);
071: putConfigProperty(
072: result,
073: MfManagedElementServerProperties.PRIVATE_CONNECTOR_SERVER_SECURITY_MODE_KEY);
074: putConfigProperty(
075: result,
076: MfManagedElementServerProperties.PRIVATE_CONNECTOR_SERVER_TRUSTSTORE_PASSWORD_KEY);
077: putConfigProperty(
078: result,
079: MfManagedElementServerProperties.PRIVATE_CONNECTOR_SERVER_TRUSTSTORE_PATH_KEY);
080: putConfigProperty(
081: result,
082: MfManagedElementServerProperties.PRIVATE_CONNECTOR_SERVER_URL_KEY);
083: putConfigProperty(
084: result,
085: MfManagedElementServerProperties.SECURED_PRIVATE_CONNECTOR_SERVER_KEY);
086: putConfigProperty(
087: result,
088: MfManagedElementServerProperties.SECURED_PRIVATE_DISCOVERY_KEY);
089:
090: return result;
091: }
092:
093: private void putContextProperty(Hashtable context, String keySuffix) {
094: String value = getContextProperty(keySuffix);
095: if ((value != null) && (value.length() > 0)) {
096: context.put(keySuffix, value);
097: }
098: }
099:
100: private static final String DOT = ".";
101:
102: public Hashtable getMeServerContext() {
103: Hashtable result = new Hashtable();
104:
105: putContextProperty(result,
106: MfManagedElementServer.ENABLE_REMOTE_MONITORING_CTX_KEY);
107: putContextProperty(result,
108: MfManagedElementServer.PRODUCT_CODE_NAME_CTX_KEY);
109: putContextProperty(result,
110: MfManagedElementServer.PRODUCT_COLLECTIONID_CTX_KEY);
111: putContextProperty(result,
112: MfManagedElementServer.PRODUCT_NAME_CTX_KEY);
113:
114: // putContextProperty(result, MfManagedElementServer.PRODUCT_PREFIX_CTX_KEY);
115: result
116: .put(
117: MfManagedElementServer.PRODUCT_PREFIX_CTX_KEY,
118: getConfigProperty(MfwkContext.SUFFIX_APPLICATION_SYSTEM_NAME)
119: + DOT
120: + getPortalID()
121: + DOT
122: + getInstanceID());
123:
124: return result;
125: }
126:
127: public String getPortalID() {
128: return getContextProperty("portalID");
129: }
130:
131: public String getInstanceID() {
132: return getContextProperty("instanceID");
133: }
134:
135: public static final String SUFFIX_APPLICATION_SYSTEM_NAME = "ApplicationSystem.name";
136: public static final String SUFFIX_APPLICATION_SYSTEM_SETTING_NAME = "ApplicationSystemSetting.name";
137: public static final String SUFFIX_APPLICATION_SYSTEM_STATS_NAME = "ApplicationSystemStats.name";
138: public static final String SUFFIX_DESKTOP_LOGICAL_COMPONENT_NAME = "DesktopLogicalComponent.name";
139: public static final String SUFFIX_DESKTOP_SERVICE_ACCESS_URI_NAME = "DesktopServiceAccessURI.name";
140: public static final String SUFFIX_DESKTOP_SERVICE_ACCESS_URI_SETTING_NAME = "DesktopServiceAccessURISetting.name";
141: public static final String SUFFIX_DESKTOP_SERVICE_ACCESS_URI_STATS_NAME = "DesktopServiceAccessURIStats.name";
142: public static final String SUFFIX_DESKTOP_SERVICE_NAME = "DesktopService.name";
143: public static final String SUFFIX_DESKTOP_SERVICE_SETTING_NAME = "DesktopServiceSetting.name";
144: public static final String SUFFIX_DESKTOP_SERVICE_STATS_NAME = "DesktopServiceStats.name";
145: public static final String SUFFIX_PROVIDER_LOGICAL_COMPONENT_NAME = "ProviderLogicalComponent.name";
146: public static final String SUFFIX_PROVIDER_SERVICE_NAME = "ProviderService.name";
147: public static final String SUFFIX_PROVIDER_SERVICE_SETTING_NAME = "ProviderServiceSetting.name";
148: public static final String SUFFIX_PROVIDER_SERVICE_STATS_NAME = "ProviderServiceStats.name";
149: public static final String SUFFIX_THREAD_POOL_CALLER_NAME = "ThreadPoolCaller.name";
150: public static final String SUFFIX_THREAD_POOL_CALLER_SETTING_NAME = "ThreadPoolCallerSetting.name";
151: public static final String SUFFIX_THREAD_POOL_CALLER_STATS_NAME = "ThreadPoolCallerStats.name";
152: public static final String SUFFIX_THREAD_POOL_GETTER_NAME = "ThreadPoolGetter.name";
153: public static final String SUFFIX_THREAD_POOL_GETTER_SETTING_NAME = "ThreadPoolGetterSetting.name";
154: public static final String SUFFIX_THREAD_POOL_GETTER_STATS_NAME = "ThreadPoolGetterStats.name";
155: }
|