Source Code Cross Referenced for LoggingService.java in  » ESB » open-esb » com » sun » jbi » management » system » 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 » ESB » open esb » com.sun.jbi.management.system 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)LoggingService.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.management.system;
030:
031:        import javax.management.ObjectName;
032:        import com.sun.jbi.management.MBeanNames;
033:        import com.sun.jbi.management.support.JbiNameInfo;
034:        import com.sun.jbi.management.LocalStringKeys;
035:        import com.sun.jbi.StringTranslator;
036:        import java.util.ArrayList;
037:        import java.util.Iterator;
038:        import java.util.Set;
039:        import java.util.logging.Logger;
040:
041:        /**
042:         * This is the JBI Framework Logging Service, which manages the loggers
043:         * for all components and system services.
044:         *
045:         * @author Sun Microsystems, Inc.
046:         */
047:        public class LoggingService extends ModelSystemService implements 
048:                LoggingServiceMBean {
049:            /** our immutable name: */
050:            private final JbiNameInfo mJbiNameInfo = new JbiNameInfo(
051:                    "LoggingService");
052:
053:            /**
054:             * Management context
055:             */
056:            private ManagementContext mContext = null;
057:
058:            /**
059:             * Management Message Object
060:             */
061:            private BuildManagementMessageImpl mMMImpl = null;
062:
063:            /**
064:             * Constructs a LoggingService.
065:             * @param anEnv is the ManagementContext.
066:             */
067:            public LoggingService(ManagementContext anEnv) {
068:                mContext = anEnv;
069:
070:                /*
071:                 * Local initialization of this service.
072:                 * Local routine is responsible for calling super.initModelSystemService(..).
073:                 */
074:                initModelSystemService(anEnv.getEnvironmentContext());
075:
076:                mMMImpl = mContext.getManagementMessageObject();
077:            }
078:
079:            /** local model init - called by constructor - create custom mbeans. */
080:            protected void initModelSystemService(
081:                    com.sun.jbi.EnvironmentContext anEnv) {
082:                String loggerName = com.sun.jbi.management.config.LoggerConfigurationFactory.LOGGING_LOGGER;
083:
084:                Logger logger = Logger.getLogger(loggerName);
085:
086:                //initialize the super.
087:                super .initModelSystemService(anEnv, logger, mJbiNameInfo);
088:
089:                //add AdminService MBean to START/STOP mbean set:
090:                mStartMBeans
091:                        .add(
092:                                mLoggingServiceMBeanName,
093:                                com.sun.jbi.management.system.LoggingServiceMBean.class,
094:                                this );
095:            }
096:
097:            /**
098:             * Lookup a system LoggerMBean by system service name.
099:             * @param aSvcName is the name of the system service
100:             * @return the JMX object name of the service LoggerMBean or null
101:             */
102:            public ObjectName getSystemLoggerMBean(String aSvcName) {
103:                MBeanNames mbn = mContext.getMBeanNames();
104:                String tmp = mbn.getJmxDomainName();
105:
106:                tmp += ":" + mbn.SERVICE_NAME_KEY + "=" + aSvcName;
107:                tmp += "," + mbn.CONTROL_TYPE_KEY + "="
108:                        + mbn.CONTROL_TYPE_LOGGER;
109:                tmp += "," + mbn.COMPONENT_TYPE_KEY + "="
110:                        + mbn.COMPONENT_TYPE_SYSTEM;
111:                //wildcard goes at the end:
112:                tmp += ",*";
113:
114:                //exec the query:
115:                ObjectName[] names = queryHelper(tmp);
116:
117:                if (names.length >= 1) {
118:                    if (names.length > 1) {
119:                        String statusMsg = mTranslator
120:                                .getString(
121:                                        LocalStringKeys.LS_GETSYSTEMLOGGERMBEAN_TOO_MANY_MBEANS,
122:                                        tmp);
123:                        mLogger.severe(statusMsg);
124:                    }
125:
126:                    //always return the first mbean name, even if many:
127:                    return names[0];
128:                } else {
129:                    String statusMsg = mTranslator
130:                            .getString(
131:                                    LocalStringKeys.LS_GETSYSTEMLOGGERMBEAN_LOOKUP_FAILED,
132:                                    tmp);
133:                    mLogger.warning(statusMsg);
134:                }
135:
136:                return null;
137:            }
138:
139:            /**
140:             * Looks up LoggerMBeans for all JBI Framework
141:             * System Services currently installed.
142:             * @return array of object names for all system service LoggerMBeans.
143:             * @return zero-length array if no services registered.
144:             */
145:            public ObjectName[] getSystemLoggerMBeans() {
146:                MBeanNames mbn = mContext.getMBeanNames();
147:                String tmp = mbn.getJmxDomainName();
148:
149:                tmp += ":" + mbn.COMPONENT_TYPE_KEY + "="
150:                        + mbn.COMPONENT_TYPE_SYSTEM;
151:                tmp += "," + mbn.CONTROL_TYPE_KEY + "="
152:                        + mbn.CONTROL_TYPE_LOGGER;
153:                //wildcard goes at the end:
154:                tmp += ",*";
155:
156:                //exec the query:
157:                ObjectName[] names = queryHelper(tmp);
158:
159:                //if no logger mbeans found for any system service...
160:                if (names.length <= 1) {
161:                    String statusMsg = mTranslator
162:                            .getString(LocalStringKeys.LS_GETSYSTEMLOGGERMBEANS_NO_SERVICES);
163:                    mLogger.severe(statusMsg);
164:                    return (new ObjectName[0]);
165:                }
166:
167:                return names;
168:            }
169:
170:            /**
171:             * lookup a JBI Installable Component by its unique ID.
172:             * @param aComponentId is the unique ID of the BC or SE.
173:             * @return the JMX object name of the LifeCycle MBean for the component
174:             */
175:            public ObjectName getComponentLoggerMBeanById(String aComponentId) {
176:                /*
177:                 * EXAMPLE:
178:                com.sun.jbi:ComponentId=ABC,ControlType=Lifecycle,ComponentType=Installed,*
179:                 */
180:
181:                MBeanNames mbn = mContext.getMBeanNames();
182:                String tmp = mbn.getJmxDomainName();
183:
184:                tmp += ":" + mbn.COMPONENT_ID_KEY + "=" + aComponentId;
185:                tmp += "," + mbn.COMPONENT_TYPE_KEY + "="
186:                        + mbn.COMPONENT_TYPE_INSTALLED;
187:                tmp += "," + mbn.CONTROL_TYPE_KEY + "="
188:                        + mbn.CONTROL_TYPE_LOGGER;
189:                //wildcard goes at the end:
190:                tmp += ",*";
191:
192:                //exec the query:
193:                ObjectName[] names = queryHelper(tmp);
194:
195:                /*
196:                 mLogger.info(
197:                 "LoggingService.getComponentLoggerMBeanById: T1 names.length=" + names.length );
198:                 mLogger.info("LoggingService.getComponentLoggerMBeanById: T1 tmp=" + tmp);
199:                 */
200:
201:                if (names.length >= 1) {
202:                    if (names.length > 1) {
203:                        String statusMsg = mTranslator
204:                                .getString(
205:                                        LocalStringKeys.LS_GETCOMPONENTLOGGERMBEANBYID_TOO_MANY_MBEANS,
206:                                        tmp);
207:                        mLogger.severe(statusMsg);
208:                    }
209:
210:                    //always return the first mbean name, even if many:
211:                    return names[0];
212:                } else {
213:                    String statusMsg = mTranslator
214:                            .getString(
215:                                    LocalStringKeys.LS_GETCOMPONENTLOGGERMBEANBYID_LOOKUP_FAILED,
216:                                    tmp);
217:                    mLogger.warning(statusMsg);
218:                }
219:
220:                return null;
221:            }
222:
223:            /////////
224:            //methods private to LoggingService
225:            /////////
226:
227:            /**
228:             * Stub that calls AdminService queryHelper.
229:             * @param qStr is a JMX formatted query string
230:             * @return array of JMX object names, possibly of zero length.
231:             */
232:            private ObjectName[] queryHelper(String qStr) {
233:                return mContext.getAdminServiceHandle().queryHelper(qStr);
234:            }
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.