Source Code Cross Referenced for RegistrationSupport.java in  » JMX » mx4j » test » javax » management » support » 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 » JMX » mx4j » test.javax.management.support 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) The MX4J Contributors.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the MX4J License version 1.0.
006:         * See the terms of the MX4J License in the documentation provided with this software.
007:         */
008:
009:        package test.javax.management.support;
010:
011:        import javax.management.InstanceNotFoundException;
012:        import javax.management.MBeanOperationInfo;
013:        import javax.management.MBeanParameterInfo;
014:        import javax.management.MBeanRegistration;
015:        import javax.management.MBeanServer;
016:        import javax.management.Notification;
017:        import javax.management.NotificationListener;
018:        import javax.management.ObjectName;
019:
020:        import mx4j.AbstractDynamicMBean;
021:        import test.MutableBoolean;
022:        import test.MutableObject;
023:
024:        /**
025:         * @version $Revision: 1.7 $
026:         */
027:        public class RegistrationSupport {
028:            public interface NullObjectNameMBean {
029:            }
030:
031:            public static class NullObjectName implements  NullObjectNameMBean,
032:                    MBeanRegistration {
033:                public ObjectName preRegister(MBeanServer server,
034:                        ObjectName name) throws Exception {
035:                    return null;
036:                }
037:
038:                public void postRegister(Boolean registrationDone) {
039:                }
040:
041:                public void preDeregister() throws Exception {
042:                }
043:
044:                public void postDeregister() {
045:                }
046:            }
047:
048:            public interface PreRegisterExceptionMBean {
049:            }
050:
051:            public static class PreRegisterException implements 
052:                    PreRegisterExceptionMBean, MBeanRegistration {
053:                public ObjectName preRegister(MBeanServer server,
054:                        ObjectName name) throws Exception {
055:                    throw new Exception();
056:                }
057:
058:                public void postRegister(Boolean registrationDone) {
059:                }
060:
061:                public void preDeregister() throws Exception {
062:                }
063:
064:                public void postDeregister() {
065:                }
066:            }
067:
068:            public interface PostRegisterExceptionMBean {
069:            }
070:
071:            public static class PostRegisterException implements 
072:                    PostRegisterExceptionMBean, MBeanRegistration {
073:                public ObjectName preRegister(MBeanServer server,
074:                        ObjectName name) throws Exception {
075:                    return name;
076:                }
077:
078:                public void postRegister(Boolean registrationDone) {
079:                    throw new RuntimeException();
080:                }
081:
082:                public void preDeregister() throws Exception {
083:                }
084:
085:                public void postDeregister() {
086:                }
087:            }
088:
089:            public interface PreDeregisterExceptionMBean {
090:            }
091:
092:            public static class PreDeregisterException implements 
093:                    PreDeregisterExceptionMBean, MBeanRegistration {
094:                public ObjectName preRegister(MBeanServer server,
095:                        ObjectName name) throws Exception {
096:                    return name;
097:                }
098:
099:                public void postRegister(Boolean registrationDone) {
100:                }
101:
102:                public void preDeregister() throws Exception {
103:                    throw new Exception();
104:                }
105:
106:                public void postDeregister() {
107:                }
108:            }
109:
110:            public interface PostDeregisterExceptionMBean {
111:            }
112:
113:            public static class PostDeregisterException implements 
114:                    PostDeregisterExceptionMBean, MBeanRegistration {
115:                public ObjectName preRegister(MBeanServer server,
116:                        ObjectName name) throws Exception {
117:                    return name;
118:                }
119:
120:                public void postRegister(Boolean registrationDone) {
121:                }
122:
123:                public void preDeregister() throws Exception {
124:                }
125:
126:                public void postDeregister() {
127:                    throw new RuntimeException();
128:                }
129:            }
130:
131:            public interface EmptyMBean {
132:            }
133:
134:            public static class Empty implements  EmptyMBean, MBeanRegistration {
135:                private MutableBoolean m_bool1;
136:                private MutableBoolean m_bool2;
137:
138:                public Empty(MutableBoolean bool1, MutableBoolean bool2) {
139:                    m_bool1 = bool1;
140:                    m_bool2 = bool2;
141:                }
142:
143:                public ObjectName preRegister(MBeanServer server,
144:                        ObjectName name) throws Exception {
145:                    return name;
146:                }
147:
148:                public void postRegister(Boolean registrationDone) {
149:                    m_bool1.set(registrationDone.booleanValue());
150:                }
151:
152:                public void preDeregister() throws Exception {
153:                    m_bool1.set(false);
154:                }
155:
156:                public void postDeregister() {
157:                    m_bool2.set(false);
158:                }
159:            }
160:
161:            public interface EmptyDuplicateMBean {
162:            }
163:
164:            public static class EmptyDuplicate implements  EmptyDuplicateMBean,
165:                    MBeanRegistration {
166:                private ObjectName m_name;
167:                private MutableBoolean m_bool1;
168:
169:                public EmptyDuplicate(ObjectName name, MutableBoolean bool1) {
170:                    m_name = name;
171:                    m_bool1 = bool1;
172:                }
173:
174:                public ObjectName preRegister(MBeanServer server,
175:                        ObjectName name) throws Exception {
176:                    return m_name;
177:                }
178:
179:                public void postRegister(Boolean registrationDone) {
180:                    m_bool1.set(registrationDone.booleanValue());
181:                }
182:
183:                public void preDeregister() throws Exception {
184:                }
185:
186:                public void postDeregister() {
187:                }
188:            }
189:
190:            public interface StdMBean {
191:                public void method();
192:            }
193:
194:            public static class Std implements  StdMBean, MBeanRegistration {
195:                public ObjectName preRegister(MBeanServer server,
196:                        ObjectName name) throws Exception {
197:                    return name;
198:                }
199:
200:                public void postRegister(Boolean registrationDone) {
201:                }
202:
203:                public void preDeregister() throws Exception {
204:                }
205:
206:                public void postDeregister() {
207:                }
208:
209:                public void method() {
210:                }
211:            }
212:
213:            public static class Dyn extends AbstractDynamicMBean implements 
214:                    MBeanRegistration {
215:                public ObjectName preRegister(MBeanServer server,
216:                        ObjectName name) throws Exception {
217:                    return name;
218:                }
219:
220:                public void postRegister(Boolean registrationDone) {
221:                }
222:
223:                public void preDeregister() throws Exception {
224:                }
225:
226:                public void postDeregister() {
227:                }
228:
229:                public void method() {
230:                }
231:
232:                protected MBeanOperationInfo[] createMBeanOperationInfo() {
233:                    return new MBeanOperationInfo[] { new MBeanOperationInfo(
234:                            StdMBean.class.getMethods()[0].getName(), null,
235:                            new MBeanParameterInfo[0], "void",
236:                            MBeanOperationInfo.UNKNOWN) };
237:                }
238:            }
239:
240:            public interface ListenerRegistrarMBean {
241:            }
242:
243:            public static class ListenerRegistrar implements 
244:                    ListenerRegistrarMBean, MBeanRegistration,
245:                    NotificationListener {
246:                private final MutableObject holder;
247:                private MBeanServer server;
248:                private ObjectName delegate;
249:
250:                public ListenerRegistrar(MutableObject holder) {
251:                    this .holder = holder;
252:                }
253:
254:                public ObjectName preRegister(MBeanServer server,
255:                        ObjectName name) throws Exception {
256:                    this .server = server;
257:                    delegate = ObjectName
258:                            .getInstance("JMImplementation:type=MBeanServerDelegate");
259:                    return name;
260:                }
261:
262:                public void postRegister(Boolean registrationDone) {
263:                    try {
264:                        server.addNotificationListener(delegate, this , null,
265:                                null);
266:                    } catch (InstanceNotFoundException x) {
267:                        throw new Error(x.toString());
268:                    }
269:                }
270:
271:                public void preDeregister() throws Exception {
272:                }
273:
274:                public void postDeregister() {
275:                    try {
276:                        server.removeNotificationListener(delegate, this );
277:                    } catch (Exception x) {
278:                        throw new Error(x.toString());
279:                    }
280:                }
281:
282:                public void handleNotification(Notification notification,
283:                        Object handback) {
284:                    holder.set(notification);
285:                }
286:            }
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.