Source Code Cross Referenced for NotificationServiceMBeanImpl.java in  » ESB » open-esb » com » sun » esb » management » impl » notification » 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.esb.management.impl.notification 
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:         * @(#)NotificationServiceMBeanImpl.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.esb.management.impl.notification;
030:
031:        import java.io.Serializable;
032:
033:        import javax.management.Attribute;
034:        import javax.management.AttributeList;
035:        import javax.management.AttributeNotFoundException;
036:        import javax.management.DynamicMBean;
037:        import javax.management.InstanceNotFoundException;
038:        import javax.management.InvalidAttributeValueException;
039:        import javax.management.MBeanAttributeInfo;
040:        import javax.management.MBeanConstructorInfo;
041:        import javax.management.MBeanException;
042:        import javax.management.MBeanInfo;
043:        import javax.management.MBeanNotificationInfo;
044:        import javax.management.MBeanOperationInfo;
045:        import javax.management.Notification;
046:        import javax.management.NotificationBroadcasterSupport;
047:        import javax.management.NotificationListener;
048:        import javax.management.ObjectName;
049:        import javax.management.ReflectionException;
050:
051:        import com.sun.esb.management.api.notification.EventNotificationListener;
052:        import com.sun.esb.management.api.notification.NotificationService;
053:        import com.sun.esb.management.common.ManagementRemoteException;
054:        import com.sun.jbi.EnvironmentContext;
055:        import com.sun.jbi.management.MBeanNames;
056:        import com.sun.jbi.ui.common.I18NBundle;
057:
058:        /**
059:         * @author graj
060:         *
061:         */
062:        public class NotificationServiceMBeanImpl extends
063:                NotificationBroadcasterSupport implements  NotificationListener,
064:                DynamicMBean, Serializable, NotificationService {
065:            static final long serialVersionUID = -1L;
066:
067:            private String name = "NotificationService";
068:            private String description = "Notification Service Broadcaster";
069:
070:            /** i18n */
071:            private static I18NBundle I18NBUNDLE = null;
072:
073:            /** Jbi Environment context. */
074:            protected EnvironmentContext environmentContext;
075:
076:            /**
077:             * Events that generate notifications.
078:             */
079:            enum EventType {
080:                Installed, Upgraded, Uninstalled, Deployed, Undeployed, Ready, Started, Stopped, ShutDown
081:            }
082:
083:            /**
084:             * Sources of notifications.
085:             */
086:            enum SourceType {
087:                JBIRuntime, BindingComponent, ServiceEngine, SharedLibrary, ServiceUnit, ServiceAssembly
088:            }
089:
090:            /**
091:             * Common prefix for all notification messages.
092:             */
093:            static final String JBI_PREFIX = "com.sun.jbi.";
094:
095:            /**
096:             * Notification types emitted by the runtime.
097:             */
098:            static final String[] NOTIFICATION_TYPES = {
099:                    JBI_PREFIX + EventType.Ready + "." + SourceType.JBIRuntime,
100:                    JBI_PREFIX + EventType.Started + "."
101:                            + SourceType.JBIRuntime,
102:                    JBI_PREFIX + EventType.Stopped + "."
103:                            + SourceType.JBIRuntime,
104:                    JBI_PREFIX + EventType.Installed + "."
105:                            + SourceType.SharedLibrary,
106:                    JBI_PREFIX + EventType.Uninstalled + "."
107:                            + SourceType.SharedLibrary,
108:                    JBI_PREFIX + EventType.Installed + "."
109:                            + SourceType.BindingComponent,
110:                    JBI_PREFIX + EventType.Started + "."
111:                            + SourceType.BindingComponent,
112:                    JBI_PREFIX + EventType.Stopped + "."
113:                            + SourceType.BindingComponent,
114:                    JBI_PREFIX + EventType.ShutDown + "."
115:                            + SourceType.BindingComponent,
116:                    JBI_PREFIX + EventType.Uninstalled + "."
117:                            + SourceType.BindingComponent,
118:                    JBI_PREFIX + EventType.Installed + "."
119:                            + SourceType.ServiceEngine,
120:                    JBI_PREFIX + EventType.Started + "."
121:                            + SourceType.ServiceEngine,
122:                    JBI_PREFIX + EventType.Stopped + "."
123:                            + SourceType.ServiceEngine,
124:                    JBI_PREFIX + EventType.ShutDown + "."
125:                            + SourceType.ServiceEngine,
126:                    JBI_PREFIX + EventType.Uninstalled + "."
127:                            + SourceType.ServiceEngine,
128:                    JBI_PREFIX + EventType.Deployed + "."
129:                            + SourceType.ServiceAssembly,
130:                    JBI_PREFIX + EventType.Started + "."
131:                            + SourceType.ServiceAssembly,
132:                    JBI_PREFIX + EventType.Stopped + "."
133:                            + SourceType.ServiceAssembly,
134:                    JBI_PREFIX + EventType.ShutDown + "."
135:                            + SourceType.ServiceAssembly,
136:                    JBI_PREFIX + EventType.Undeployed + "."
137:                            + SourceType.ServiceAssembly,
138:                    JBI_PREFIX + EventType.Deployed + "."
139:                            + SourceType.ServiceUnit,
140:                    JBI_PREFIX + EventType.Started + "."
141:                            + SourceType.ServiceUnit,
142:                    JBI_PREFIX + EventType.Stopped + "."
143:                            + SourceType.ServiceUnit,
144:                    JBI_PREFIX + EventType.ShutDown + "."
145:                            + SourceType.ServiceUnit,
146:                    JBI_PREFIX + EventType.Undeployed + "."
147:                            + SourceType.ServiceUnit };
148:
149:            /**
150:             * Class name for notifications emitted by the runtime.
151:             */
152:            static final String NOTIFICATION_CLASS_NAME = "javax.management.Notification";
153:
154:            /**
155:             * Desription for notifications emitted by the runtime.
156:             */
157:            static final String NOTIFICATION_DESCRIPTION = "JBI runtime event";
158:
159:            static final String[] ITEM_NAMES = { "EventType", "SourceType",
160:                    "TargetName", "SourceName", "ServiceAssemblyName",
161:                    "ComponentName" };
162:
163:            /** default constructor */
164:            public NotificationServiceMBeanImpl(EnvironmentContext anEnvContext) {
165:                this .environmentContext = anEnvContext;
166:                this .registerForLocalNotifications();
167:            }
168:
169:            /**
170:             * Handles event notifications from the runtime and sends to remote clients
171:             * @param a notification
172:             * @param a handback
173:             * 
174:             * @see javax.management.NotificationListener#handleNotification(javax.management.Notification, java.lang.Object)
175:             */
176:            public void handleNotification(Notification notification,
177:                    Object handback) {
178:                super .sendNotification(notification);
179:            }
180:
181:            /**
182:             * Retrieve an attribute
183:             * @param the attribute name
184:             * @return the attribute value
185:             * 
186:             * @see javax.management.DynamicMBean#getAttribute(java.lang.String)
187:             */
188:            public Object getAttribute(String attribute)
189:                    throws AttributeNotFoundException, MBeanException,
190:                    ReflectionException {
191:                if (attribute.equals("name")) {
192:                    return getName();
193:                }
194:                if (attribute.equals("description")) {
195:                    return getDescription();
196:                }
197:                return null;
198:            }
199:
200:            /**
201:             * Get an attribute list
202:             * @param the list of attribute names
203:             * @return the attributelist
204:             * @see javax.management.DynamicMBean#getAttributes(java.lang.String[])
205:             */
206:            public AttributeList getAttributes(String[] attributes) {
207:                // TODO Auto-generated method stub
208:                return null;
209:            }
210:
211:            /**
212:             * Get the MBean Info
213:             * @return the MBeanInfo
214:             * 
215:             * @see javax.management.DynamicMBean#getMBeanInfo()
216:             */
217:            public MBeanInfo getMBeanInfo() {
218:                MBeanInfo beanInfo = new MBeanInfo(
219:                        "ESBNotificationBroadcaster",
220:                        "ESBNotificationBroadcaster",
221:                        new MBeanAttributeInfo[] {},
222:                        new MBeanConstructorInfo[] {},
223:                        new MBeanOperationInfo[] {},
224:                        new MBeanNotificationInfo[] { new MBeanNotificationInfo(
225:                                NOTIFICATION_TYPES, NOTIFICATION_CLASS_NAME,
226:                                NOTIFICATION_DESCRIPTION) });
227:                return beanInfo;
228:            }
229:
230:            /**
231:             * Invoke an operation
232:             * @param operationName
233:             * @param object parameters
234:             * @param param signatures
235:             * @return result of the invoke
236:             * 
237:             * @see javax.management.DynamicMBean#invoke(java.lang.String, java.lang.Object[], java.lang.String[])
238:             */
239:            public Object invoke(String actionName, Object[] params,
240:                    String[] signature) throws MBeanException,
241:                    ReflectionException {
242:                // TODO Auto-generated method stub
243:                return null;
244:            }
245:
246:            /**
247:             * Set an attribute value
248:             * @param the attribute to set
249:             * 
250:             * @see javax.management.DynamicMBean#setAttribute(javax.management.Attribute)
251:             */
252:            public void setAttribute(Attribute attribute)
253:                    throws AttributeNotFoundException,
254:                    InvalidAttributeValueException, MBeanException,
255:                    ReflectionException {
256:                if (attribute.getName().equals("name")) {
257:                    setName((String) attribute.getValue());
258:                } else if (attribute.getName().equals("description")) {
259:                    setDescription((String) attribute.getValue());
260:                }
261:            }
262:
263:            /**
264:             * Set a list of attribute values
265:             * @param the list of attributes to set
266:             * @return the attribute list
267:             * 
268:             * @see javax.management.DynamicMBean#setAttributes(javax.management.AttributeList)
269:             */
270:            public AttributeList setAttributes(AttributeList attributes) {
271:                // TODO Auto-generated method stub
272:                return null;
273:            }
274:
275:            /**
276:             * @return the name
277:             */
278:            public String getName() {
279:                return this .name;
280:            }
281:
282:            /**
283:             * @param name the name to set
284:             */
285:            public void setName(String name) {
286:                this .name = name;
287:            }
288:
289:            /**
290:             * @return the description
291:             */
292:            public String getDescription() {
293:                return this .description;
294:            }
295:
296:            /**
297:             * @param description the description to set
298:             */
299:            public void setDescription(String description) {
300:                this .description = description;
301:            }
302:
303:            /**
304:             * Add a notification listener
305:             * @param event notification listener object
306:             * 
307:             * @see com.sun.esb.management.api.notification.NotificationService#addNotificationEventListener(com.sun.esb.management.api.notification.EventNotificationListener)
308:             */
309:            public void addNotificationEventListener(
310:                    EventNotificationListener listener)
311:                    throws ManagementRemoteException {
312:            }
313:
314:            /**
315:             * Remove a notification listener
316:             * @param event notification listener object
317:             * 
318:             * @see com.sun.esb.management.api.notification.NotificationService#removeNotificationEventListener(com.sun.esb.management.api.notification.EventNotificationListener)
319:             */
320:            public void removeNotificationEventListener(
321:                    EventNotificationListener listener)
322:                    throws ManagementRemoteException {
323:            }
324:
325:            /**
326:             * Get the Framework Notification MBean
327:             * @return
328:             */
329:            protected ObjectName getFrameworkDomainNotificationMBean() {
330:                return this .environmentContext.getMBeanNames()
331:                        .getSystemServiceMBeanName(
332:                                MBeanNames.ServiceName.Framework,
333:                                MBeanNames.ServiceType.Notification, "domain");
334:            }
335:
336:            /**
337:             * Register for notifications from the framework MBean
338:             */
339:            protected void registerForLocalNotifications() {
340:                ObjectName mbeanName = getFrameworkDomainNotificationMBean();
341:
342:                try {
343:                    Object[] params = { this , null, null };
344:                    String[] signature = {
345:                            "javax.management.NotificationListener",
346:                            "javax.management.NotificationFilter",
347:                            "java.lang.Object" };
348:                    this .environmentContext.getMBeanServer().invoke(mbeanName,
349:                            "addNotificationListener", params, signature);
350:                } catch (InstanceNotFoundException e) {
351:                    // Could not register for local notifications
352:                } catch (MBeanException e) {
353:                    // Could not register for local notifications
354:                } catch (ReflectionException e) {
355:                    // Could not register for local notifications
356:                }
357:            }
358:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.