Source Code Cross Referenced for Initializer.java in  » J2EE » wicket » wicket » jmx » 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 » J2EE » wicket » wicket.jmx 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ==============================================================================
003:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
004:         * use this file except in compliance with the License. You may obtain a copy of
005:         * the License at
006:         * 
007:         * http://www.apache.org/licenses/LICENSE-2.0
008:         * 
009:         * Unless required by applicable law or agreed to in writing, software
010:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
011:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
012:         * License for the specific language governing permissions and limitations under
013:         * the License.
014:         */
015:        package wicket.jmx;
016:
017:        import java.lang.management.ManagementFactory;
018:        import java.util.ArrayList;
019:        import java.util.List;
020:
021:        import javax.management.InstanceAlreadyExistsException;
022:        import javax.management.InstanceNotFoundException;
023:        import javax.management.MBeanRegistrationException;
024:        import javax.management.MBeanServer;
025:        import javax.management.MalformedObjectNameException;
026:        import javax.management.NotCompliantMBeanException;
027:        import javax.management.ObjectName;
028:
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:
032:        import wicket.IDestroyer;
033:        import wicket.IInitializer;
034:        import wicket.WicketRuntimeException;
035:
036:        /**
037:         * Registers Wicket's MBeans.
038:         * 
039:         * @author eelcohillenius
040:         */
041:        public class Initializer implements  IInitializer, IDestroyer {
042:            private static Log log = LogFactory.getLog(Initializer.class);
043:
044:            /**
045:             * List of registered names
046:             */
047:            private List<ObjectName> registered = new ArrayList<ObjectName>();
048:
049:            /**
050:             * @see wicket.IDestroyer#destroy(wicket.Application)
051:             */
052:            public void destroy(wicket.Application application) {
053:                MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
054:                for (ObjectName objectName : registered) {
055:                    try {
056:                        mbs.unregisterMBean(objectName);
057:                    } catch (InstanceNotFoundException e) {
058:                        log.error(e.getMessage(), e);
059:                    } catch (MBeanRegistrationException e) {
060:                        log.error(e.getMessage(), e);
061:                    }
062:                }
063:            }
064:
065:            /**
066:             * @see wicket.IInitializer#init(wicket.Application)
067:             */
068:            public void init(wicket.Application application) {
069:                try {
070:                    String name = application.getName();
071:                    MBeanServer mbs = ManagementFactory
072:                            .getPlatformMBeanServer();
073:
074:                    // register top level application object, but first check whether
075:                    // multiple instances of the same application (name) are running and
076:                    // if so adjust the name
077:                    String domain = "wicket.app." + name;
078:                    ObjectName appBeanName = new ObjectName(domain
079:                            + ":type=Application");
080:                    String tempDomain = domain;
081:                    int i = 0;
082:                    while (mbs.isRegistered(appBeanName)) {
083:                        tempDomain = name + "-" + i++;
084:                        appBeanName = new ObjectName(tempDomain
085:                                + ":type=Application");
086:                    }
087:                    domain = tempDomain;
088:
089:                    Application appBean = new Application(application);
090:                    register(mbs, appBean, appBeanName);
091:
092:                    register(
093:                            mbs,
094:                            new ApplicationSettings(application),
095:                            new ObjectName(
096:                                    domain
097:                                            + ":type=Application,name=ApplicationSettings"));
098:                    register(mbs, new DebugSettings(application),
099:                            new ObjectName(domain
100:                                    + ":type=Application,name=DebugSettings"));
101:                    register(mbs, new MarkupSettings(application),
102:                            new ObjectName(domain
103:                                    + ":type=Application,name=MarkupSettings"));
104:                    register(
105:                            mbs,
106:                            new ResourceSettings(application),
107:                            new ObjectName(domain
108:                                    + ":type=Application,name=ResourceSettings"));
109:                    register(mbs, new PageSettings(application),
110:                            new ObjectName(domain
111:                                    + ":type=Application,name=PageSettings"));
112:                    register(
113:                            mbs,
114:                            new RequestCycleSettings(application),
115:                            new ObjectName(
116:                                    domain
117:                                            + ":type=Application,name=RequestCycleSettings"));
118:                    register(
119:                            mbs,
120:                            new SecuritySettings(application),
121:                            new ObjectName(domain
122:                                    + ":type=Application,name=SecuritySettings"));
123:                    register(mbs, new SessionSettings(application),
124:                            new ObjectName(domain
125:                                    + ":type=Application,name=SessionSettings"));
126:                    register(
127:                            mbs,
128:                            new CookieValuePersisterSettings(application),
129:                            new ObjectName(
130:                                    domain
131:                                            + ":type=Application,name=CookieValuePersisterSettings"));
132:
133:                    RequestLogger sessionsBean = new RequestLogger(application);
134:                    ObjectName sessionsBeanName = new ObjectName(domain
135:                            + ":type=RequestLogger");
136:                    register(mbs, sessionsBean, sessionsBeanName);
137:                } catch (MalformedObjectNameException e) {
138:                    throw new WicketRuntimeException(e);
139:                } catch (InstanceAlreadyExistsException e) {
140:                    throw new WicketRuntimeException(e);
141:                } catch (MBeanRegistrationException e) {
142:                    throw new WicketRuntimeException(e);
143:                } catch (NotCompliantMBeanException e) {
144:                    throw new WicketRuntimeException(e);
145:                }
146:            }
147:
148:            /**
149:             * @see java.lang.Object#toString()
150:             */
151:            public String toString() {
152:                return "Wicket JMX initializer";
153:            }
154:
155:            /**
156:             * Register MBean.
157:             * 
158:             * @param mbs
159:             *            server
160:             * @param o
161:             *            MBean
162:             * @param objectName
163:             *            Object name
164:             * @throws NotCompliantMBeanException
165:             * @throws MBeanRegistrationException
166:             * @throws InstanceAlreadyExistsException
167:             */
168:            private void register(MBeanServer mbs, Object o,
169:                    ObjectName objectName)
170:                    throws InstanceAlreadyExistsException,
171:                    MBeanRegistrationException, NotCompliantMBeanException {
172:                mbs.registerMBean(o, objectName);
173:                registered.add(objectName);
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.