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


001:        /*
002:         * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.portal.fabric.tasks;
006:
007:        import com.sun.portal.admin.common.context.PSConfigContext;
008:        import com.sun.portal.fabric.util.NetworkUtil;
009:        import com.sun.portal.fabric.util.FileUtil;
010:        import com.sun.portal.fabric.util.ClasspathGenUtil;
011:        import com.sun.portal.monitoring.MonitoringConfiguration;
012:        import com.sun.portal.monitoring.MonitoringException;
013:        import com.sun.portal.log.common.PortalLogger;
014:
015:        import com.sun.portal.util.Platform;
016:
017:        import java.util.Properties;
018:        import java.util.logging.Level;
019:        import java.util.logging.Logger;
020:        import java.util.logging.LogRecord;
021:        import java.io.FileInputStream;
022:        import java.io.File;
023:        import java.io.IOException;
024:
025:        public class MonitoringConfigurationHelper {
026:            public static String fs = Platform.fs;
027:
028:            // private static String KEY_HTML_ADAPTOR_PORT = "com.sun.portal.monitoring.MonitoringContext.html.adaptor.port";
029:            private static String KEY_JMX_MP_PORT = "com.sun.portal.monitoring.security.ssl.SslContext.port";
030:            // private static String KEY_NEXT_AVAIL_HTML_ADAPTOR_PORT = "com.sun.portal.fabric.tasks.MonitoringConfigurationHelper.html.adaptor.next.available.port";
031:            private static String KEY_NEXT_AVAIL_JMX_MP_PORT = "com.sun.portal.fabric.tasks.MonitoringConfigurationHelper.ssl.SslContext.next.available.port";
032:            private static Logger logger = PortalLogger
033:                    .getLogger(MonitoringConfigurationHelper.class);
034:
035:            public static void configurePropertyFile(
036:                    String monitoringPropertiesFile, String host,
037:                    PSConfigContext context) {
038:                try {
039:                    // ports configuration
040:                    String monitoringPortConfigFile = context.getPSConfigDir()
041:                            + fs + "MonitoringPortConfig.properties";
042:                    Properties portConfigProperties = new Properties();
043:                    portConfigProperties.load(new FileInputStream(
044:                            monitoringPortConfigFile));
045:
046:                    Properties properties = new Properties();
047:                    properties.load(new FileInputStream(
048:                            monitoringPropertiesFile));
049:
050:                    /*
051:                    String nextAvailableHtmlAdaptorPort = portConfigProperties.getProperty(KEY_NEXT_AVAIL_HTML_ADAPTOR_PORT);
052:                    String htmlAdaptorPort = properties.getProperty(KEY_HTML_ADAPTOR_PORT);
053:                    nextAvailableHtmlAdaptorPort = NetworkUtil.getNextAvailablePort(host, nextAvailableHtmlAdaptorPort);
054:                    if(nextAvailableHtmlAdaptorPort != null && !nextAvailableHtmlAdaptorPort.equals(htmlAdaptorPort)){
055:                        FileUtil.replaceTokenInFile(new File(monitoringPropertiesFile), htmlAdaptorPort, nextAvailableHtmlAdaptorPort);
056:                        logger.log(Level.INFO, "Configured HTML Adaptor port in <" + monitoringPropertiesFile + "> as "+ nextAvailableHtmlAdaptorPort);
057:                    }
058:                     */
059:
060:                    String nextAvailableJmxMpPort = portConfigProperties
061:                            .getProperty(KEY_NEXT_AVAIL_JMX_MP_PORT);
062:                    String jmxMpPort = properties.getProperty(KEY_JMX_MP_PORT);
063:                    nextAvailableJmxMpPort = NetworkUtil.getNextAvailablePort(
064:                            host, nextAvailableJmxMpPort);
065:                    if (nextAvailableJmxMpPort != null
066:                            && !nextAvailableJmxMpPort.equals(jmxMpPort)) {
067:                        FileUtil.replaceTokenInFile(new File(
068:                                monitoringPropertiesFile), jmxMpPort,
069:                                nextAvailableJmxMpPort);
070:                        logger.log(Level.INFO, "PSFB_CSPFT0247", new Object[] {
071:                                monitoringPropertiesFile,
072:                                nextAvailableJmxMpPort });
073:                    }
074:
075:                    int nextPort = 0;
076:                    try {
077:                        /*
078:                        nextPort = Integer.parseInt(nextAvailableHtmlAdaptorPort) + 1;
079:                        FileUtil.replaceTokenInFile(new File(monitoringPortConfigFile), nextAvailableHtmlAdaptorPort, new Integer(nextPort).toString());
080:                        logger.log(Level.INFO, "Next available HTML Adaptor port is set as " + nextPort);
081:                         */
082:
083:                        nextPort = Integer.parseInt(nextAvailableJmxMpPort) + 1;
084:                        FileUtil.replaceTokenInFile(new File(
085:                                monitoringPortConfigFile),
086:                                nextAvailableJmxMpPort, new Integer(nextPort)
087:                                        .toString());
088:                        logger.log(Level.INFO, "PSFB_CSPFT0248", String
089:                                .valueOf(nextPort));
090:                    } catch (NumberFormatException nfe) {
091:                        if (logger.isLoggable(Level.SEVERE)) {
092:                            LogRecord rec = new LogRecord(Level.SEVERE,
093:                                    "PSFB_CSPFT0249");
094:                            rec.setLoggerName(logger.getName());
095:                            rec
096:                                    .setParameters(new Object[] { monitoringPortConfigFile });
097:                            rec.setThrown(nfe);
098:                            logger.log(rec);
099:                        }
100:                    }
101:
102:                    // monitoring classpath property - bea/ibm web container only
103:                    String contextCPKey = "com.sun.portal.monitoring.MonitoringContext.class.path";
104:                    String contextCP = properties.getProperty(contextCPKey);
105:                    if (contextCP != null && !contextCP.trim().equals("")) {
106:                        String tagSwappedContextCP = ClasspathGenUtil
107:                                .tagSwapClasspath(contextCP);
108:                        logger.log(Level.INFO, "PSFB_CSPFT0250", new Object[] {
109:                                contextCPKey, tagSwappedContextCP });
110:                        FileUtil.replaceLineInFile(new File(
111:                                monitoringPropertiesFile), contextCPKey + "=",
112:                                contextCPKey + "=" + tagSwappedContextCP);
113:                    }
114:
115:                    //delegatees - bea/ibm web container only
116:                    String delegateesKey = "com.sun.portal.monitoring.MonitoringContext.class.path.delegatees";
117:                    String delegatees = properties.getProperty(delegateesKey);
118:                    if (delegatees != null) {
119:                        //In case of serarator is different for the OS (Windows)
120:                        String tagSwappedDelegatees = ClasspathGenUtil
121:                                .tagSwapClasspath(delegatees);
122:                        logger.log(Level.INFO, "PSFB_CSPFT0250", new Object[] {
123:                                delegateesKey, tagSwappedDelegatees });
124:                        if (!delegatees.equals(tagSwappedDelegatees)) {
125:                            FileUtil.replaceLineInFile(new File(
126:                                    monitoringPropertiesFile), delegateesKey
127:                                    + "=", delegateesKey + "="
128:                                    + tagSwappedDelegatees);
129:                        }
130:                    }
131:
132:                    // non delegatees - bea/ibm web containers only
133:                    String nonDelegateesKey = "com.sun.portal.monitoring.MonitoringContext.class.path.non.delegatees";
134:                    String nonDelegatees = properties
135:                            .getProperty(nonDelegateesKey);
136:                    if (nonDelegatees != null) {
137:                        //In case of serarator is different for the OS (Windows)
138:                        String tagSwappedNonDelegatees = ClasspathGenUtil
139:                                .tagSwapClasspath(nonDelegatees);
140:                        logger.log(Level.INFO, "PSFB_CSPFT0250", new Object[] {
141:                                nonDelegateesKey, tagSwappedNonDelegatees });
142:                        if (!nonDelegatees.equals(tagSwappedNonDelegatees)) {
143:                            FileUtil.replaceLineInFile(new File(
144:                                    monitoringPropertiesFile), nonDelegateesKey
145:                                    + "=", nonDelegateesKey + "="
146:                                    + tagSwappedNonDelegatees);
147:                        }
148:                    }
149:                } catch (IOException ex) {
150:                    if (logger.isLoggable(Level.SEVERE)) {
151:                        LogRecord rec = new LogRecord(Level.SEVERE,
152:                                "PSFB_CSPFT0251");
153:                        rec.setLoggerName(logger.getName());
154:                        rec
155:                                .setParameters(new Object[] { monitoringPropertiesFile });
156:                        rec.setThrown(ex);
157:                        logger.log(rec);
158:                    }
159:                }
160:
161:                // Monitoring configuration
162:                try {
163:                    MonitoringConfiguration mconfig = new MonitoringConfiguration();
164:                    String[] params = { monitoringPropertiesFile, "setUp" };
165:                    logger.log(Level.INFO, "PSFB_CSPFT0252",
166:                            monitoringPropertiesFile);
167:                    mconfig.process(params);
168:                } catch (MonitoringException mex) {
169:                    if (logger.isLoggable(Level.SEVERE)) {
170:                        LogRecord rec = new LogRecord(Level.SEVERE,
171:                                "PSFB_CSPFT0253");
172:                        rec.setLoggerName(logger.getName());
173:                        rec
174:                                .setParameters(new Object[] { monitoringPropertiesFile });
175:                        rec.setThrown(mex);
176:                        logger.log(rec);
177:                    }
178:                }
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.