Source Code Cross Referenced for JonasManagementRepr.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » 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 » JOnAS 4.8.6 » org.objectweb.jonas.jmx 
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: JonasManagementRepr.java 9688 2006-10-06 13:43:32Z danesa $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jmx;
025:
026:        import java.util.Hashtable;
027:
028:        import javax.management.MBeanInfo;
029:        import javax.management.ObjectName;
030:        import javax.naming.Context;
031:
032:        /**
033:         * Wraper class. Apply the management operations on the ManagementRep instance.
034:         * @author Adriana Danes
035:         */
036:        public class JonasManagementRepr {
037:
038:            /**
039:             * Using getManagementRepr() without parameters makes creating a ManagemenrReprImpl
040:             * object (an "old" style representant which uses proprietary RMIConnector object)
041:             */
042:            //private static ManagementRepr repr = ManagementReprFactory.getManagementRepr();
043:            // Let repr null and then use setRepr method, will allow to set/change representative
044:            // in order to set/change the managed server.
045:            //private static ManagementRepr repr = null;
046:            private static Hashtable serverReprs = new Hashtable();
047:
048:            public static void addServerRepr(String serverName,
049:                    ManagementRepr repr) {
050:                serverReprs.put(serverName, repr);
051:            }
052:
053:            public static boolean noServerRepr() {
054:                if (serverReprs.isEmpty()) {
055:                    return true;
056:                } else {
057:                    return false;
058:                }
059:            }
060:
061:            public static boolean isServerRepr(String serverName) {
062:                return serverReprs.containsKey(serverName);
063:            }
064:
065:            public static ManagementRepr getServerRepr(String serverName)
066:                    throws ManagementException {
067:                if (!isServerRepr(serverName)) {
068:                    // try to get repr
069:                    ManagementReprLoader.loadServerRepr(serverName);
070:                }
071:                ManagementRepr repr = (ManagementRepr) serverReprs
072:                        .get(serverName);
073:                if (repr != null) {
074:                    return repr;
075:                } else {
076:                    throw new ManagementException(
077:                            "Can't manage server "
078:                                    + serverName
079:                                    + " as no ManagementRepr set (couldn't get connection)");
080:                }
081:            }
082:
083:            /**
084:             * @return True if the MBean is already registered in the MBean server, false otherwise or if an exception is catched.
085:             * @param on ObjectName of the MBean we are looking for
086:             * @param serverName The server name
087:             */
088:            public static boolean isRegistered(ObjectName on, String serverName)
089:                    throws ManagementException {
090:                ManagementRepr repr = getServerRepr(serverName);
091:                return repr.isRegistered(on);
092:            }
093:
094:            /**
095:             * @param on The ObjectName of the MBean from which the attribute is to be retrieved.
096:             * @param attribute A String specifying the name of the attribute to be retrieve.
097:             * @param serverName The server name
098:             * @return The value of the attribute.
099:             */
100:            public static Object getAttribute(ObjectName on, String attribute,
101:                    String serverName) throws ManagementException {
102:                ManagementRepr repr = getServerRepr(serverName);
103:                return repr.getAttribute(on, attribute);
104:            }
105:
106:            /**
107:             * @param on The ObjectName of the MBean from which the attribute is to be retrieved.
108:             * @param attribute A String specifying the name of the attribute to be retrieve.
109:             * @param serverName The server name
110:             * @return The value of the attribute.
111:             */
112:            public static Object getAttributes(ObjectName on, String attribute,
113:                    String serverName) throws ManagementException {
114:                ManagementRepr repr = getServerRepr(serverName);
115:                return repr.getAttribute(on, attribute);
116:            }
117:
118:            /**
119:             * @param on The ObjectName of the MBean within which the attribute is to be set.
120:             * @param serverName The server name
121:             * @param attribute A String specifying the name of the attribute to be retrieve.
122:             * @param value The value to set to the attribute.
123:             */
124:            public static void setAttribute(ObjectName on, String attribute,
125:                    Object value, String serverName) throws ManagementException {
126:                ManagementRepr repr = getServerRepr(serverName);
127:                repr.setAttribute(on, attribute, value);
128:            }
129:
130:            /**
131:             * @param on
132:             * @param param invoke parameters
133:             * @param signature invoke parameters signature
134:             * @param serverName The server name
135:             */
136:            public static Object invoke(ObjectName on, String operation,
137:                    Object[] param, String[] signature, String serverName)
138:                    throws ManagementException {
139:                ManagementRepr repr = getServerRepr(serverName);
140:                return repr.invoke(on, operation, param, signature);
141:            }
142:
143:            /**
144:             * @return A set containing the ObjectNames for the MBeans selected.
145:             * @param serverName The server name
146:             */
147:            public static java.util.Set queryNames(ObjectName on,
148:                    String serverName) throws ManagementException {
149:                ManagementRepr repr = getServerRepr(serverName);
150:                return repr.queryNames(on);
151:            }
152:
153:            /**
154:             * @return An instance of MBeanInfo allowing the retrieval of all
155:             * attributes and operations of this MBean.
156:             * @param name MBean's ObjectName
157:             * @param serverName The server name
158:             */
159:            public static MBeanInfo getMBeanInfo(ObjectName name,
160:                    String serverName) throws ManagementException {
161:                ManagementRepr repr = getServerRepr(serverName);
162:                return (MBeanInfo) repr.getMBeanInfo(name);
163:            }
164:
165:            /**
166:             * @return Context the current application context.
167:             */
168:            public static Context getContext(String serverName)
169:                    throws javax.naming.NamingException {
170:                ManagementRepr repr = getServerRepr(serverName);
171:                return repr.getContext();
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.