Source Code Cross Referenced for SRAMonitoring.java in  » Portal » Open-Portal » com » sun » portal » sra » admin » mbeans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.sra.admin.mbeans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.sra.admin.mbeans;
002:
003:        import java.io.File;
004:        import java.io.IOException;
005:        import java.io.FileInputStream;
006:        import java.lang.reflect.InvocationTargetException;
007:        import java.lang.reflect.Method;
008:        import java.util.HashMap;
009:        import java.util.List;
010:        import java.util.Map;
011:        import java.util.Properties;
012:
013:        import javax.management.InstanceNotFoundException;
014:        import javax.management.MBeanException;
015:        import javax.management.MalformedObjectNameException;
016:        import javax.management.ObjectName;
017:        import javax.management.ReflectionException;
018:
019:        import com.sun.portal.admin.common.context.PSConfigContext;
020:        import com.sun.portal.admin.common.context.PortalDomainContext;
021:        import com.sun.portal.admin.common.util.AdminUtil;
022:        import com.sun.portal.admin.server.mbeans.PSResource;
023:        import com.sun.portal.monitoring.*;
024:        import com.sun.portal.monitoring.security.ssl.SslContext;
025:        import com.sun.portal.monitoring.utilities.PropertyHelper;
026:        import com.sun.portal.monitoring.utilities.UtilityException;
027:
028:        import com.sun.portal.util.Platform;
029:
030:        /**
031:         * author: Noble Paul Date: Mar 17, 2005, 2:02:53 PM
032:         */
033:        public class SRAMonitoring extends PSResource implements 
034:                SRAMonitoringMBean {
035:            protected Subsystem subsystem;
036:
037:            protected Client client;
038:
039:            protected String host;
040:
041:            protected ObjectName objectNameProxy;
042:
043:            private Map subsystemCache = new HashMap();
044:
045:            private Map propertiesCache = new HashMap();
046:
047:            public void init(PSConfigContext cc, PortalDomainContext pdc,
048:                    List path) {
049:                super .init(cc, pdc, path);
050:                try {
051:                    objectNameProxy = AdminUtil.getResourceMBeanObjectName(
052:                            "PortalDomain.SRAMonitoring", path);
053:                } catch (MalformedObjectNameException mone) {
054:                    Debug.severe("PSMN_CSPM0001", new Object[] { Debug
055:                            .getStackTrace(mone) }, null);
056:                }
057:            }
058:
059:            private Subsystem getSubSystem(String profile, String proxyType)
060:                    throws MonitoringException {
061:                Subsystem subsystem = (Subsystem) subsystemCache.get(profile
062:                        + "." + proxyType);
063:                if (subsystem != null) {
064:                    return subsystem;
065:                }
066:
067:                String configurationDirectory = cc.getPSConfigDir()
068:                        + Platform.fs + profile + Platform.fs + proxyType;
069:                PropertyHelper ph = new PropertyHelper(new Properties());
070:                try {
071:                    ph.loadProperties(configurationDirectory + Platform.fs
072:                            + "monitoring.properties");
073:                } catch (UtilityException e) {
074:                    throw new MonitoringException(e);
075:                }
076:                ph.setProperty(ConnectorContext.class.getName(),
077:                        ConnectorContext.PROPERTY_SUFFIX_SSL_DISABLE, "true");
078:                ph.setProperty(ConnectorContext.class.getName(),
079:                        ConnectorContext.PROPERTY_SUFFIX_SASL_DISABLE, "true");
080:                ph
081:                        .setProperty(
082:                                MonitoringContext.class.getName(),
083:                                MonitoringContext.PROPERTY_SUFFIX_CONFIGURATION_DIRECTORY,
084:                                configurationDirectory);
085:                ph.setProperty(MonitoringContext.class.getName(),
086:                        MonitoringContext.PROPERTY_SUFFIX_SUBSYSTEM_MODE,
087:                        "Client");
088:                ph.setProperty(SslContext.class.getName(),
089:                        SslContext.PROPERTY_SUFFIX_TRUST_ALL_CERTIFICATES,
090:                        "true");
091:
092:                subsystem = new SubsystemImpl(ph.getProperties());
093:                subsystem.start();
094:
095:                subsystemCache.put(profile + "." + proxyType, subsystem);
096:                return subsystem;
097:
098:            }
099:
100:            public Object invoke(ObjectName on, String operationName,
101:                    Object[] params, String[] signature)
102:                    throws ReflectionException, InstanceNotFoundException,
103:                    IOException, MBeanException {
104:                if (on == null && operationName == null) {
105:                    return invokeMethod(params);
106:                } else {
107:                    return client.invoke(on, operationName, params, signature);
108:                }
109:            }
110:
111:            private Object invokeMethod(Object[] params)
112:                    throws ReflectionException, MBeanException {
113:                String methodName = (String) params[0];
114:                String proxyType = (String) params[1];
115:                String instanceName = (String) params[2];
116:                Method method = null;
117:                try {
118:                    method = getMethod(methodName, Client.class);
119:                } catch (NoSuchMethodException e) {
120:                    throw new ReflectionException(e);
121:                }
122:                Object[] newParams = new Object[0];
123:                if (params.length > 3) {
124:                    newParams = new Object[params.length - 3];
125:                    System.arraycopy(params, 3, newParams, 0, newParams.length);
126:                }
127:                Client c = null;
128:                try {
129:                    c = getSubSystem(instanceName, proxyType).getClient();
130:                } catch (Exception e) {
131:                    e.printStackTrace();// TODO handle Exception properly
132:                    throw new MBeanException(e);
133:                }
134:                try {
135:                    return method.invoke(c, newParams);
136:                } catch (IllegalAccessException e) {
137:                    throw new ReflectionException(e);
138:                } catch (InvocationTargetException e) {
139:                    throw new ReflectionException(e);
140:                }
141:            }
142:
143:            private Method getMethod(String methodName, Class clzz)
144:                    throws NoSuchMethodException {
145:                Method[] methods = clzz.getMethods();
146:                for (int i = 0; i < methods.length; i++) {
147:                    if (methodName.equals(methods[i].getName())) {
148:                        return methods[i];
149:                    }
150:                }
151:                throw new NoSuchMethodException(methodName);
152:            }
153:
154:            public String getMonitoringProperty(String proxyType,
155:                    String instance, String propName) {
156:                String result = (String) propertiesCache.get(proxyType + ":"
157:                        + instance + ":" + propName);
158:                if (result != null) {
159:                    return result;
160:                }
161:                String monProperties = cc.getPSConfigDir() + Platform.fs
162:                        + instance + Platform.fs + proxyType + Platform.fs
163:                        + "monitoring.properties";
164:                Properties properties = new Properties();
165:                try {
166:                    properties.load(new FileInputStream(monProperties));
167:                } catch (IOException e) {
168:                    return "";
169:                }
170:
171:                if ("true"
172:                        .equals(properties
173:                                .getProperty("com.sun.portal.monitoring.MonitoringContext.monitoring.disable"))) {
174:                    return "";
175:                }
176:                result = properties.getProperty(propName);
177:                if (result != null) {
178:                    propertiesCache.put(proxyType + ":" + instance + ":"
179:                            + propName, result);
180:                    return result;
181:                } else {
182:                    return "";
183:                }
184:            }
185:
186:            public void disconnect(String proxyType, String instance)
187:                    throws IOException {
188:                // try {
189:                // Subsystem subsystem = getSubSystem(instance,proxyType);
190:                // if(subsystem != null){
191:                // try {
192:                // subsystem.getClient().disconnect();
193:                // } catch (Exception e) {}
194:                // }
195:                // } catch (MonitoringException e) {
196:                // e.printStackTrace();//TODO handle Exception properly
197:                // }
198:
199:            }
200:
201:            public void connect(String proxyType, String instance)
202:                    throws IOException {
203:                try {
204:                    Subsystem subsystem = getSubSystem(instance, proxyType);
205:                    try {
206:                        subsystem.getClient();
207:                    } catch (MonitoringException me) {
208:                        client = null;
209:                        Debug.severe("PSMN_CSPM0001", new Object[] { Debug
210:                                .getStackTrace(me) }, null);
211:                        throw new IOException(Debug.getStackTrace(me));
212:                    }
213:                } catch (MonitoringException me) {
214:                    Debug.severe("PSMN_CSPM0001", new Object[] { Debug
215:                            .getStackTrace(me) }, null);
216:                    throw new IOException(Debug.getStackTrace(me));
217:                }
218:            }
219:
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.