Source Code Cross Referenced for ReconfigDispatcher.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » management » 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 » JOnAS 4.8.6 » org.objectweb.jonas.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: ReconfigDispatcher.java 6661 2005-04-28 08:43:27Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.management;
025:
026:        // JMX import
027:        import javax.management.ListenerNotFoundException;
028:        import javax.management.MBeanNotificationInfo;
029:        import javax.management.Notification;
030:        import javax.management.NotificationBroadcasterSupport;
031:        import javax.management.NotificationFilter;
032:        import javax.management.NotificationListener;
033:
034:        import org.objectweb.util.monolog.api.BasicLevel;
035:        import org.objectweb.util.monolog.api.Logger;
036:
037:        /**
038:         * This MBean implementation has to be extended by MBeans associated to reconfigurable JOnAS services
039:         * and to reconfigurable resources managed by JOnAS (DataSources and MailFactories).
040:         * These MBeans can add and remove a notification listener, and emit notifications towards this listener.
041:         * Currently only one listner may register as listener: the ReconfigManager MBean created at the server start-up.
042:         * @author Adriana Danes
043:         * Contributor(s):
044:         */
045:        public class ReconfigDispatcher extends NotificationBroadcasterSupport
046:                implements  ReconfigDispatcherMBean {
047:
048:            private static Logger slogger = null;
049:
050:            /**
051:             * Management notification type for <i>reconfiguration</i> events (notify that the management application made a reconfiguration operation)
052:             */
053:            public static final String RECONFIG_TYPE = "jonas.management.reconfiguration";
054:            /**
055:             * Management notification type for <i>save configuration</i> events (notify that the management application asks for save changes)
056:             */
057:            public static final String SAVE_RECONFIG_TYPE = "jonas.management.reconfiguration.save";
058:            /**
059:             * Class implementing the management notifications.
060:             */
061:            final String RECONFIG_NOTIF_CLASS = "jmx.management.Notification";
062:            final String SAVE_RECONFIG_NOTIF_CLASS = "jmx.management.Notification";
063:
064:            /**
065:             * There may be only one listener : the ReconfigManager MBean.
066:             */
067:            ListenerJavaBean myListener = null;
068:
069:            /**
070:             * Initialize the logger with a Logger provided by the reconfigurable resource
071:             * or service.
072:             * @param mylogger the logger provided by a sub-class
073:             */
074:            public void initLogger(Logger mylogger) {
075:                slogger = mylogger;
076:            }
077:
078:            /**
079:             * This method is called by the ReconfigManager.
080:             * @listner  the ReconfigManager
081:             * @filter   null (not used)
082:             * @handback null (not used
083:             */
084:            public void addNotificationListener(NotificationListener listner,
085:                    NotificationFilter filter, java.lang.Object handback)
086:                    throws java.lang.IllegalArgumentException {
087:
088:                if (slogger.isLoggable(BasicLevel.DEBUG)) {
089:                    slogger.log(BasicLevel.DEBUG, "handback: " + handback);
090:                    if (myListener == null) {
091:                        slogger.log(BasicLevel.DEBUG, "Register the listener");
092:                    } else {
093:                        slogger.log(BasicLevel.DEBUG,
094:                                "Caution : Re-register a listener !!! ");
095:                    }
096:                }
097:                myListener = new ListenerJavaBean(listner, filter, handback);
098:            }
099:
100:            /**
101:             * This method is called by the ReconfigManager when it no longer needs to receive management notifications.
102:             * @listner the ReconfigManager
103:             */
104:            public void removeNotificationListener(NotificationListener listner)
105:                    throws ListenerNotFoundException {
106:                NotificationListener registeredListener = myListener
107:                        .getListener();
108:                if (registeredListener.equals(listner))
109:                    myListener = null;
110:            }
111:
112:            /**
113:             * Returns information about management notifications sent by this object
114:             * @return information about management notifications sent by this object
115:             */
116:            public MBeanNotificationInfo[] getNotificationInfo() {
117:                String[] notifsType = new String[2];
118:                notifsType[0] = new String(RECONFIG_TYPE);
119:                notifsType[1] = new String(SAVE_RECONFIG_TYPE);
120:
121:                MBeanNotificationInfo[] myNotifInfos = new MBeanNotificationInfo[2];
122:                MBeanNotificationInfo myNotifInfo = new MBeanNotificationInfo(
123:                        notifsType, RECONFIG_NOTIF_CLASS,
124:                        "Notify service reconfiguration events");
125:                myNotifInfos[0] = myNotifInfo;
126:
127:                myNotifInfo = new MBeanNotificationInfo(notifsType,
128:                        SAVE_RECONFIG_NOTIF_CLASS,
129:                        "Notify save reconfiguretion events");
130:                myNotifInfos[1] = myNotifInfo;
131:
132:                return myNotifInfos;
133:            }
134:
135:            /**
136:             * Returns the listener reference (the ReconfigManager)
137:             * @return the ReconfigManager reference
138:             */
139:            public NotificationListener getListener() {
140:                if (myListener != null)
141:                    return myListener.getListener();
142:                else
143:                    return null;
144:            }
145:
146:            /**
147:             * Returns the listner's filter
148:             * @return the filter object
149:             */
150:            public NotificationFilter getFilter() {
151:                if (myListener != null)
152:                    return myListener.getFilter();
153:                else
154:                    return null;
155:            }
156:
157:            /**
158:             * Returns the listner's handback
159:             * @return the handback object
160:             */
161:            public java.lang.Object getHandback() {
162:                if (myListener != null)
163:                    return myListener.getHandback();
164:                else
165:                    return null;
166:            }
167:
168:            /**
169:             * Send a <i>save configuration</i> notification to the registerd listener. If no listener,
170:             * then log an error message.
171:             * @param sequenceNumber notification attribute
172:             * @param resourceName the name of a reconfigurable resource or of a JOnAS service
173:             */
174:            public void sendSaveNotification(long sequenceNumber,
175:                    String resourceName) {
176:                // create notification
177:                Notification saveNotif = new Notification(SAVE_RECONFIG_TYPE,
178:                        this , sequenceNumber, resourceName);
179:                if (slogger.isLoggable(BasicLevel.DEBUG)) {
180:                    slogger.log(BasicLevel.DEBUG, saveNotif.getType()
181:                            + " notification object created");
182:                }
183:
184:                // get listener and emit notification to it
185:                NotificationListener listenerMBean = getListener();
186:                Object handback = getHandback();
187:                if (listenerMBean != null) {
188:                    listenerMBean.handleNotification(saveNotif, handback);
189:                } else {
190:                    if (slogger.isLoggable(BasicLevel.DEBUG)) {
191:                        slogger
192:                                .log(BasicLevel.ERROR,
193:                                        "MBean can't send management notification as no listener registered !!");
194:                    }
195:                }
196:            }
197:
198:            /**
199:             * Send a <i>reconfiguration</i> notification to the registerd listener. If no listener,
200:             * then log an error message.
201:             * @param sequenceNumber notification attribute
202:             * @param resourceName the name of a reconfigurable resource or of a JOnAS service
203:             * @param userData data containing the name and the value of the reconfigured property(or properties)
204:             */
205:            public void sendReconfigNotification(long sequenceNumber,
206:                    String resourceName, Object userData) {
207:                // create notification and set the userData
208:                Notification configNotif = new Notification(RECONFIG_TYPE,
209:                        this , sequenceNumber, resourceName);
210:                configNotif.setUserData(userData);
211:                if (slogger.isLoggable(BasicLevel.DEBUG)) {
212:                    slogger.log(BasicLevel.DEBUG, configNotif.getType()
213:                            + " notification object created");
214:                }
215:
216:                // get listener and emit notification to it
217:                NotificationListener listenerMBean = getListener();
218:                Object handback = getHandback();
219:                if (listenerMBean != null) {
220:                    listenerMBean.handleNotification(configNotif, handback);
221:                } else {
222:                    if (slogger.isLoggable(BasicLevel.DEBUG)) {
223:                        slogger
224:                                .log(BasicLevel.ERROR,
225:                                        "MBean can't send management notification as no listener registered !!");
226:                    }
227:                }
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.