Source Code Cross Referenced for MethodExclusionMBeanInfoAssembler.java in  » J2EE » spring-framework-2.0.6 » org » springframework » jmx » export » assembler » 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 » spring framework 2.0.6 » org.springframework.jmx.export.assembler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2006 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.jmx.export.assembler;
018:
019:        import java.lang.reflect.Method;
020:        import java.util.Arrays;
021:        import java.util.Enumeration;
022:        import java.util.HashMap;
023:        import java.util.HashSet;
024:        import java.util.Map;
025:        import java.util.Properties;
026:        import java.util.Set;
027:
028:        import org.springframework.util.StringUtils;
029:
030:        /**
031:         * <code>AbstractReflectiveMBeanInfoAssembler</code> subclass that allows
032:         * method names to be explicitly excluded as MBean operations and attributes.
033:         * 
034:         * <p>Any method not explicitly excluded from the management interface will be exposed to
035:         * JMX. JavaBean getters and setters will automatically be exposed as JMX attributes.
036:         *
037:         * <p>You can supply an array of method names via the <code>ignoredMethods</code>
038:         * property. If you have multiple beans and you wish each bean to use a different
039:         * set of method names, then you can map bean keys (that is the name used to pass
040:         * the bean to the <code>MBeanExporter</code>) to a list of method names using the
041:         * <code>ignoredMethodMappings</code> property.
042:         *
043:         * <p>If you specify values for both <code>ignoredMethodMappings</code> and
044:         * <code>ignoredMethods</code>, Spring will attempt to find method names in the
045:         * mappings first. If no method names for the bean are found, it will use the
046:         * method names defined by <code>ignoredMethods</code>.
047:         *
048:         * @author Rob Harrop
049:         * @author Seth Ladd
050:         * @since 1.2.5
051:         * @see #setIgnoredMethods
052:         * @see #setIgnoredMethodMappings
053:         * @see InterfaceBasedMBeanInfoAssembler
054:         * @see SimpleReflectiveMBeanInfoAssembler
055:         * @see MethodNameBasedMBeanInfoAssembler
056:         * @see org.springframework.jmx.export.MBeanExporter
057:         */
058:        public class MethodExclusionMBeanInfoAssembler extends
059:                AbstractConfigurableMBeanInfoAssembler {
060:
061:            private Set ignoredMethods;
062:
063:            private Map ignoredMethodMappings;
064:
065:            /**
066:             * Set the array of method names to be <b>ignored</b> when creating the management info.
067:             * <p>These method names will be used for a bean if no entry corresponding to
068:             * that bean is found in the <code>ignoredMethodsMappings</code> property.
069:             * @see #setIgnoredMethodMappings(java.util.Properties)
070:             */
071:            public void setIgnoredMethods(String[] ignoredMethodNames) {
072:                this .ignoredMethods = new HashSet(Arrays
073:                        .asList(ignoredMethodNames));
074:            }
075:
076:            /**
077:             * Set the mappings of bean keys to a comma-separated list of method names.
078:             * <p>These method names are <b>ignored</b> when creating the management interface.
079:             * <p>The property key must match the bean key and the property value must match
080:             * the list of method names. When searching for method names to ignore for a bean,
081:             * Spring will check these mappings first.
082:             */
083:            public void setIgnoredMethodMappings(Properties mappings) {
084:                this .ignoredMethodMappings = new HashMap();
085:                for (Enumeration en = mappings.keys(); en.hasMoreElements();) {
086:                    String beanKey = (String) en.nextElement();
087:                    String[] methodNames = StringUtils
088:                            .commaDelimitedListToStringArray(mappings
089:                                    .getProperty(beanKey));
090:                    this .ignoredMethodMappings.put(beanKey, new HashSet(Arrays
091:                            .asList(methodNames)));
092:                }
093:            }
094:
095:            protected boolean includeReadAttribute(Method method, String beanKey) {
096:                return isNotIgnored(method, beanKey);
097:            }
098:
099:            protected boolean includeWriteAttribute(Method method,
100:                    String beanKey) {
101:                return isNotIgnored(method, beanKey);
102:            }
103:
104:            protected boolean includeOperation(Method method, String beanKey) {
105:                return isNotIgnored(method, beanKey);
106:            }
107:
108:            /**
109:             * Determine whether the given method is supposed to be included,
110:             * that is, not configured as to be ignored.
111:             * @param method the operation method
112:             * @param beanKey the key associated with the MBean in the beans map
113:             * of the <code>MBeanExporter</code>
114:             */
115:            protected boolean isNotIgnored(Method method, String beanKey) {
116:                if (this .ignoredMethodMappings != null) {
117:                    Set methodNames = (Set) this .ignoredMethodMappings
118:                            .get(beanKey);
119:                    if (methodNames != null) {
120:                        return !methodNames.contains(method.getName());
121:                    }
122:                }
123:                if (this .ignoredMethods != null) {
124:                    return !this .ignoredMethods.contains(method.getName());
125:                }
126:                return true;
127:            }
128:
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.