Source Code Cross Referenced for EafConfigMBean.java in  » J2EE » Enhydra-Application-Framework » org » enhydra » util » 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 » Enhydra Application Framework » org.enhydra.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Apr 6, 2005
003:         */
004:        package org.enhydra.util;
005:
006:        import javax.management.MBeanConstructorInfo;
007:        import javax.management.MBeanException;
008:        import javax.management.MBeanOperationInfo;
009:        import javax.management.MBeanParameterInfo;
010:        import javax.management.ObjectName;
011:        import javax.management.ReflectionException;
012:        import javax.management.RuntimeOperationsException;
013:
014:        import com.lutris.appserver.server.Application;
015:
016:        import java.lang.reflect.Method;
017:
018:        /**
019:         * EAF's Core MBean Implementation
020:         * 
021:         * @author Slobodan Vujasinovic
022:         * @author Tanja Jovanovic
023:         */
024:        public class EafConfigMBean extends AbsConfigMBean {
025:
026:            protected Application application = null;
027:
028:            public EafConfigMBean(Application application,
029:                    ObjectName objectName, String prefix, String[] includes,
030:                    String[] excludes) {
031:                init(application, objectName, prefix, includes, excludes);
032:            }
033:
034:            public void init(Application app, ObjectName objectName,
035:                    String prefix, String[] includes, String[] excludes) {
036:                this .application = app;
037:                config = application.getConfig();
038:                logChannel = application.getLogChannel();
039:                super .initConfig(objectName, prefix, includes, excludes);
040:            }
041:
042:            /**
043:             * Method returns MBean's MBeanOperationInfo Array
044:             * @return MBeanOperationInfo[]
045:             */
046:            protected MBeanOperationInfo[] getMBeanOperationsInfo() {
047:                MBeanParameterInfo[] params = null;
048:                MBeanOperationInfo[] dOperations = new MBeanOperationInfo[5];
049:                dOperations[0] = new MBeanOperationInfo("reset",
050:                        "reset(): reset  attributes to their initial values",
051:                        params, "void", MBeanOperationInfo.ACTION);
052:                dOperations[1] = new MBeanOperationInfo(
053:                        "saveAttributes",
054:                        "saveAttributes(): save the attribute values into the configuration file",
055:                        params, "void", MBeanOperationInfo.ACTION);
056:                dOperations[2] = new MBeanOperationInfo("getAppInfo",
057:                        "getAppInfo(): get application information", params,
058:                        "String", MBeanOperationInfo.ACTION);
059:
060:                params = new MBeanParameterInfo[2];
061:                params[0] = new MBeanParameterInfo(
062:                        "attKey",
063:                        "java.lang.String",
064:                        "Attribute name! Please, "
065:                                + "use UNDERLINE (_) as attribute group separator.");
066:                params[1] = new MBeanParameterInfo("attValue",
067:                        "java.lang.String", "Attribute value!");
068:
069:                dOperations[3] = new MBeanOperationInfo(
070:                        "addAttribute",
071:                        "addAttribute(String key, String value): add new application parameter",
072:                        params, "void", MBeanOperationInfo.ACTION);
073:
074:                params = new MBeanParameterInfo[1];
075:                params[0] = new MBeanParameterInfo(
076:                        "attKey",
077:                        "java.lang.String",
078:                        "Attribute name! Please, "
079:                                + "use UNDERLINE (_) as attribute group separator.");
080:
081:                dOperations[4] = new MBeanOperationInfo(
082:                        "removeAttribute",
083:                        "removeAttribute(String key): remove application parameter",
084:                        params, "void", MBeanOperationInfo.ACTION);
085:
086:                return dOperations;
087:            }
088:
089:            /**
090:             * Method returns MBean's MBeanConstructorInfo Array
091:             * @return MBeanConstructorInfo[]
092:             */
093:            protected MBeanConstructorInfo[] getMBeanConstructorInfo() {
094:                MBeanParameterInfo[] dParameters = new MBeanParameterInfo[5];
095:                dParameters[0] = new MBeanParameterInfo("application",
096:                        "com.lutris.appserver.server.Application",
097:                        "Application Object");
098:                dParameters[1] = new MBeanParameterInfo("objectName",
099:                        "javax.management.ObjectName", "MBean Name Object");
100:                dParameters[2] = new MBeanParameterInfo("prefix",
101:                        "java.lang.String", "Configuration Parameter Prefix");
102:                dParameters[3] = new MBeanParameterInfo("includes",
103:                        "java.lang.reflect.Array",
104:                        "Array of internal parameter prefixes to include");
105:                dParameters[4] = new MBeanParameterInfo("excludes",
106:                        "java.lang.reflect.Array",
107:                        "Array of internal parameter prefixes to exclude");
108:
109:                MBeanConstructorInfo[] dConstructors = new MBeanConstructorInfo[1];
110:                dConstructors[0] = new MBeanConstructorInfo("ConfigMBean",
111:                        "ConfigMBean Object Constructor", dParameters);
112:
113:                return dConstructors;
114:            }
115:
116:            /**
117:             * Allows an operation to be invoked on the Dynamic MBean.
118:             */
119:            public Object invoke(String operationName, Object params[],
120:                    String signature[]) throws MBeanException,
121:                    ReflectionException {
122:                // Check operationName is not null to avoid NullPointerException later on
123:                if (operationName == null) {
124:                    throw new RuntimeOperationsException(
125:                            new IllegalArgumentException(
126:                                    "Operation name cannot be null"),
127:                            "Cannot invoke a null operation in " + dClassName);
128:                }
129:                // Check for a recognized operation name and call the corresponding operation
130:                if (operationName.equals("reset")) {
131:                    try {
132:                        reset();
133:                    } catch (Exception e) {
134:                        throw new MBeanException(e);
135:                    }
136:                    return null;
137:                } else if (operationName.equals("saveAttributes")) {
138:                    saveAttributes();
139:                    return null;
140:                } else if (operationName.equals("addAttribute")) {
141:                    if (params != null && params.length == 2) {
142:                        addAttribute((String) params[0], (String) params[1]);
143:                    }
144:                    return null;
145:                } else if (operationName.equals("removeAttribute")) {
146:                    if (params != null && params.length == 1) {
147:                        removeAttribute((String) params[0]);
148:                    }
149:                    return null;
150:                } else if (operationName.equals("getAppInfo")) {
151:                    return getAppInfo();
152:                } else {
153:                    // unrecognized operation name:
154:                    throw new ReflectionException(new NoSuchMethodException(
155:                            operationName), "Cannot find the operation "
156:                            + operationName + " in " + dClassName);
157:                }
158:            }
159:
160:            public String getAppInfo() {
161:                String appInfo = null;
162:                Class appClass = application.getClass();
163:                try {
164:                    Method toHtmlMethod = appClass.getMethod("toHtml", null);
165:                    appInfo = (String) toHtmlMethod.invoke(application, null);
166:                } catch (Exception exc) {
167:                    appInfo = application.toString();
168:                }
169:                return appInfo;
170:            }
171:
172:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.