Source Code Cross Referenced for SubsystemHelper.java in  » Portal » Open-Portal » com » sun » portal » monitoring » 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.monitoring 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.portal.monitoring;
006:
007:        import com.sun.jdmk.comm.AuthInfo;
008:        import com.sun.jdmk.comm.HtmlAdaptorServer;
009:        import com.sun.portal.log.common.PortalLogger;
010:
011:        import javax.management.*;
012:        import javax.management.remote.JMXConnectorServer;
013:        import java.io.IOException;
014:        import java.lang.reflect.InvocationTargetException;
015:        import java.lang.reflect.Method;
016:        import java.util.ArrayList;
017:        import java.util.List;
018:        import java.util.Set;
019:        import java.util.logging.Logger;
020:        import java.util.logging.Level;
021:        import java.util.logging.LogRecord;
022:
023:        public class SubsystemHelper {
024:            private static final Logger logger = PortalLogger
025:                    .getLogger(SubsystemHelper.class);
026:
027:            private static LogRecord getLogRecord(Level level, String message,
028:                    Object[] parameters, Throwable t) {
029:                LogRecord result = new LogRecord(level, message);
030:                result.setLoggerName(logger.getName());
031:                result.setParameters(parameters);
032:                result.setThrown(t);
033:                return result;
034:            }
035:
036:            public static MBeanServer getJavaPlatformMBeanServer() {
037:                MBeanServer mBeanServer = null;
038:
039:                try {
040:                    Class managementFactory = Class
041:                            .forName("java.lang.management.ManagementFactory");
042:                    Method getPlatformMBeanServerMethod = managementFactory
043:                            .getMethod("getPlatformMBeanServer", null);
044:                    mBeanServer = (MBeanServer) getPlatformMBeanServerMethod
045:                            .invoke(managementFactory, null);
046:                } catch (ClassNotFoundException e) {
047:                    if (logger.isLoggable(Level.SEVERE)) {
048:                        logger.log(getLogRecord(Level.SEVERE, "PSMN_CSPM0001",
049:                                new Object[] { e.getLocalizedMessage() }, e));
050:                    }
051:                } catch (NoSuchMethodException e) {
052:                    if (logger.isLoggable(Level.SEVERE)) {
053:                        logger.log(getLogRecord(Level.SEVERE, "PSMN_CSPM0001",
054:                                new Object[] { e.getLocalizedMessage() }, e));
055:                    }
056:                } catch (IllegalAccessException e) {
057:                    if (logger.isLoggable(Level.SEVERE)) {
058:                        logger.log(getLogRecord(Level.SEVERE, "PSMN_CSPM0001",
059:                                new Object[] { e.getLocalizedMessage() }, e));
060:                    }
061:                } catch (InvocationTargetException e) {
062:                    if (logger.isLoggable(Level.SEVERE)) {
063:                        logger.log(getLogRecord(Level.SEVERE, "PSMN_CSPM0001",
064:                                new Object[] { e.getLocalizedMessage() }, e));
065:                    }
066:                }
067:
068:                return mBeanServer;
069:            }
070:
071:            public static ObjectName getMonitoringObjectName(String domain,
072:                    String typePropertyValue) throws MonitoringException {
073:                try {
074:                    return new ObjectName(domain, JMXHelper.TYPE,
075:                            typePropertyValue);
076:                } catch (MalformedObjectNameException mone) {
077:                    throw new MonitoringException(mone);
078:                }
079:            }
080:
081:            public static ObjectName getConnectorServerObjectName(
082:                    MonitoringContext monitoringContext)
083:                    throws MonitoringException {
084:                return getMonitoringObjectName(monitoringContext
085:                        .getNamingDomain(), monitoringContext
086:                        .getNamingTypeConnectorServer());
087:            }
088:
089:            public static ObjectName getHtmlAdaptorObjectName(
090:                    MonitoringContext monitoringContext)
091:                    throws MonitoringException {
092:                return getMonitoringObjectName(monitoringContext
093:                        .getNamingDomain(), monitoringContext
094:                        .getNamingTypeHtmlAdaptorServer());
095:            }
096:
097:            public static ObjectName getMonitoringSubsystemObjectName(
098:                    MonitoringContext monitoringContext)
099:                    throws MonitoringException {
100:                return getMonitoringObjectName(monitoringContext
101:                        .getNamingDomain(), monitoringContext
102:                        .getNamingTypeMonitoringConfiguration());
103:            }
104:
105:            public static void gearUpHtmlAdaptor(
106:                    MonitoringContext monitoringContext, MBeanServer mBeanServer)
107:                    throws MonitoringException {
108:                String htmlAdaptorPort = monitoringContext.getHtmlAdaptorPort();
109:                if (!htmlAdaptorPort
110:                        .equals(MonitoringContext.HTML_ADAPTOR_PORT)) {
111:                    AuthInfo[] aAuthInfo = new AuthInfo[] { new AuthInfo(
112:                            monitoringContext.getUserName(), monitoringContext
113:                                    .getUserPassword()) };
114:                    HtmlAdaptorServer htmlAdaptorServer = new HtmlAdaptorServer(
115:                            Integer.parseInt(htmlAdaptorPort), aAuthInfo);
116:
117:                    try {
118:                        mBeanServer.registerMBean(htmlAdaptorServer,
119:                                getHtmlAdaptorObjectName(monitoringContext));
120:                    } catch (InstanceAlreadyExistsException iaee) {
121:                        throw new MonitoringException(iaee);
122:                    } catch (MBeanRegistrationException mbre) {
123:                        throw new MonitoringException(mbre);
124:                    } catch (NotCompliantMBeanException ncmbe) {
125:                        throw new MonitoringException(ncmbe);
126:                    }
127:
128:                    htmlAdaptorServer.start();
129:                }
130:            }
131:
132:            public static void windDownHtmlAdaptor(
133:                    MonitoringContext monitoringContext, MBeanServer mBeanServer)
134:                    throws MonitoringException {
135:                ObjectName on = getHtmlAdaptorObjectName(monitoringContext);
136:
137:                Set onNames = mBeanServer.queryNames(on, null);
138:                if (onNames != null) {
139:                    if (!onNames.isEmpty()) {
140:                        try {
141:                            mBeanServer.invoke(on, "stop", null, null);
142:                        } catch (InstanceNotFoundException infe) {
143:                            throw new MonitoringException(infe);
144:                        } catch (MBeanException mbe) {
145:                            throw new MonitoringException(mbe);
146:                        } catch (ReflectionException re) {
147:                            throw new MonitoringException(re);
148:                        }
149:
150:                        try {
151:                            mBeanServer.unregisterMBean(on);
152:                        } catch (InstanceNotFoundException infe) {
153:                            throw new MonitoringException(infe);
154:                        } catch (MBeanRegistrationException mbre) {
155:                            throw new MonitoringException(mbre);
156:                        }
157:                    }
158:                }
159:            }
160:
161:            public static void gearUpConnectorServer(
162:                    MonitoringContext monitoringContext, MBeanServer mBeanServer)
163:                    throws MonitoringException {
164:                JMXConnectorServer jmxConnectorServer = ConnectorFactory
165:                        .getJMXConnectorServer(monitoringContext
166:                                .getConnectorContext(), monitoringContext
167:                                .getSaslContext(), monitoringContext
168:                                .getSslContext());
169:
170:                try {
171:                    mBeanServer.registerMBean(jmxConnectorServer,
172:                            getConnectorServerObjectName(monitoringContext));
173:                } catch (InstanceAlreadyExistsException iaee) {
174:                    throw new MonitoringException(iaee);
175:                } catch (MBeanRegistrationException mbre) {
176:                    throw new MonitoringException(mbre);
177:                } catch (NotCompliantMBeanException ncmbe) {
178:                    throw new MonitoringException(ncmbe);
179:                }
180:
181:                try {
182:                    jmxConnectorServer.start();
183:                } catch (IOException ioe) {
184:                    throw new MonitoringException(ioe);
185:                }
186:            }
187:
188:            public static void windDownConnectorServer(
189:                    MonitoringContext monitoringContext, MBeanServer mBeanServer)
190:                    throws MonitoringException {
191:                ObjectName on = getConnectorServerObjectName(monitoringContext);
192:
193:                Set onNames = mBeanServer.queryNames(on, null);
194:                if (onNames != null) {
195:                    if (!onNames.isEmpty()) {
196:                        try {
197:                            mBeanServer.invoke(on, "stop", null, null);
198:                        } catch (InstanceNotFoundException infe) {
199:                            throw new MonitoringException(infe);
200:                        } catch (MBeanException mbe) {
201:                            throw new MonitoringException(mbe);
202:                        } catch (ReflectionException re) {
203:                            throw new MonitoringException(re);
204:                        }
205:
206:                        try {
207:                            mBeanServer
208:                                    .unregisterMBean(getConnectorServerObjectName(monitoringContext));
209:                        } catch (InstanceNotFoundException infe) {
210:                            throw new MonitoringException(infe);
211:                        } catch (MBeanRegistrationException mbre) {
212:                            throw new MonitoringException(mbre);
213:                        }
214:                    }
215:                }
216:            }
217:
218:            public static void gearUpMonitoringSubsystem(
219:                    SubsystemImpl subsystemImpl,
220:                    MonitoringContext monitoringContext)
221:                    throws MonitoringException {
222:                MBeanSubsystem mBeanSubsystem = new MBeanSubsystem(
223:                        subsystemImpl, monitoringContext);
224:                ObjectName on = SubsystemHelper
225:                        .getMonitoringSubsystemObjectName(monitoringContext);
226:                subsystemImpl.registerMBean(mBeanSubsystem, on.toString());
227:            }
228:
229:            public static List getImmortalMBeanObjectNames(
230:                    MonitoringContext monitoringContext)
231:                    throws MonitoringException {
232:                List immortalMBeanObjectNames = new ArrayList();
233:                immortalMBeanObjectNames.add(SubsystemHelper
234:                        .getMonitoringSubsystemObjectName(monitoringContext));
235:                immortalMBeanObjectNames.add(SubsystemHelper
236:                        .getConnectorServerObjectName(monitoringContext));
237:                immortalMBeanObjectNames.add(SubsystemHelper
238:                        .getHtmlAdaptorObjectName(monitoringContext));
239:                return immortalMBeanObjectNames;
240:            }
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.