Source Code Cross Referenced for ManagementService.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:         * @(#)ManagementService.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 java.util.Properties;
032:        import java.util.Enumeration;
033:        import javax.management.MBeanServer;
034:        import javax.management.Attribute;
035:        import javax.management.ObjectName;
036:        import javax.management.ObjectInstance;
037:        import com.sun.jbi.EnvironmentContext;
038:        import com.sun.jbi.StringTranslator;
039:        import com.sun.jbi.management.LocalStringKeys;
040:        import com.sun.jbi.management.MBeanNames;
041:        import com.sun.jbi.management.MBeanHelper;
042:
043:        import java.util.Map;
044:
045:        /**
046:         * This is the Management Service of the JBI Framework, which provides
047:         * the JMX MBean server and related items.
048:         *
049:         * @author Sun Microsystems, Inc.
050:         */
051:        public class ManagementService implements  com.sun.jbi.ServiceLifecycle {
052:            /**
053:             * Handle to the logger
054:             */
055:            private java.util.logging.Logger mLog;
056:
057:            /**
058:             * copy of framework EnvironmentContext	
059:             */
060:            private EnvironmentContext mEnv;
061:
062:            /**
063:             * Handle to the Management Context
064:             */
065:            private ManagementContext mMgmtContext;
066:
067:            /**
068:             * Handle to the main MBean server
069:             */
070:            private MBeanServer mMBeanServer;
071:
072:            /**
073:             * Handle to the MBeanHelper class, for creating & registering mbeans:
074:             */
075:            private MBeanHelper mMBeanHelper;
076:
077:            /**
078:             * Handle to StringTranslator for message translation
079:             */
080:            private StringTranslator mTranslator;
081:
082:            /**
083:             * Initialize the Management Service.
084:             * @param envContext the JBI environment context created
085:             * by the JBI framework
086:             * @throws javax.jbi.JBIException if an error occurs
087:             */
088:            public void initService(EnvironmentContext envContext)
089:                    throws javax.jbi.JBIException {
090:                mEnv = envContext; //save a copy of framework EnvironmentContext	
091:                Properties jbiprops = mEnv.getInitialProperties();
092:
093:                mTranslator = mEnv
094:                        .getStringTranslator("com.sun.jbi.management");
095:
096:                //initialize any missing properties to default values:
097:                initJbiProperties(jbiprops);
098:
099:                // copy initial (static) jbi properties to global system properties:
100:                exportJbiProperties(jbiprops);
101:
102:                //create management context object:
103:                mMgmtContext = new ManagementContext(envContext);
104:
105:                //note - all variables we need from framework env context are wrapped by
106:                //the management context.  So use the management context to retrieve values:
107:                mMBeanServer = mMgmtContext.getMBeanServer();
108:                mMBeanHelper = mMgmtContext.getMBeanHelper();
109:
110:                mLog = mMgmtContext.getLogger();
111:                mLog.fine("ManagementService: initializing");
112:
113:                if (!mMBeanHelper.createSystemServiceLoggerMBean(
114:                        "ManagementService", mLog)) {
115:                    String errMsg = mTranslator
116:                            .getString(LocalStringKeys.MNGMTSVC_CANNOT_CREATE_LOGGERMBEAN);
117:                    mLog.severe(errMsg);
118:                }
119:
120:                //Create DeploymentService:
121:                if (!createDeploymentService(mMgmtContext)) {
122:                    throw new javax.jbi.JBIException(
123:                            "cannot create JBI Framework DeploymentService.");
124:                }
125:
126:                //Create InstallationService:
127:                if (!createInstallationService(mMgmtContext)) {
128:                    throw new javax.jbi.JBIException(
129:                            "cannot create JBI Framework InstallationService.");
130:                }
131:
132:                //Create LoggingService:
133:                if (!createLoggingService(mMgmtContext)) {
134:                    throw new javax.jbi.JBIException(
135:                            "cannot create JBI Framework LoggingService.");
136:                }
137:
138:                //Create AdminService LAST, as it is the entry point:
139:                if (!createAdminService(mMgmtContext)) {
140:                    throw new javax.jbi.JBIException(
141:                            "cannot create JBI Framework AdminService.");
142:                }
143:
144:                try {
145:                    MBeanNames mbn = mMgmtContext.getMBeanNames();
146:                    ObjectName adminLC = mbn.getSystemServiceMBeanName(
147:                            mbn.SERVICE_NAME_ADMIN_SERVICE,
148:                            mbn.CONTROL_TYPE_LIFECYCLE);
149:
150:                    mLog
151:                            .fine("ManagementService: Starting admin service lifecycle, "
152:                                    + adminLC.toString());
153:
154:                    // start up the admin service via its lifecycle:
155:                    mMBeanServer.invoke(adminLC, "start", new Object[0],
156:                            new String[0]);
157:
158:                    //now tell the admin service to start the management layer:
159:                    ObjectName adminSVC = mbn.getSystemServiceMBeanName(
160:                            mbn.SERVICE_NAME_ADMIN_SERVICE,
161:                            mbn.CONTROL_TYPE_ADMIN_SERVICE);
162:                    mLog
163:                            .fine("ManagementService: Starting Management Services, "
164:                                    + adminSVC.toString());
165:                    mMBeanServer.invoke(adminSVC, "startManagementServices",
166:                            new Object[0], new String[0]);
167:                } catch (Exception e) {
168:                    mLog.severe(e.toString());
169:                    e.printStackTrace();
170:                    throw new javax.jbi.JBIException(e);
171:                }
172:
173:                mLog.fine("ManagementService: initialization complete");
174:            }
175:
176:            /**
177:             * Start the Management service.
178:             * @throws javax.jbi.JBIException if an error occurs.
179:             */
180:            public void startService() throws javax.jbi.JBIException {
181:                mLog.fine("ManagementService: starting");
182:                mLog.fine("ManagementService: startup complete");
183:            }
184:
185:            /**
186:             * Stop the Management service.
187:             * @throws javax.jbi.JBIException if an error occurs.
188:             */
189:            public void stopService() throws javax.jbi.JBIException {
190:                mLog.fine("ManagementService: shutting down");
191:
192:                try {
193:                    MBeanNames mbn = mMgmtContext.getMBeanNames();
194:                    ObjectName adminSVC = mbn.getSystemServiceMBeanName(
195:                            mbn.SERVICE_NAME_ADMIN_SERVICE,
196:                            mbn.CONTROL_TYPE_ADMIN_SERVICE);
197:
198:                    mLog.fine("ManagementService: shutdown Management layer, "
199:                            + adminSVC.toString());
200:
201:                    //shutdown the management layer:
202:                    mMBeanServer.invoke(adminSVC, "shutdownManagementServices",
203:                            new Object[0], new String[0]);
204:                } catch (Exception e) {
205:                    mLog.warning(e.toString());
206:                    throw new javax.jbi.JBIException(e);
207:                }
208:
209:                //unregister the mbean for my logger:
210:                if (!mMBeanHelper.destroySystemServiceLoggerMBean(
211:                        "ManagementService", mLog)) {
212:                    mLog
213:                            .fine("ManagementService: cannot destroy my LoggerMBean!");
214:                }
215:
216:                mLog.fine("ManagementService: shutdown complete");
217:            }
218:
219:            /**
220:             * This is called by the framework whenever a component changes state, so
221:             * that the deployment service can be notified to update any affected
222:             * service connections.
223:             * @param componentName name of a component that has changed state
224:             */
225:            public void updateComponentState(String componentName) {
226:                // -- Notify Deployment Service of component change
227:                DeploymentService depSvc = mMgmtContext
228:                        .getDeploymentServiceHandle();
229:                depSvc.updateServiceAssemblyConnections(componentName);
230:            }
231:
232:            /**
233:             * Helper to get ManagementContext from an Environment Context in SunASJBIFramework.
234:             */
235:            public ManagementContext getManagementContext() {
236:                return (mMgmtContext);
237:            }
238:
239:            /**
240:             * initialize any missing properties to default values:
241:             * @param jbiprops is the property object we are initializing.
242:             */
243:            private void initJbiProperties(Properties jbiprops) {
244:                /** Add domain root values iff this is the admin server */
245:                if (mEnv.getPlatformContext().isAdminServer()) {
246:                    /** NOTE : this code references a platform-specific property :
247:                     *  com.sun.aas.domainName.  It is only used in our 
248:                     *  regression environment, so this is not a huge deal, but we need
249:                     *  to find a more portable way to surface this property.
250:                     */
251:
252:                    //re-export some key appserver properties:
253:                    jbiprops.setProperty("com.sun.jbi.domain.root", mEnv
254:                            .getPlatformContext().getInstanceRoot());
255:
256:                    String domainName = System
257:                            .getProperty("com.sun.aas.domainName");
258:                    if (domainName != null) {
259:                        jbiprops.setProperty("com.sun.jbi.domain.name",
260:                                domainName);
261:                    }
262:                }
263:
264:            }
265:
266:            /**
267:             * Export the jbi inital properties as system properties, so we can
268:             * use them to generate configuration scripts.
269:             * @param jbiprops holds the properties we are going to export.
270:             */
271:            private void exportJbiProperties(Properties jbiprops) {
272:                //for each property in jbiprops...
273:                for (Enumeration e = jbiprops.propertyNames(); e
274:                        .hasMoreElements();) {
275:                    String key = (String) e.nextElement();
276:                    String value = jbiprops.getProperty(key);
277:
278:                    //Now, copy to system:
279:                    System.setProperty(key, value);
280:                }
281:            }
282:
283:            //////////
284:            // Methods to create each system service
285:            //////////
286:
287:            /**
288:             * Create, initialize,  and register the AdminService
289:             * lifecycle MBean with the JBI Framework MBEANSERVER.
290:             *
291:             * Save handle to new service.
292:             *
293:             * @param gv is the management context.
294:             * @return false if we cannot.
295:             */
296:            private static boolean createAdminService(ManagementContext gv) {
297:                String this Service = "AdminService";
298:
299:                //create object:
300:                AdminService svc = new AdminService(gv);
301:
302:                //save handle to AdminService:
303:                gv.setAdminServiceHandle(svc);
304:
305:                //bootstrap the service:
306:                //NOTE:  this happen at START time, not INIT time:
307:                svc.bootstrap();
308:
309:                return true;
310:            }
311:
312:            /**
313:             * Create, initialize,  and register the ConfigurationService
314:             * lifecycle MBean with the JBI Framework MBEANSERVER.
315:             *
316:             * Save handle to new service.
317:             *
318:             * @param gv is the management context.
319:             * @return false if we cannot.
320:             *
321:            private static boolean createConfigurationService(ManagementContext gv)
322:            {
323:                String thisService = "ConfigurationService";
324:
325:                //create object:
326:                ConfigurationService svc = new ConfigurationService();
327:
328:                //save handle to ConfigurationService:
329:                gv.setConfigurationServiceHandle(svc);
330:
331:                //bootstrap the service:
332:                //NOTE:  this happen at START time, not INIT time:
333:                svc.bootstrap();
334:
335:                return true;
336:            }*/
337:
338:            /**
339:             * Create, initialize,  and register the DeploymentService
340:             * lifecycle MBean with the JBI Framework MBEANSERVER.
341:             *
342:             * Save handle to new service.
343:             *
344:             * @param gv is the management context.
345:             * @return false if we cannot.
346:             */
347:            private static boolean createDeploymentService(ManagementContext gv)
348:                    throws javax.jbi.JBIException {
349:                String this Service = "DeploymentService";
350:
351:                //create object:
352:                DeploymentService svc = new DeploymentService(gv);
353:
354:                //save handle to DeploymentService:
355:                gv.setDeploymentServiceHandle(svc);
356:
357:                //bootstrap the service:
358:                //NOTE:  this happen at START time, not INIT time:
359:                svc.bootstrap();
360:
361:                return true;
362:            }
363:
364:            /**
365:             * Create, initialize,  and register the InstallationService
366:             * lifecycle MBean with the JBI Framework MBEANSERVER.
367:             *
368:             * Save handle to new service.
369:             *
370:             * @param gv is the management context.
371:             * @return false if we cannot.
372:             */
373:            private static boolean createInstallationService(
374:                    ManagementContext gv) throws javax.jbi.JBIException {
375:                String this Service = "InstallationService";
376:
377:                //create object:
378:                InstallationService svc = new InstallationService(gv);
379:
380:                //save handle to InstallationService:
381:                gv.setInstallationServiceHandle(svc);
382:
383:                //bootstrap the service:
384:                //NOTE:  this happen at START time, not INIT time:
385:                svc.bootstrap();
386:
387:                return true;
388:            }
389:
390:            /**
391:             * Create, initialize,  and register the LoggingService
392:             * lifecycle MBean with the JBI Framework MBEANSERVER.
393:             *
394:             * Save handle to new service.
395:             *
396:             * @param gv is the management context.
397:             * @return false if we cannot.
398:             */
399:            private static boolean createLoggingService(ManagementContext gv) {
400:                String this Service = "LoggingService";
401:
402:                //create object:
403:                LoggingService svc = new LoggingService(gv);
404:
405:                //save handle to LoggingService:
406:                gv.setLoggingServiceHandle(svc);
407:
408:                //bootstrap the service:
409:                //NOTE:  this happen at START time, not INIT time:
410:                svc.bootstrap();
411:
412:                return true;
413:            }
414:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.