commons-modeler-2.0.1-src/ 40755 0 0 0 10636604104 12431 5ustar 0 0 commons-modeler-2.0.1-src/src/ 40755 0 0 0 10636604104 13220 5ustar 0 0 commons-modeler-2.0.1-src/src/conf/ 40755 0 0 0 10636604104 14145 5ustar 0 0 commons-modeler-2.0.1-src/src/java/ 40755 0 0 0 10636604104 14141 5ustar 0 0 commons-modeler-2.0.1-src/src/java/org/ 40755 0 0 0 10636604104 14730 5ustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/ 40755 0 0 0 10636604104 16151 5ustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/commons/ 40755 0 0 0 10636604104 17624 5ustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/ 40755 0 0 0 10636604104 21253 5ustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/ant/ 40755 0 0 0 10636604104 22035 5ustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/mbeans/ 40755 0 0 0 10636604104 22520 5ustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/ 40755 0 0 0 10636604104 22723 5ustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/util/ 40755 0 0 0 10636604104 22230 5ustar 0 0 commons-modeler-2.0.1-src/src/test/ 40755 0 0 0 10636604104 14177 5ustar 0 0 commons-modeler-2.0.1-src/src/test/org/ 40755 0 0 0 10636604104 14766 5ustar 0 0 commons-modeler-2.0.1-src/src/test/org/apache/ 40755 0 0 0 10636604104 16207 5ustar 0 0 commons-modeler-2.0.1-src/src/test/org/apache/commons/ 40755 0 0 0 10636604104 17662 5ustar 0 0 commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/ 40755 0 0 0 10636604104 21311 5ustar 0 0 commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/demo/ 40755 0 0 0 10636604104 22235 5ustar 0 0 commons-modeler-2.0.1-src/xdocs/ 40755 0 0 0 10636604104 13551 5ustar 0 0 commons-modeler-2.0.1-src/xdocs/images/ 40755 0 0 0 10636604104 15016 5ustar 0 0 commons-modeler-2.0.1-src/xdocs/style/ 40755 0 0 0 10636604104 14711 5ustar 0 0 commons-modeler-2.0.1-src/build.properties.default100644 0 0 5225 10636604104 17372 0ustar 0 0 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ----- Proxy setup ----- #proxy.host=proxy.domain #proxy.port=8080 #proxy.use=on # ----- CVS root for the jakarta repositories ------ cvsroot=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" # ----- Default Base Path for Dependent Packages ----- base.path=/usr/share/java #base.path=../repository # -------------------------------------------------- # OPTIONAL LIBRARIES # -------------------------------------------------- # ----- Commons Digester, version 1.4 or later ----- commons-digester.home=${base.path}/commons-digester-1.4.1 commons-digester.lib=${commons-digester.home} commons-digester.jar=${commons-digester.lib}/commons-digester.jar commons-digester.loc=http://www.apache.org/dist/jakarta/commons/digester/binaries/commons-digester-1.4.1.tar.gz # -------------------------------------------------- # REQUIRED LIBRARIES # -------------------------------------------------- # ----- Commons Logging, version 1.0.1 or later ----- commons-logging.home=${base.path}/commons-logging-1.0.3 commons-logging.lib=${commons-logging.home} commons-logging-api.jar=${commons-logging.lib}/commons-logging-api.jar commons-logging.jar=${commons-logging.lib}/commons-logging.jar commons-logging.loc=http://www.apache.org/dist/jakarta/commons/logging/binaries/commons-logging-1.0.3.tar.gz # ----- Java Management Extensions (JMX), JMX RI 1.0.1 or later or MX4J 1.1 or later ----- jmx.home=${base.path}/mx4j-1.1.1 jmx.lib=${jmx.home}/lib jmx.jar=${jmx.lib}/mx4j-jmx.jar jmx-tools.jar=${jmx.lib}/mx4j-tools.jar jmx.loc=http://telia.dl.sourceforge.net/sourceforge/mx4j/mx4j-1.1.1.tar.gz # ----- JUnit Unit Test Suite, version 3.7 or later ----- junit.home=${base.path}/junit3.7 junit.lib=${junit.home} junit.jar=${junit.lib}/junit.jar junit.loc=http://telia.dl.sourceforge.net/sourceforge/junit/junit3.7.zip commons-modeler-2.0.1-src/build.properties.sample100644 0 0 3510 10636604104 17222 0ustar 0 0 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # build.properties.sample - Sample build.properties for "modeler" # Base properties for expansion below commons.home=../../jakarta-commons sandbox.home=../../jakarta-commons-sandbox jaxp.home=/usr/local/jaxp-1.1 junit.home=/usr/local/junit3.7 jmx.home=/usr/local/jmx-ri_1.0.1/jmx # Derived home directories digester.home=${commons.home}/digester logging.home=${commons.home}/logging # Jakarta JAR files commons-digester.jar=${digester.home}/dist/commons-digester.jar commons-logging.jar=${logging.home}/dist/commons-logging.jar # JMX libraries # jmx.jar must contain the JMX classes and interfaces, as well as the # server implementation. Any JMX compliant implementation can be used. jmx.jar=${jmx.home}/lib/jmxri.jar # jmxtools.jar from the JMX RI is only used for the demonstration example. jmxtools.jar=${jmx.home}/lib/jmxtools.jar # External packages jaxp.jaxp.jar=${jaxp.home}/jaxp.jar jaxp.parser.jar=${jaxp.home}/crimson.jar jaxp.xalan.jar=${jaxp.home}/xalan.jar junit.jar=${junit.home}/junit.jar commons-modeler-2.0.1-src/build.xml100644 0 0 44035 10636604104 14375 0ustar 0 0 commons-modeler-2.0.1-src/LICENSE.txt100644 0 0 26450 10636604104 14400 0ustar 0 0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. commons-modeler-2.0.1-src/maven.xml100644 0 0 13764 10636604104 14411 0ustar 0 0 commons-modeler-2.0.1-src/NOTICE.txt100644 0 0 275 10636604104 14234 0ustar 0 0 Apache Jakarta Commons Modeler Copyright 2001-2007 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). commons-modeler-2.0.1-src/project.properties100644 0 0 4454 10636604104 16321 0ustar 0 0 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. maven.repo.remote=http://repo1.maven.org/maven #maven.checkstyle.properties = checkstyle.xml # uncomment the next line to work in offline mode (no jar download & no linkcheck) #maven.mode.online= maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory maven.changelog.type=date maven.changelog.date=2003-08-10 maven.changelog.svn.baseurl=http://svn.apache.org/repos/asf maven.javadoc.author=false maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api # Jar Manifest Additional Attributes maven.jar.manifest.attributes.list=Implementation-Vendor-Id,X-Compile-Source-JDK,X-Compile-Target-JDK maven.jar.manifest.attribute.Implementation-Vendor-Id=org.apache maven.jar.manifest.attribute.X-Compile-Source-JDK=${maven.compile.source} maven.jar.manifest.attribute.X-Compile-Target-JDK=${maven.compile.target} maven.xdoc.date=left maven.xdoc.version=${pom.currentVersion} maven.xdoc.developmentProcessUrl=http://jakarta.apache.org/commons/charter.html maven.xdoc.poweredby.image=maven-feather.png maven.compile.debug=on maven.compile.deprecation=off maven.compile.optimize=off maven.jarResources.basedir=src/java maven.jar.excludes=**/package.html maven.junit.fork=true maven.junit.sysproperties=org.xml.sax.driver org.xml.sax.driver=org.apache.xerces.parsers.SAXParser # Make the source distro unzip to a different directory maven.dist.src.assembly.dir=${maven.dist.assembly.dir}/src/${maven.final.name}-src clover.excludes=**/Test*.java maven.compile.target=1.3 maven.compile.source=1.3 commons-modeler-2.0.1-src/project.xml100644 0 0 17511 10636604104 14743 0ustar 0 0 3 Commons Modeler commons-modeler commons-modeler 2.0.1 2002 Commons Modeler Commons Modeler /images/modeler-logo-white.png http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/ org.apache.commons.${pom.artifactId.substring(8)} The Apache Software Foundation http://jakarta.apache.org http://jakarta.apache.org/images/original-jakarta-logo.gif The Apache Software License, Version 2.0 /LICENSE.txt repo jakarta http://issues.apache.org/jira/browse/${pom.artifactId.substring(8).toUpperCase()} people.apache.org /www/jakarta.apache.org/commons/${pom.artifactId.substring(8)}/ /www/jakarta.apache.org/builds/jakarta-commons/${pom.artifactId.substring(8)}/ scm:svn:http://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk http://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk Commons Dev List commons-dev-subscribe@jakarta.apache.org commons-dev-unsubscribe@jakarta.apache.org http://mail-archives.apache.org/mod_mbox/jakarta-commons-dev/ Commons User List commons-user-subscribe@jakarta.apache.org commons-user-unsubscribe@jakarta.apache.org http://mail-archives.apache.org/mod_mbox/jakarta-commons-user/ Craig McClanahan craigmcc craigmcc@apache.org Apache Yoav Shapira yoavs yoavs@apache.org Apache Bill Barker billbarker billbarker@apache.org Apache Davanum Srinivas dims dims@apache.org Apache commons-digester commons-digester 1.4.1 http://jakarta.apache.org/commons/digester/ commons-logging commons-logging-api 1.0.4 http://jakarta.apache.org/commons/logging/ mx4j mx4j-jmx 2.1.1 http://mx4j.sourceforge.net/ provided xml-apis xml-apis 2.0.2 provided junit junit 3.7 http://www.junit.org/ test ant ant 1.5 http://ant.apache.org/ true maven maven-changelog-plugin 1.9.1 http://maven.apache.org/maven-1.x/plugins/changelog/ plugin <strong>Site Only</strong> - v1.9.1 (minimum) required for building the Site documentation. maven maven-xdoc-plugin 1.9.2 http://maven.apache.org/maven-1.x/plugins/xdoc/ plugin <strong>Site Only</strong> - v1.9.2 (minimum) required for building the Site documentation. commons-dev@jakarta.apache.org src/java src/test **/*TestCase.java ${pom.build.unitTestSourceDirectory} **/*.xml . META-INF NOTICE.txt src/java/org/apache/commons/modeler/ant META-INF ant.properties src/java **/ant.properties **/mbeans-descriptors.dtd maven-changelog-plugin maven-changes-plugin maven-javadoc-plugin maven-jdepend-plugin maven-junit-report-plugin maven-jxr-plugin maven-license-plugin maven-tasklist-plugin commons-modeler-2.0.1-src/RELEASE-NOTES.txt100644 0 0 1721 10636604104 15236 0ustar 0 0 $Id: RELEASE-NOTES.txt 549548 2007-06-21 17:03:51Z niallp $ Commons Modeler Package Version 2.0.1 Release Notes INTRODUCTION: ============ This document contains the release notes for this version of the Commons Modeler package, and highlights changes since the previous version. For more information on Jakarta Commons Modeler, see o http://jakarta.apache.org/commons/modeler/ Compatibility with 2.0 ====================== Modeler 2.0.1 is binary and source compatible with Modeler 2.0 BUG REPORTS ADDRESSED: ===================== o MODELER-20 ant jar in trunk fails o MODELER-21 MbeansDescriptorsDigesterSource.java is never build if just setting commons-digester.jar property in build.properties o MODELER-22 ant.properties is missing from the Modeler jar o MODELER-23 mbeans-descriptors.dtd is missing from the Modeler jar and binary distro commons-modeler-2.0.1-src/src/conf/MANIFEST.MF100644 0 0 457 10636604104 15662 0ustar 0 0 Manifest-version: 1.1 Extension-Name: org.apache.commons.modeler Specification-Title: Commons Modeler Specification-Vendor: Apache Software Foundation Specification-Version: 2.0 Implementation-Vendor-Id: org.apache Implementation-Vendor: Apache Software Foundation Implementation-Version: 2.0.1 commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/ant/ant.properties100644 0 0 2626 10636604104 25040 0ustar 0 0 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. modeler=org.apache.commons.modeler.ant.ModelerTask MLET=org.apache.commons.modeler.ant.MLETTask mbean=org.apache.commons.modeler.ant.MLETTask jmx-attribute=org.apache.commons.modeler.ant.JmxSet jmx-operation=org.apache.commons.modeler.ant.JmxInvoke mbeans-descriptors=org.apache.commons.modeler.ant.RegistryTask jmx-service=org.apache.commons.modeler.ant.ServiceTask service=org.apache.commons.modeler.ant.ServiceTask # old names, to be removed jmxSet=org.apache.commons.modeler.ant.JmxSet jmx=org.apache.commons.modeler.ant.JmxInvoke modelerRegistry=org.apache.commons.modeler.ant.RegistryTask commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/ant/Arg.java100644 0 0 2410 10636604104 23503 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.ant; /** */ public class Arg { String type; String value; public void setType( String type) { this.type=type; } public void setValue( String value ) { this.value=value; } public void addText( String text ) { this.value=text; } public String getValue() { return value; } public String getType() { return type; } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/ant/JmxInvoke.java100644 0 0 5514 10636604104 24714 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.ant; import java.util.Vector; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import org.apache.tools.ant.Task; /** * Set mbean properties. * */ public class JmxInvoke extends Task { String objectName; String method; Vector args; public JmxInvoke() { } public void setObjectName(String name) { this.objectName = name; } public void setOperation(String method) { this.method = method; } public void execute() { try { MBeanServer server=(MBeanServer)project.getReference("jmx.server"); if (server == null) { if( MBeanServerFactory.findMBeanServer(null).size() > 0 ) { server=(MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0); } else { System.out.println("Creating mbean server"); server=MBeanServerFactory.createMBeanServer(); } project.addReference("jmx.server", server); } ObjectName oname=new ObjectName(objectName); if( args==null ) { server.invoke(oname, method, null, null); } else { // XXX Use the loader ref, if any Object argsA[]=new Object[ args.size()]; String sigA[]=new String[args.size()]; for( int i=0; i, with few * ant-specific extensions. * * A separate classloader can be used, the mechanism is similar with * what taskdef is using. * * Note that mlet will use the arguments in the constructor. * * */ public class MLETTask extends Task { private static Log log = LogFactory.getLog(MLETTask.class); String code; String archive; String codebase; String objectName; ObjectName oname; List args=new ArrayList(); List attributes=new ArrayList(); // ant specific String loaderRef; // class loader ref public MLETTask() { } public void addArg(Arg arg ) { args.add(arg); } public void addAttribute( JmxSet arg ) { attributes.add( arg ); } public void setCode(String code) { this.code = code; } public void setArchive(String archive) { this.archive = archive; } public void setCodebase(String codebase) { this.codebase = codebase; } public void setName(String name) { this.objectName = name; } MBeanServer server; public MBeanServer getMBeanServer() { if( server!= null ) return server; server=(MBeanServer)project.getReference("jmx.server"); if (server != null) return server; try { if( MBeanServerFactory.findMBeanServer(null).size() > 0 ) { server=(MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0); } else { server=MBeanServerFactory.createMBeanServer(); // Register a loader that will be find ant classes. ObjectName defaultLoader= new ObjectName("modeler-ant", "loader", "ant"); MLet mlet=new MLet( new URL[0], this.getClass().getClassLoader()); server.registerMBean(mlet, defaultLoader); if( log.isDebugEnabled()) log.debug("Creating mbean server and loader "+ mlet + " " + this.getClass().getClassLoader()); } project.addReference("jmx.server", server); // Create the MLet object } catch( JMException ex ) { log.error("Error creating server", ex); } if( log.isDebugEnabled()) log.debug("Using Mserver " + server ); return server; } boolean modeler=false; public void setModeler(boolean modeler) { this.modeler = modeler; } protected void bindJmx(String objectName, String code, String arg0, List args) throws Exception { MBeanServer server=getMBeanServer(); oname=new ObjectName( objectName ); if( modeler ) { Arg codeArg=new Arg(); codeArg.setType("java.lang.String"); codeArg.setValue( code ); if( args==null) args=new ArrayList(); args.add(0, codeArg); code="org.apache.commons.modeler.BaseModelMBean"; } Object argsA[]=new Object[ args.size()]; String sigA[]=new String[args.size()]; for( int i=0; i Package Documentation for org.apache.commons.modeler.ant Package Ant Tasks for Commons Modeler Integration.
[mbean / MLET] [jmx-attribute] [jmx-operation] [mbeans-descriptors]

The commons-modeler package includes a set of custom tasks for the Ant build tool, which lets you use Ant to automate the loading of MBean descriptor information, dynamic creation of JMX MBeans, and calling operations and attribute setters on those MBeans. If your application can assemble itself based JMX Mbean operations, this means that you can now use Ant scripts to manage the lifecycle of your application's components, without having to write Java code for this purpose.

To use these tasks, you must copy commons-modeler.jar into the lib subdirectory of your Ant installation, or make sure that it is on the CLASSPATH being used to execute Ant.


mbean / MLET


jmx-attribute

Description

Locates the JMX MBean identified by the objectName attribute, and calls its setAttribute() operation, passing in the attribute name specified by attribute and the value specified by value, after converting the value to the type specified by type.

Parameters

Attribute Description Required
attribute

Name of the attribute for which the setAttribute() method will be called.

Yes
objectName The JMX ObjectName that identifies the MBean whose setAttribute() method will be called. Yes
type

The data type of the attribute value to be set. If not specified, will be assumed to be a String. Otherwise, must be one of ObjectName, boolean, or int.

No
value

String representation of the value to which this attribute will be set. Either value or valueRef must be specified.

No
valueRef

Indirect pointer to a project reference containing the value to which this attribute will be set. Either value or valueRef must be specified.

No

jmx-operation


mbeans-descriptors


commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/ant/RegistryTask.java100644 0 0 5737 10636604104 25444 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.ant; import java.io.File; import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.net.URL; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.modeler.ManagedBean; import org.apache.commons.modeler.Registry; import org.apache.tools.ant.BuildException; /** * Load descriptors into registry. * * @author Costin Manolache */ public final class RegistryTask { private static Log log = LogFactory.getLog(RegistryTask.class); public RegistryTask() { } String resource; String file; String type="MbeansDescriptorsDOMSource"; /** Set the resource type that will be loaded * * @param type */ public void setType( String type ) { this.type=type; } public void setFile( String file ) { this.file=file; } public void setResource( String res ) { this.resource=res; } String outFile; public void setOut( String outFile ) { this.outFile=outFile; } public void execute() throws Exception { URL url=null; if( resource != null ) { url=this.getClass().getClassLoader().getResource(resource); } else if( file != null ) { File f=new File(file); url=new URL("file", null, f.getAbsolutePath()); } else { throw new BuildException( "Resource or file attribute required"); } Registry.getRegistry().loadDescriptors( type, url, null); if( outFile !=null ) { FileOutputStream fos=new FileOutputStream(outFile); ObjectOutputStream oos=new ObjectOutputStream(fos); Registry reg=Registry.getRegistry(); String beans[]=reg.findManagedBeans(); ManagedBean mbeans[]=new ManagedBean[beans.length]; for( int i=0; iInternal configuration information for an Attribute * descriptor.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class AttributeInfo extends FeatureInfo implements Serializable { static final long serialVersionUID = -2511626862303972143L; // ----------------------------------------------------- Instance Variables /** * The ModelMBeanAttributeInfo object that corresponds * to this AttributeInfo instance. */ protected transient ModelMBeanAttributeInfo info = null; protected String displayName = null; protected String getMethod = null; protected String setMethod = null; protected transient Method getMethodObj = null; protected transient Method setMethodObj = null; protected boolean readable = true; protected boolean writeable = true; protected boolean is = false; protected String type = null; protected String persist; protected String defaultStringValue; // ------------------------------------------------------------- Properties /** * Override the description property setter. * * @param description The new description */ public void setDescription(String description) { super.setDescription(description); this.info = null; } /** * Override the name property setter. * * @param name The new name */ public void setName(String name) { super.setName(name); this.info = null; } /** * The display name of this attribute. */ public String getDisplayName() { return (this.displayName); } public void setDisplayName(String displayName) { this.displayName = displayName; } /** * The name of the property getter method, if non-standard. */ public String getGetMethod() { return (this.getMethod); } public void setGetMethod(String getMethod) { this.getMethod = getMethod; this.info = null; } public Method getGetMethodObj() { return getMethodObj; } public void setGetMethodObj(Method getMethodObj) { this.getMethodObj = getMethodObj; } public Method getSetMethodObj() { return setMethodObj; } public void setSetMethodObj(Method setMethodObj) { this.setMethodObj = setMethodObj; } /** * Is this a boolean attribute with an "is" getter? */ public boolean isIs() { return (this.is); } public void setIs(boolean is) { this.is = is; this.info = null; } /** * Is this attribute readable by management applications? */ public boolean isReadable() { return (this.readable); } public void setReadable(boolean readable) { this.readable = readable; this.info = null; } /** * The name of the property setter method, if non-standard. */ public String getSetMethod() { return (this.setMethod); } public void setSetMethod(String setMethod) { this.setMethod = setMethod; this.info = null; } /** * The fully qualified Java class name of this attribute. */ public String getType() { return (this.type); } public void setType(String type) { this.type = type; this.info = null; } /** * Is this attribute writeable by management applications? */ public boolean isWriteable() { return (this.writeable); } public void setWriteable(boolean writeable) { this.writeable = writeable; this.info = null; } /** Persistence policy. * All persistent attributes should have this attribute set. * Valid values: * ??? */ public String getPersist() { return persist; } public void setPersist(String persist) { this.persist = persist; } /** Default value. If set, it can provide info to the user and * it can be used by persistence mechanism to generate a more compact * representation ( a value may not be saved if it's default ) */ public String getDefault() { return defaultStringValue; } public void setDefault(String defaultStringValue) { this.defaultStringValue = defaultStringValue; } // --------------------------------------------------------- Public Methods /** * Create and return a ModelMBeanAttributeInfo object that * corresponds to the attribute described by this instance. */ public ModelMBeanAttributeInfo createAttributeInfo() { // Return our cached information (if any) if (info != null) return (info); if((getMethodObj != null) || (setMethodObj != null) ) { try { info=new ModelMBeanAttributeInfo(getName(), getDescription(), getMethodObj, setMethodObj); return info; } catch( Exception ex) { ex.printStackTrace(); } } // Create and return a new information object info = new ModelMBeanAttributeInfo (getName(), getType(), getDescription(), isReadable(), isWriteable(), false); Descriptor descriptor = info.getDescriptor(); if (getDisplayName() != null) descriptor.setField("displayName", getDisplayName()); if (isReadable()) { if (getGetMethod() != null) descriptor.setField("getMethod", getGetMethod()); else descriptor.setField("getMethod", getMethodName(getName(), true, isIs())); } if (isWriteable()) { if (getSetMethod() != null) descriptor.setField("setMethod", getSetMethod()); else descriptor.setField("setMethod", getMethodName(getName(), false, false)); } addFields(descriptor); info.setDescriptor(descriptor); return (info); } /** * Return a string representation of this attribute descriptor. */ public String toString() { StringBuffer sb = new StringBuffer("AttributeInfo["); sb.append("name="); sb.append(name); sb.append(", description="); sb.append(description); if (!readable) { sb.append(", readable="); sb.append(readable); } sb.append(", type="); sb.append(type); if (!writeable) { sb.append(", writeable="); sb.append(writeable); } sb.append("]"); return (sb.toString()); } // -------------------------------------------------------- Private Methods /** * Create and return the name of a default property getter or setter * method, according to the specified values. * * @param name Name of the property itself * @param getter Do we want a get method (versus a set method)? * @param is If returning a getter, do we want the "is" form? */ private String getMethodName(String name, boolean getter, boolean is) { StringBuffer sb = new StringBuffer(); if (getter) { if (is) sb.append("is"); else sb.append("get"); } else sb.append("set"); sb.append(Character.toUpperCase(name.charAt(0))); sb.append(name.substring(1)); return (sb.toString()); } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/BaseAttributeFilter.java100644 0 0 10775 10636604104 26151 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.util.HashSet; import javax.management.AttributeChangeNotification; import javax.management.Notification; import javax.management.NotificationFilter; /** *

Implementation of NotificationFilter for attribute change * notifications. This class is used by BaseModelMBean to * construct attribute change notification event filters when a filter is not * supplied by the application.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class BaseAttributeFilter implements NotificationFilter { // ----------------------------------------------------------- Constructors /** * Construct a new filter that accepts only the specified attribute * name. * * @param name Name of the attribute to be accepted by this filter, or * null to accept all attribute names */ public BaseAttributeFilter(String name) { super(); if (name != null) addAttribute(name); } // ----------------------------------------------------- Instance Variables /** * The set of attribute names that are accepted by this filter. If this * list is empty, all attribute names are accepted. */ private HashSet names = new HashSet(); // --------------------------------------------------------- Public Methods /** * Add a new attribute name to the set of names accepted by this filter. * * @param name Name of the attribute to be accepted */ public void addAttribute(String name) { synchronized (names) { names.add(name); } } /** * Clear all accepted names from this filter, so that it will accept * all attribute names. */ public void clear() { synchronized (names) { names.clear(); } } /** * Return the set of names that are accepted by this filter. If this * filter accepts all attribute names, a zero length array will be * returned. */ public String[] getNames() { synchronized (names) { return ((String[]) names.toArray(new String[names.size()])); } } /** *

Test whether notification enabled for this event. * Return true if:

*
    *
  • This is an attribute change notification
  • *
  • Either the set of accepted names is empty (implying that all * attribute names are of interest) or the set of accepted names * includes the name of the attribute in this notification
  • *
*/ public boolean isNotificationEnabled(Notification notification) { if (notification == null) return (false); if (!(notification instanceof AttributeChangeNotification)) return (false); AttributeChangeNotification acn = (AttributeChangeNotification) notification; if (!AttributeChangeNotification.ATTRIBUTE_CHANGE.equals(acn.getType())) return (false); synchronized (names) { if (names.size() < 1) return (true); else return (names.contains(acn.getAttributeName())); } } /** * Remove an attribute name from the set of names accepted by this * filter. * * @param name Name of the attribute to be removed */ public void removeAttribute(String name) { synchronized (names) { names.remove(name); } } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/BaseModelMBean.java100644 0 0 147701 10636604104 25023 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import javax.management.Attribute; import javax.management.AttributeChangeNotification; import javax.management.AttributeList; import javax.management.AttributeNotFoundException; import javax.management.Descriptor; import javax.management.DynamicMBean; import javax.management.InstanceNotFoundException; import javax.management.InvalidAttributeValueException; import javax.management.ListenerNotFoundException; import javax.management.MBeanException; import javax.management.MBeanInfo; import javax.management.MBeanNotificationInfo; import javax.management.MBeanRegistration; import javax.management.MBeanServer; import javax.management.Notification; import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectName; import javax.management.ReflectionException; import javax.management.RuntimeErrorException; import javax.management.RuntimeOperationsException; import javax.management.ServiceNotFoundException; import javax.management.modelmbean.DescriptorSupport; import javax.management.modelmbean.InvalidTargetObjectTypeException; import javax.management.modelmbean.ModelMBean; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; import javax.management.modelmbean.ModelMBeanInfoSupport; import javax.management.modelmbean.ModelMBeanNotificationInfo; import javax.management.modelmbean.ModelMBeanOperationInfo; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.modeler.modules.ModelerSource; // TODO: enable ant-like substitutions ? ( or at least discuss it ) /** *

Basic implementation of the ModelMBean interface, which * supports the minimal requirements of the interface contract.

* *

This can be used directly to wrap an existing java bean, or inside * an mlet or anywhere an MBean would be used. The String parameter * passed to the constructor will be used to construct an instance of the * real object that we wrap. * * Limitations: *

    *
  • Only managed resources of type objectReference are * supportd.
  • *
  • Caching of attribute values and operation results is not supported. * All calls to invoke() are immediately executed.
  • *
  • Logging (under control of descriptors) is not supported.
  • *
  • Persistence of MBean attributes and operations is not supported.
  • *
  • All classes referenced as attribute types, operation parameters, or * operation return values must be one of the following: *
      *
    • One of the Java primitive types (boolean, byte, char, double, * float, integer, long, short). Corresponding value will be wrapped * in the appropriate wrapper class automatically.
    • *
    • Operations that return no value should declare a return type of * void.
    • *
    *
  • Attribute caching is not supported
  • *
* * @author Craig R. McClanahan * @author Costin Manolache * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class BaseModelMBean implements ModelMBean, MBeanRegistration { private static Log log = LogFactory.getLog(BaseModelMBean.class); // ----------------------------------------------------------- Constructors /** * Construct a ModelMBean with default * ModelMBeanInfo information. * * @exception MBeanException if the initializer of an object * throws an exception * @exception RuntimeOperationsException if an IllegalArgumentException * occurs */ public BaseModelMBean() throws MBeanException, RuntimeOperationsException { super(); if( log.isDebugEnabled()) log.debug("default constructor"); setModelMBeanInfo(createDefaultModelMBeanInfo()); } /** * Construct a ModelMBean associated with the specified * ModelMBeanInfo information. * * @param info ModelMBeanInfo for this MBean * * @exception MBeanException if the initializer of an object * throws an exception * @exception RuntimeOperationsException if an IllegalArgumentException * occurs */ public BaseModelMBean(ModelMBeanInfo info) throws MBeanException, RuntimeOperationsException { // XXX should be deprecated - just call setInfo super(); setModelMBeanInfo(info); if( log.isDebugEnabled()) log.debug("ModelMBeanInfo constructor"); } /** Construct a ModelMBean of a specified type. * The type can be a class name or the key used in one of the descriptors. * * If no descriptor is available, we'll first try to locate one in * the same package with the class, then use introspection. * * The mbean resource will be created. * * @param type Class name or the type key used in the descriptor. * @throws MBeanException * @throws RuntimeOperationsException */ public BaseModelMBean( String type ) throws MBeanException, RuntimeOperationsException { try { // This constructor is used from , it should create // the resource setModeledType(type); } catch( Throwable ex ) { log.error( "Error creating mbean ", ex); } } public BaseModelMBean( String type, ModelerSource source ) throws MBeanException, RuntimeOperationsException { try { setModeledType(type); } catch( Throwable ex ) { log.error( "Error creating mbean ", ex); } this.source=source; } // ----------------------------------------------------- Instance Variables /** * Notification broadcaster for attribute changes. */ protected BaseNotificationBroadcaster attributeBroadcaster = null; /** Registry we are associated with */ protected Registry registry=null; /** * Notification broadcaster for general notifications. */ protected BaseNotificationBroadcaster generalBroadcaster = null; protected ObjectName oname=null; /** * The ModelMBeanInfo object that controls our activity. */ protected ModelMBeanInfo info = null; /** * The managed resource this MBean is associated with (if any). */ protected Object resource = null; protected String resourceType = null; /** Source object used to read this mbean. Can be used to * persist the mbean */ protected ModelerSource source=null; /** Attribute values. XXX That can be stored in the value Field */ protected HashMap attributes=new HashMap(); // --------------------------------------------------- DynamicMBean Methods static final Object[] NO_ARGS_PARAM=new Object[0]; static final Class[] NO_ARGS_PARAM_SIG=new Class[0]; // key: attribute val: getter method private Hashtable getAttMap=new Hashtable(); // key: attribute val: setter method private Hashtable setAttMap=new Hashtable(); // key: operation val: invoke method private Hashtable invokeAttMap=new Hashtable(); /** * Obtain and return the value of a specific attribute of this MBean. * * @param name Name of the requested attribute * * @exception AttributeNotFoundException if this attribute is not * supported by this MBean * @exception MBeanException if the initializer of an object * throws an exception * @exception ReflectionException if a Java reflection exception * occurs when invoking the getter */ public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (name == null) throw new RuntimeOperationsException (new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); if( (resource instanceof DynamicMBean) && ! ( resource instanceof BaseModelMBean )) { return ((DynamicMBean)resource).getAttribute(name); } // Extract the method from cache Method m=(Method)getAttMap.get( name ); if( m==null ) { // Look up the actual operation to be used ModelMBeanAttributeInfo attrInfo = info.getAttribute(name); if (attrInfo == null) throw new AttributeNotFoundException(" Cannot find attribute " + name); Descriptor attrDesc = attrInfo.getDescriptor(); if (attrDesc == null) throw new AttributeNotFoundException("Cannot find attribute " + name + " descriptor"); String getMethod = (String) attrDesc.getFieldValue("getMethod"); if (getMethod == null) throw new AttributeNotFoundException("Cannot find attribute " + name + " get method name"); Object object = null; NoSuchMethodException exception = null; try { object = this; m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG); } catch (NoSuchMethodException e) { exception = e;; } if( m== null && resource != null ) { try { object = resource; m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG); exception=null; } catch (NoSuchMethodException e) { exception = e; } } if( exception != null ) throw new ReflectionException(exception, "Cannot find getter method " + getMethod); getAttMap.put( name, m ); } Object result = null; try { Class declaring=m.getDeclaringClass(); // workaround for catalina weird mbeans - the declaring class is BaseModelMBean. // but this is the catalina class. if( declaring.isAssignableFrom(this.getClass()) ) { result = m.invoke(this, NO_ARGS_PARAM ); } else { result = m.invoke(resource, NO_ARGS_PARAM ); } } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t == null) t = e; if (t instanceof RuntimeException) throw new RuntimeOperationsException ((RuntimeException) t, "Exception invoking method " + name); else if (t instanceof Error) throw new RuntimeErrorException ((Error) t, "Error invoking method " + name); else throw new MBeanException (e, "Exception invoking method " + name); } catch (Exception e) { throw new MBeanException (e, "Exception invoking method " + name); } // Return the results of this method invocation // FIXME - should we validate the return type? return (result); } /** * Obtain and return the values of several attributes of this MBean. * * @param names Names of the requested attributes */ public AttributeList getAttributes(String names[]) { // Validate the input parameters if (names == null) throw new RuntimeOperationsException (new IllegalArgumentException("Attribute names list is null"), "Attribute names list is null"); // Prepare our response, eating all exceptions AttributeList response = new AttributeList(); for (int i = 0; i < names.length; i++) { try { response.add(new Attribute(names[i],getAttribute(names[i]))); } catch (Exception e) { ; // Not having a particular attribute in the response ; // is the indication of a getter problem } } return (response); } /** * Return the MBeanInfo object for this MBean. */ public MBeanInfo getMBeanInfo() { // XXX Why do we have to clone ? if( info== null ) return null; return ((MBeanInfo) info.clone()); } /** * Invoke a particular method on this MBean, and return any returned * value. * *

IMPLEMENTATION NOTE - This implementation will * attempt to invoke this method on the MBean itself, or (if not * available) on the managed resource object associated with this * MBean.

* * @param name Name of the operation to be invoked * @param params Array containing the method parameters of this operation * @param signature Array containing the class names representing * the signature of this operation * * @exception MBeanException if the initializer of an object * throws an exception * @exception ReflectioNException if a Java reflection exception * occurs when invoking a method */ public Object invoke(String name, Object params[], String signature[]) throws MBeanException, ReflectionException { if( (resource instanceof DynamicMBean) && ! ( resource instanceof BaseModelMBean )) { return ((DynamicMBean)resource).invoke(name, params, signature); } // Validate the input parameters if (name == null) throw new RuntimeOperationsException (new IllegalArgumentException("Method name is null"), "Method name is null"); if( log.isDebugEnabled()) log.debug("Invoke " + name); MethodKey mkey = new MethodKey(name, signature); Method method=(Method)invokeAttMap.get(mkey); if( method==null ) { if (params == null) params = new Object[0]; if (signature == null) signature = new String[0]; if (params.length != signature.length) throw new RuntimeOperationsException (new IllegalArgumentException("Inconsistent arguments and signature"), "Inconsistent arguments and signature"); // Acquire the ModelMBeanOperationInfo information for // the requested operation ModelMBeanOperationInfo opInfo = info.getOperation(name); if (opInfo == null) throw new MBeanException (new ServiceNotFoundException("Cannot find operation " + name), "Cannot find operation " + name); // Prepare the signature required by Java reflection APIs // FIXME - should we use the signature from opInfo? Class types[] = new Class[signature.length]; for (int i = 0; i < signature.length; i++) { types[i]=getAttributeClass( signature[i] ); } // Locate the method to be invoked, either in this MBean itself // or in the corresponding managed resource // FIXME - Accessible methods in superinterfaces? Object object = null; Exception exception = null; try { object = this; method = object.getClass().getMethod(name, types); } catch (NoSuchMethodException e) { exception = e;; } try { if ((method == null) && (resource != null)) { object = resource; method = object.getClass().getMethod(name, types); } } catch (NoSuchMethodException e) { exception = e; } if (method == null) { throw new ReflectionException(exception, "Cannot find method " + name + " with this signature"); } invokeAttMap.put( mkey, method ); } // Invoke the selected method on the appropriate object Object result = null; try { if( method.getDeclaringClass().isAssignableFrom( this.getClass()) ) { result = method.invoke(this, params ); } else { result = method.invoke(resource, params); } } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); log.error("Exception invoking method " + name , t ); if (t == null) t = e; if (t instanceof RuntimeException) throw new RuntimeOperationsException ((RuntimeException) t, "Exception invoking method " + name); else if (t instanceof Error) throw new RuntimeErrorException ((Error) t, "Error invoking method " + name); else throw new MBeanException ((Exception)t, "Exception invoking method " + name); } catch (Exception e) { log.error("Exception invoking method " + name , e ); throw new MBeanException (e, "Exception invoking method " + name); } // Return the results of this method invocation // FIXME - should we validate the return type? return (result); } private Class getAttributeClass(String signature) throws ReflectionException { if (signature.equals(Boolean.TYPE.getName())) return Boolean.TYPE; else if (signature.equals(Byte.TYPE.getName())) return Byte.TYPE; else if (signature.equals(Character.TYPE.getName())) return Character.TYPE; else if (signature.equals(Double.TYPE.getName())) return Double.TYPE; else if (signature.equals(Float.TYPE.getName())) return Float.TYPE; else if (signature.equals(Integer.TYPE.getName())) return Integer.TYPE; else if (signature.equals(Long.TYPE.getName())) return Long.TYPE; else if (signature.equals(Short.TYPE.getName())) return Short.TYPE; else { try { ClassLoader cl=Thread.currentThread().getContextClassLoader(); if( cl!=null ) return cl.loadClass(signature); } catch( ClassNotFoundException e ) { } try { return Class.forName(signature); } catch (ClassNotFoundException e) { throw new ReflectionException (e, "Cannot find Class for " + signature); } } } /** * Set the value of a specific attribute of this MBean. * * @param attribute The identification of the attribute to be set * and the new value * * @exception AttributeNotFoundException if this attribute is not * supported by this MBean * @exception MBeanException if the initializer of an object * throws an exception * @exception ReflectionException if a Java reflection exception * occurs when invoking the getter */ public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { if( log.isDebugEnabled() ) log.debug("Setting attribute " + this + " " + attribute ); if( (resource instanceof DynamicMBean) && ! ( resource instanceof BaseModelMBean )) { try { ((DynamicMBean)resource).setAttribute(attribute); } catch (InvalidAttributeValueException e) { throw new MBeanException(e); } return; } // Validate the input parameters if (attribute == null) throw new RuntimeOperationsException (new IllegalArgumentException("Attribute is null"), "Attribute is null"); String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) throw new RuntimeOperationsException (new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); ModelMBeanAttributeInfo attrInfo=info.getAttribute(name); if (attrInfo == null) throw new AttributeNotFoundException("Cannot find attribute " + name); Descriptor attrDesc=attrInfo.getDescriptor(); if (attrDesc == null) throw new AttributeNotFoundException("Cannot find attribute " + name + " descriptor"); Object oldValue=null; if( getAttMap.get(name) != null ) oldValue=getAttribute( name ); // Extract the method from cache Method m=(Method)setAttMap.get( name ); if( m==null ) { // Look up the actual operation to be used String setMethod = (String) attrDesc.getFieldValue("setMethod"); if (setMethod == null) throw new AttributeNotFoundException("Cannot find attribute " + name + " set method name"); String argType=attrInfo.getType(); Class signature[] = new Class[] { getAttributeClass( argType ) }; Object object = null; NoSuchMethodException exception = null; try { object = this; m = object.getClass().getMethod(setMethod, signature); } catch (NoSuchMethodException e) { exception = e;; } if( m== null && resource != null ) { try { object = resource; m = object.getClass().getMethod(setMethod, signature); exception=null; } catch (NoSuchMethodException e) { if( log.isDebugEnabled()) log.debug("Method not found in resource " +resource); exception = e; } } if( exception != null ) throw new ReflectionException(exception, "Cannot find setter method " + setMethod + " " + resource); setAttMap.put( name, m ); } Object result = null; try { if( m.getDeclaringClass().isAssignableFrom( this.getClass()) ) { result = m.invoke(this, new Object[] { value }); } else { result = m.invoke(resource, new Object[] { value }); } } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t == null) t = e; if (t instanceof RuntimeException) throw new RuntimeOperationsException ((RuntimeException) t, "Exception invoking method " + name); else if (t instanceof Error) throw new RuntimeErrorException ((Error) t, "Error invoking method " + name); else throw new MBeanException (e, "Exception invoking method " + name); } catch (Exception e) { log.error("Exception invoking method " + name , e ); throw new MBeanException (e, "Exception invoking method " + name); } try { sendAttributeChangeNotification(new Attribute( name, oldValue), attribute); } catch(Exception ex) { log.error("Error sending notification " + name, ex); } attributes.put( name, value ); if( source != null ) { // this mbean is asscoiated with a source - maybe we want to persist source.updateField(oname, name, value); } } public String toString() { if( resource==null ) return "BaseModelMbean[" + resourceType + "]"; return resource.toString(); } /** * Set the values of several attributes of this MBean. * * @param attributes THe names and values to be set * * @return The list of attributes that were set and their new values */ public AttributeList setAttributes(AttributeList attributes) { // Validate the input parameters if (attributes == null) throw new RuntimeOperationsException (new IllegalArgumentException("Attributes list is null"), "Attributes list is null"); // Prepare and return our response, eating all exceptions AttributeList response = new AttributeList(); String names[] = new String[attributes.size()]; int n = 0; Iterator items = attributes.iterator(); while (items.hasNext()) { Attribute item = (Attribute) items.next(); names[n++] = item.getName(); try { setAttribute(item); } catch (Exception e) { ; // Ignore all exceptions } } return (getAttributes(names)); } // ----------------------------------------------------- ModelMBean Methods /** * Get the instance handle of the object against which we execute * all methods in this ModelMBean management interface. * * @exception InstanceNotFoundException if the managed resource object * cannot be found * @exception MBeanException if the initializer of the object throws * an exception * @exception RuntimeOperationsException if the managed resource or the * resource type is null or invalid */ public Object getManagedResource() throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException { if (resource == null) throw new RuntimeOperationsException (new IllegalArgumentException("Managed resource is null"), "Managed resource is null"); return resource; } /** * Set the instance handle of the object against which we will execute * all methods in this ModelMBean management interface. * * This method will detect and call "setModelMbean" method. A resource * can implement this method to get a reference to the model mbean. * The reference can be used to send notification and access the * registry. * * @param resource The resource object to be managed * @param type The type of reference for the managed resource * ("ObjectReference", "Handle", "IOR", "EJBHandle", or * "RMIReference") * * @exception InstanceNotFoundException if the managed resource object * cannot be found * @exception InvalidTargetObjectTypeException if this ModelMBean is * asked to handle a reference type it cannot deal with * @exception MBeanException if the initializer of the object throws * an exception * @exception RuntimeOperationsException if the managed resource or the * resource type is null or invalid */ public void setManagedResource(Object resource, String type) throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException { if (resource == null) throw new RuntimeOperationsException (new IllegalArgumentException("Managed resource is null"), "Managed resource is null"); if (!"objectreference".equalsIgnoreCase(type)) throw new InvalidTargetObjectTypeException(type); this.resource = resource; this.resourceType = resource.getClass().getName(); // Make the resource aware of the model mbean. try { Method m=resource.getClass().getMethod("setModelMBean", new Class[] {ModelMBean.class}); if( m!= null ) { m.invoke(resource, new Object[] {this}); } } catch( NoSuchMethodException t ) { // ignore } catch( Throwable t ) { log.error( "Can't set model mbean ", t ); } } /** * Initialize the ModelMBeanInfo associated with this * ModelMBean. After the information and associated * descriptors have been customized, the ModelMBean should * be registered with the associated MBeanServer. * * Currently the model can be set after registration. This behavior is * deprecated and won't be supported in future versions. * * @param info The ModelMBeanInfo object to be used by this ModelMBean * * @exception MBeanException If an exception occurs recording this * ModelMBeanInfo information * @exception RuntimeOperations if the specified parameter is * null or invalid */ public void setModelMBeanInfo(ModelMBeanInfo info) throws MBeanException, RuntimeOperationsException { if (info == null) throw new RuntimeOperationsException (new IllegalArgumentException("ModelMBeanInfo is null"), "ModelMBeanInfo is null"); if (!isModelMBeanInfoValid(info)) throw new RuntimeOperationsException (new IllegalArgumentException("ModelMBeanInfo is invalid"), "ModelMBeanInfo is invalid"); this.info = (ModelMBeanInfo) info.clone(); } // ------------------------------ ModelMBeanNotificationBroadcaster Methods /** * Add an attribute change notification event listener to this MBean. * * @param listener Listener that will receive event notifications * @param name Name of the attribute of interest, or null * to indicate interest in all attributes * @param handback Handback object to be sent along with event * notifications * * @exception IllegalArgumentException if the listener parameter is null */ public void addAttributeChangeNotificationListener (NotificationListener listener, String name, Object handback) throws IllegalArgumentException { if (listener == null) throw new IllegalArgumentException("Listener is null"); if (attributeBroadcaster == null) attributeBroadcaster = new BaseNotificationBroadcaster(); if( log.isDebugEnabled() ) log.debug("addAttributeNotificationListener " + listener); BaseAttributeFilter filter = new BaseAttributeFilter(name); attributeBroadcaster.addNotificationListener (listener, filter, handback); } /** * Remove an attribute change notification event listener from * this MBean. * * @param listener The listener to be removed * @param name The attribute name for which no more events are required * * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ public void removeAttributeChangeNotificationListener (NotificationListener listener, String name) throws ListenerNotFoundException { if (listener == null) throw new IllegalArgumentException("Listener is null"); if (attributeBroadcaster == null) attributeBroadcaster = new BaseNotificationBroadcaster(); // FIXME - currently this removes *all* notifications for this listener attributeBroadcaster.removeNotificationListener(listener); } /** * Remove an attribute change notification event listener from * this MBean. * * @param listener The listener to be removed * @param attributeName The attribute name for which no more events are required * @param handback Handback object to be sent along with event * notifications * * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ public void removeAttributeChangeNotificationListener (NotificationListener listener, String attributeName, Object handback) throws ListenerNotFoundException { removeAttributeChangeNotificationListener(listener, attributeName); } /** * Send an AttributeChangeNotification to all registered * listeners. * * @param notification The AttributeChangeNotification * that will be passed * * @exception MBeanException if an object initializer throws an * exception * @exception RuntimeOperationsException wraps IllegalArgumentException * when the specified notification is null or invalid */ public void sendAttributeChangeNotification (AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException { if (notification == null) throw new RuntimeOperationsException (new IllegalArgumentException("Notification is null"), "Notification is null"); if (attributeBroadcaster == null) return; // This means there are no registered listeners if( log.isDebugEnabled() ) log.debug( "AttributeChangeNotification " + notification ); attributeBroadcaster.sendNotification(notification); } /** * Send an AttributeChangeNotification to all registered * listeners. * * @param oldValue The original value of the Attribute * @param newValue The new value of the Attribute * * @exception MBeanException if an object initializer throws an * exception * @exception RuntimeOperationsException wraps IllegalArgumentException * when the specified notification is null or invalid */ public void sendAttributeChangeNotification (Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException { // Calculate the class name for the change notification String type = null; if (newValue.getValue() != null) type = newValue.getValue().getClass().getName(); else if (oldValue.getValue() != null) type = oldValue.getValue().getClass().getName(); else return; // Old and new are both null == no change AttributeChangeNotification notification = new AttributeChangeNotification (this, 1, System.currentTimeMillis(), "Attribute value has changed", oldValue.getName(), type, oldValue.getValue(), newValue.getValue()); sendAttributeChangeNotification(notification); } /** * Send a Notification to all registered listeners as a * jmx.modelmbean.general notification. * * @param notification The Notification that will be passed * * @exception MBeanException if an object initializer throws an * exception * @exception RuntimeOperationsException wraps IllegalArgumentException * when the specified notification is null or invalid */ public void sendNotification(Notification notification) throws MBeanException, RuntimeOperationsException { if (notification == null) throw new RuntimeOperationsException (new IllegalArgumentException("Notification is null"), "Notification is null"); if (generalBroadcaster == null) return; // This means there are no registered listeners generalBroadcaster.sendNotification(notification); } /** * Send a Notification which contains the specified string * as a jmx.modelmbean.generic notification. * * @param message The message string to be passed * * @exception MBeanException if an object initializer throws an * exception * @exception RuntimeOperationsException wraps IllegalArgumentException * when the specified notification is null or invalid */ public void sendNotification(String message) throws MBeanException, RuntimeOperationsException { if (message == null) throw new RuntimeOperationsException (new IllegalArgumentException("Message is null"), "Message is null"); Notification notification = new Notification ("jmx.modelmbean.generic", this, 1, message); sendNotification(notification); } // ---------------------------------------- NotificationBroadcaster Methods /** * Add a notification event listener to this MBean. * * @param listener Listener that will receive event notifications * @param filter Filter object used to filter event notifications * actually delivered, or null for no filtering * @param handback Handback object to be sent along with event * notifications * * @exception IllegalArgumentException if the listener parameter is null */ public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException { if (listener == null) throw new IllegalArgumentException("Listener is null"); if( log.isDebugEnabled() ) log.debug("addNotificationListener " + listener); if (generalBroadcaster == null) generalBroadcaster = new BaseNotificationBroadcaster(); generalBroadcaster.addNotificationListener (listener, filter, handback); // We'll send the attribute change notifications to all listeners ( who care ) // The normal filtering can be used. // The problem is that there is no other way to add attribute change listeners // to a model mbean ( AFAIK ). I suppose the spec should be fixed. if (attributeBroadcaster == null) attributeBroadcaster = new BaseNotificationBroadcaster(); if( log.isDebugEnabled() ) log.debug("addAttributeNotificationListener " + listener); attributeBroadcaster.addNotificationListener (listener, filter, handback); } /** * Return an MBeanNotificationInfo object describing the * notifications sent by this MBean. */ public MBeanNotificationInfo[] getNotificationInfo() { // Acquire the set of application notifications MBeanNotificationInfo current[] = info.getNotifications(); if (current == null) current = new MBeanNotificationInfo[0]; MBeanNotificationInfo response[] = new MBeanNotificationInfo[current.length + 2]; Descriptor descriptor = null; // Fill in entry for general notifications descriptor = new DescriptorSupport (new String[] { "name=GENERIC", "descriptorType=notification", "log=T", "severity=5", "displayName=jmx.modelmbean.generic" }); response[0] = new ModelMBeanNotificationInfo (new String[] { "jmx.modelmbean.generic" }, "GENERIC", "Text message notification from the managed resource", descriptor); // Fill in entry for attribute change notifications descriptor = new DescriptorSupport (new String[] { "name=ATTRIBUTE_CHANGE", "descriptorType=notification", "log=T", "severity=5", "displayName=jmx.attribute.change" }); response[1] = new ModelMBeanNotificationInfo (new String[] { "jmx.attribute.change" }, "ATTRIBUTE_CHANGE", "Observed MBean attribute value has changed", descriptor); // Copy remaining notifications as reported by the application System.arraycopy(current, 0, response, 2, current.length); return (response); } /** * Remove a notification event listener from this MBean. * * @param listener The listener to be removed (any and all registrations * for this listener will be eliminated) * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { if (listener == null) throw new IllegalArgumentException("Listener is null"); if (generalBroadcaster == null) generalBroadcaster = new BaseNotificationBroadcaster(); generalBroadcaster.removeNotificationListener(listener); } /** * Remove a notification event listener from this MBean. * * @param listener The listener to be removed (any and all registrations * for this listener will be eliminated) * @param handback Handback object to be sent along with event * notifications * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ public void removeNotificationListener(NotificationListener listener, Object handback) throws ListenerNotFoundException { removeNotificationListener(listener); } /** * Remove a notification event listener from this MBean. * * @param listener The listener to be removed (any and all registrations * for this listener will be eliminated) * @param filter Filter object used to filter event notifications * actually delivered, or null for no filtering * @param handback Handback object to be sent along with event * notifications * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException { removeNotificationListener(listener); } // ------------------------------------------------ PersistentMBean Methods /** * Instantiates this MBean instance from data found in the persistent * store. The data loaded could include attribute and operation values. * This method should be called during construction or initialization * of the instance, and before the MBean is registered with the * MBeanServer. * *

IMPLEMENTATION NOTE - This implementation does * not support persistence.

* * @exception InstanceNotFoundException if the managed resource object * cannot be found * @exception MBeanException if the initializer of the object throws * an exception * @exception RuntimeOperationsException if an exception is reported * by the persistence mechanism */ public void load() throws InstanceNotFoundException, MBeanException, RuntimeOperationsException { // XXX If a context was set, use it to load the data throw new MBeanException (new IllegalStateException("Persistence is not supported"), "Persistence is not supported"); } /** * Capture the current state of this MBean instance and write it out * to the persistent store. The state stored could include attribute * and operation values. If one of these methods of persistence is not * supported, a "service not found" exception will be thrown. * *

IMPLEMENTATION NOTE - This implementation does * not support persistence.

* * @exception InstanceNotFoundException if the managed resource object * cannot be found * @exception MBeanException if the initializer of the object throws * an exception, or persistence is not supported * @exception RuntimeOperationsException if an exception is reported * by the persistence mechanism */ public void store() throws InstanceNotFoundException, MBeanException, RuntimeOperationsException { // XXX if a context was set, use it to store the data throw new MBeanException (new IllegalStateException("Persistence is not supported"), "Persistence is not supported"); } // -------------------- BaseModelMBean methods -------------------- /** Set the type of the mbean. This is used as a key to locate * the description in the Registry. * * @param type the type of classname of the modeled object */ public void setModeledType( String type ) { initModelInfo(type); createResource(); } /** Set the type of the mbean. This is used as a key to locate * the description in the Registry. * * @param type the type of classname of the modeled object */ protected void initModelInfo( String type ) { try { if( log.isDebugEnabled()) log.debug("setModeledType " + type); log.debug( "Set model Info " + type); if(type==null) { return; } resourceType=type; //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader()); Class c=null; try { c=Class.forName( type); } catch( Throwable t ) { log.debug( "Error creating class " + t); } // The class c doesn't need to exist ManagedBean descriptor=getRegistry().findManagedBean(c, type); if( descriptor==null ) return; this.setModelMBeanInfo(descriptor.createMBeanInfo()); } catch( Throwable ex) { log.error( "TCL: " + Thread.currentThread().getContextClassLoader(), ex); } } /** Set the type of the mbean. This is used as a key to locate * the description in the Registry. */ protected void createResource() { try { //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader()); Class c=null; try { c=Class.forName( resourceType ); resource = c.newInstance(); } catch( Throwable t ) { log.error( "Error creating class " + t); } } catch( Throwable ex) { log.error( "TCL: " + Thread.currentThread().getContextClassLoader(), ex); } } public String getModelerType() { return resourceType; } public String getClassName() { return getModelerType(); } public ObjectName getJmxName() { return oname; } public String getObjectName() { if (oname != null) { return oname.toString(); } else { return null; } } public void setRegistry(Registry registry) { this.registry = registry; } public Registry getRegistry() { // XXX Need a better solution - to avoid the static if( registry == null ) registry=Registry.getRegistry(); return registry; } // ------------------------------------------------------ Protected Methods /** * Create and return a default ModelMBeanInfo object. */ protected ModelMBeanInfo createDefaultModelMBeanInfo() { return (new ModelMBeanInfoSupport(this.getClass().getName(), "Default ModelMBean", null, null, null, null)); } /** * Is the specified ModelMBeanInfo instance valid? * *

IMPLEMENTATION NOTE - This implementation * does not check anything, but this method can be overridden * as required.

* * @param info The ModelMBeanInfo object to check */ protected boolean isModelMBeanInfoValid(ModelMBeanInfo info) { return (true); } // -------------------- Registration -------------------- // XXX We can add some method patterns here- like setName() and // setDomain() for code that doesn't implement the Registration public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { if( log.isDebugEnabled()) log.debug("preRegister " + resource + " " + name ); oname=name; if( resource instanceof MBeanRegistration ) { oname = ((MBeanRegistration)resource).preRegister(server, name ); } return oname; } public void postRegister(Boolean registrationDone) { if( resource instanceof MBeanRegistration ) { ((MBeanRegistration)resource).postRegister(registrationDone); } } public void preDeregister() throws Exception { if( resource instanceof MBeanRegistration ) { ((MBeanRegistration)resource).preDeregister(); } } public void postDeregister() { if( resource instanceof MBeanRegistration ) { ((MBeanRegistration)resource).postDeregister(); } } static class MethodKey { private String name; private String[] signature; MethodKey(String name, String[] signature) { this.name = name; if(signature == null) { signature = new String[0]; } this.signature = signature; } public boolean equals(Object other) { if(!(other instanceof MethodKey)) { return false; } MethodKey omk = (MethodKey)other; if(!name.equals(omk.name)) { return false; } if(signature.length != omk.signature.length) { return false; } for(int i=0; i < signature.length; i++) { if(!signature[i].equals(omk.signature[i])) { return false; } } return true; } public int hashCode() { return name.hashCode(); } } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/BaseNotification.java100644 0 0 5422 10636604104 25437 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import javax.management.Notification; /** * Base JMX Notification. Supports in int code and notes - for faster * access and dispatching. * * @author Costin Manolache */ public final class BaseNotification extends Notification { // ----------------------------------------------------------- Constructors private int code; private String type; private Object source; private long seq; private long tstamp; /** * Private constructor. */ private BaseNotification(String type, Object source, long seq, long tstamp, int code) { super(type, source, seq, tstamp); init( type, source, seq, tstamp, code ); this.code=code; } public void recycle() { } public void init( String type, Object source, long seq, long tstamp, int code ) { this.type=type; this.source = source; this.seq=seq; this.tstamp=tstamp; this.code = code; } // -------------------- Override base methods -------------------- // All base methods need to be overriden - in order to support recycling. // -------------------- Information associated with the notification ---- // Like events ( which Notification extends ), notifications may store // informations related with the event that trigered it. Source and type is // one piece, but it is common to store more info. /** Action id, useable in switches and table indexes */ public int getCode() { return code; } // XXX Make it customizable - or grow it private Object notes[]=new Object[32]; public final Object getNote(int i ) { return notes[i]; } public final void setNote(int i, Object o ) { notes[i]=o; } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/BaseNotificationBroadcaster.java100644 0 0 21725 10636604104 27635 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.util.ArrayList; import java.util.Iterator; import javax.management.ListenerNotFoundException; import javax.management.MBeanNotificationInfo; import javax.management.Notification; import javax.management.NotificationBroadcaster; import javax.management.NotificationFilter; import javax.management.NotificationListener; /** *

Implementation of NotificationBroadcaster for attribute * change notifications. This class is used by BaseModelMBean to * handle notifications of attribute change events to interested listeners. *

* * @author Craig R. McClanahan * @author Costin Manolache */ public class BaseNotificationBroadcaster implements NotificationBroadcaster { // ----------------------------------------------------------- Constructors // ----------------------------------------------------- Instance Variables /** * The set of registered BaseNotificationBroadcasterEntry * entries. */ protected ArrayList entries = new ArrayList(); // --------------------------------------------------------- Public Methods /** * Add a notification event listener to this MBean. * * @param listener Listener that will receive event notifications * @param filter Filter object used to filter event notifications * actually delivered, or null for no filtering * @param handback Handback object to be sent along with event * notifications * * @exception IllegalArgumentException if the listener parameter is null */ public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException { synchronized (entries) { // Optimization to coalesce attribute name filters if (filter instanceof BaseAttributeFilter) { BaseAttributeFilter newFilter = (BaseAttributeFilter) filter; Iterator items = entries.iterator(); while (items.hasNext()) { BaseNotificationBroadcasterEntry item = (BaseNotificationBroadcasterEntry) items.next(); if ((item.listener == listener) && (item.filter != null) && (item.filter instanceof BaseAttributeFilter) && (item.handback == handback)) { BaseAttributeFilter oldFilter = (BaseAttributeFilter) item.filter; String newNames[] = newFilter.getNames(); String oldNames[] = oldFilter.getNames(); if (newNames.length == 0) { oldFilter.clear(); } else { if (oldNames.length != 0) { for (int i = 0; i < newNames.length; i++) oldFilter.addAttribute(newNames[i]); } } return; } } } // General purpose addition of a new entry entries.add(new BaseNotificationBroadcasterEntry (listener, filter, handback)); } } /** * Return an MBeanNotificationInfo object describing the * notifications sent by this MBean. */ public MBeanNotificationInfo[] getNotificationInfo() { return (new MBeanNotificationInfo[0]); } /** * Remove a notification event listener from this MBean. * * @param listener The listener to be removed (any and all registrations * for this listener will be eliminated) * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { synchronized (entries) { Iterator items = entries.iterator(); while (items.hasNext()) { BaseNotificationBroadcasterEntry item = (BaseNotificationBroadcasterEntry) items.next(); if (item.listener == listener) items.remove(); } } } /** * Remove a notification event listener from this MBean. * * @param listener The listener to be removed (any and all registrations * for this listener will be eliminated) * @param handback Handback object to be sent along with event * notifications * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ public void removeNotificationListener(NotificationListener listener, Object handback) throws ListenerNotFoundException { removeNotificationListener(listener); } /** * Remove a notification event listener from this MBean. * * @param listener The listener to be removed (any and all registrations * for this listener will be eliminated) * @param filter Filter object used to filter event notifications * actually delivered, or null for no filtering * @param handback Handback object to be sent along with event * notifications * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException { removeNotificationListener(listener); } /** * Send the specified notification to all interested listeners. * * @param notification The notification to be sent */ public void sendNotification(Notification notification) { synchronized (entries) { Iterator items = entries.iterator(); while (items.hasNext()) { BaseNotificationBroadcasterEntry item = (BaseNotificationBroadcasterEntry) items.next(); if ((item.filter != null) && (!item.filter.isNotificationEnabled(notification))) continue; item.listener.handleNotification(notification, item.handback); } } } // -------------------- Internal Extensions -------------------- // Fast access. First index is the hook type // ( FixedNotificationFilter.getType() ). NotificationListener hooks[][]=new NotificationListener[20][]; int hookCount[]=new int[20]; private synchronized void registerNotifications( FixedNotificationFilter filter ) { String names[]=filter.getNames(); Registry reg=Registry.getRegistry(); for( int i=0; iInternal configuration information for a Constructor * descriptor.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class ConstructorInfo extends FeatureInfo implements Serializable { static final long serialVersionUID = -5735336213417238238L; // ----------------------------------------------------- Instance Variables /** * The ModelMBeanConstructorInfo object that corresponds * to this ConstructorInfo instance. */ transient ModelMBeanConstructorInfo info = null; protected String displayName = null; protected ParameterInfo parameters[] = new ParameterInfo[0]; // ------------------------------------------------------------- Properties /** * Override the description property setter. * * @param description The new description */ public void setDescription(String description) { super.setDescription(description); this.info = null; } /** * Override the name property setter. * * @param name The new name */ public void setName(String name) { super.setName(name); this.info = null; } /** * The display name of this attribute. */ public String getDisplayName() { return (this.displayName); } public void setDisplayName(String displayName) { this.displayName = displayName; } /** * The set of parameters for this constructor. */ public ParameterInfo[] getSignature() { return (this.parameters); } // --------------------------------------------------------- Public Methods /** * Add a new parameter to the set of parameters for this constructor. * * @param parameter The new parameter descriptor */ public void addParameter(ParameterInfo parameter) { synchronized (parameters) { ParameterInfo results[] = new ParameterInfo[parameters.length + 1]; System.arraycopy(parameters, 0, results, 0, parameters.length); results[parameters.length] = parameter; parameters = results; this.info = null; } } /** * Create and return a ModelMBeanConstructorInfo object that * corresponds to the attribute described by this instance. */ public ModelMBeanConstructorInfo createConstructorInfo() { // Return our cached information (if any) if (info != null) return (info); // Create and return a new information object ParameterInfo params[] = getSignature(); MBeanParameterInfo parameters[] = new MBeanParameterInfo[params.length]; for (int i = 0; i < params.length; i++) parameters[i] = params[i].createParameterInfo(); info = new ModelMBeanConstructorInfo (getName(), getDescription(), parameters); Descriptor descriptor = info.getDescriptor(); descriptor.removeField("class"); if (getDisplayName() != null) descriptor.setField("displayName", getDisplayName()); addFields(descriptor); info.setDescriptor(descriptor); return (info); } /** * Return a string representation of this constructor descriptor. */ public String toString() { StringBuffer sb = new StringBuffer("ConstructorInfo["); sb.append("name="); sb.append(name); sb.append(", description="); sb.append(description); sb.append(", parameters="); sb.append(parameters.length); sb.append("]"); return (sb.toString()); } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/FeatureInfo.java100644 0 0 6452 10636604104 24431 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.Descriptor; /** *

Convenience base class for AttributeInfo, * ConstructorInfo, and OperationInfo classes * that will be used to collect configuration information for the * ModelMBean beans exposed for management.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class FeatureInfo implements Serializable { static final long serialVersionUID = -911529176124712296L; protected String description = null; protected List fields = new ArrayList(); protected String name = null; // ------------------------------------------------------------- Properties /** * The human-readable description of this feature. */ public String getDescription() { return (this.description); } public void setDescription(String description) { this.description = description; } /** * The field information for this feature. */ public List getFields() { return (fields); } /** * The name of this feature, which must be unique among features in the * same collection. */ public String getName() { return (this.name); } public void setName(String name) { this.name = name; } // --------------------------------------------------------- Public Methods /** *

Add a new field to the fields associated with the * Descriptor that will be created from this metadata.

* * @param field The field to be added */ public void addField(FieldInfo field) { fields.add(field); } // ------------------------------------------------------ Protected Methods /** *

Add the name/value fields that have been stored into the * specified Descriptor instance.

* * @param descriptor The Descriptor to add fields to */ protected void addFields(Descriptor descriptor) { Iterator items = getFields().iterator(); while (items.hasNext()) { FieldInfo item = (FieldInfo) items.next(); descriptor.setField(item.getName(), item.getValue()); } } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/FieldInfo.java100644 0 0 3233 10636604104 24053 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.io.Serializable; /** *

Simple JavaBean representing the contents of a <field> * element in an MBeans descriptor file. */ public class FieldInfo implements Serializable { static final long serialVersionUID = -8226401620640873691L; /** *

The field name for this field of a descriptor.

*/ protected String name = null; public String getName() { return (this.name); } public void setName(String name) { this.name = name; } /** *

The field value for this field of a descriptor.

*/ protected Object value = null; public Object getValue() { return (this.value); } public void setValue(Object value) { this.value = value; } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/FixedNotificationFilter.java100644 0 0 6040 10636604104 26767 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.util.HashSet; import javax.management.Notification; import javax.management.NotificationFilter; /** * Special NotificationFilter that allows modeler to optimize its notifications. * * This class is immutable - after you construct it it'll filter based on * a fixed set of notification names. * * The JMX specification requires the filters to be called before the * notifications are sent. We can call this filter well in advance, when * the listener is added. Based on the result we can maintain separate * channels for each notification - and reduce the overhead. * * @author Costin Manolache */ public class FixedNotificationFilter implements NotificationFilter { /** * The set of attribute names that are accepted by this filter. If this * list is empty, all attribute names are accepted. */ private HashSet names = new HashSet(); String namesA[]=null; /** * Construct a new filter that accepts only the specified notification * names. * * @param names Names of the notification types */ public FixedNotificationFilter(String names[]) { super(); } /** * Return the set of names that are accepted by this filter. If this * filter accepts all attribute names, a zero length array will be * returned. */ public String[] getNames() { synchronized (names) { return ((String[]) names.toArray(new String[names.size()])); } } /** *

Test whether notification enabled for this event. * Return true if:

*
    *
  • Either the set of accepted names is empty (implying that all * attribute names are of interest) or the set of accepted names * includes the name of the attribute in this notification
  • *
*/ public boolean isNotificationEnabled(Notification notification) { if (notification == null) return (false); synchronized (names) { if (names.size() < 1) return (true); else return (names.contains(notification.getType())); } } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/JndiJmx.java100644 0 0 17763 10636604104 23614 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.util.Enumeration; import java.util.Hashtable; import javax.management.AttributeChangeNotification; import javax.management.InstanceNotFoundException; import javax.management.MBeanException; import javax.management.MBeanServer; import javax.management.MBeanServerNotification; import javax.management.Notification; import javax.management.NotificationBroadcaster; import javax.management.NotificationListener; import javax.management.ObjectName; import javax.naming.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; // EXPERIMENTAL. It may fit better in tomcat jndi impl. /** * * Link between JNDI and JMX. JNDI can be used for persistence ( it is * an API for storing hierarchical data and a perfect fit for that ), as * well as an alternate view of the MBean registry. * * If this component is enabled, all MBeans will be registered in JNDI, and * all attributes that are set via JMX can be stored in a DirContext. * * This acts as a "recorder" for creation of mbeans and attribute changes * done via JMX. * * XXX How can we control ( filter ) which mbeans will be registere ? Or * attributes ? * XXX How can we get the beans and attributes loaded before jndijmx ? * * The intended use: * - do whatever you want to start the application * - load JndiJmx as an mbean * - make changes via JMX. All changes are recorded * - you can use JndiJmx to save the changes in a Jndi context. * - you can use JndiJmx to load changes from a JndiContext and replay them. * * The main benefit is that only changed attributes are saved, and the Jndi * layer can preserve most of the original structure of the config file. The * alternative is to override the config files with config info extracted * from the live objects - but it's very hard to save only what was actually * changed and preserve structure and comments. * * @author Costin Manolache */ public class JndiJmx extends BaseModelMBean implements NotificationListener { private static Log log= LogFactory.getLog(JndiJmx.class); protected Context componentContext; protected Context descriptorContext; protected Context configContext; MBeanServer mserver; /** * Protected constructor to require use of the factory create method. */ public JndiJmx() throws MBeanException { super(JndiJmx.class.getName()); } /** If a JNDI context is set, all components * will be registered in the context. * * @param ctx */ public void setComponentContext(Context ctx) { this.componentContext= ctx; } /** JNDI context for component descriptors ( metadata ). * * @param ctx */ public void setDescriptorContext(Context ctx) { this.descriptorContext= ctx; } /** JNDI context where attributes will be stored for persistence * */ public void setConfigContext( Context ctx ) { this.configContext= ctx; } // -------------------- Registration/unregistration -------------------- // temp - will only set in the jndi contexts Hashtable attributes=new Hashtable(); Hashtable instances=new Hashtable(); public void handleNotification(Notification notification, Object handback) { // register/unregister mbeans in jndi if( notification instanceof MBeanServerNotification ) { MBeanServerNotification msnot=(MBeanServerNotification)notification; ObjectName oname=msnot.getMBeanName(); if( "jmx.mbean.created".equalsIgnoreCase( notification.getType() )) { try { Object mbean=mserver.getObjectInstance(oname); if( log.isDebugEnabled() ) log.debug( "MBean created " + oname + " " + mbean); // XXX add filter support if( mbean instanceof NotificationBroadcaster ) { // register for attribute changes NotificationBroadcaster nb=(NotificationBroadcaster)mbean; nb.addNotificationListener(this, null, null); if( log.isDebugEnabled() ) log.debug( "Add attribute change listener"); } instances.put( oname.toString(), mbean ); } catch( InstanceNotFoundException ex ) { log.error( "Instance not found for the created object", ex ); } } if( "jmx.mbean.deleted".equalsIgnoreCase( notification.getType() )) { instances.remove(oname.toString()); } } // set attributes in jndi // if( "jmx.attribute.changed".equals( notification.getType() )) { if( notification instanceof AttributeChangeNotification) { AttributeChangeNotification anotif=(AttributeChangeNotification)notification; String name=anotif.getAttributeName(); Object value=anotif.getNewValue(); Object source=anotif.getSource(); String mname=null; Hashtable mbeanAtt=(Hashtable)attributes.get( source ); if( mbeanAtt==null ) { mbeanAtt=new Hashtable(); attributes.put( source, mbeanAtt); if( log.isDebugEnabled()) log.debug("First attribute for " + source ); } mbeanAtt.put( name, anotif ); log.debug( "Attribute change notification " + name + " " + value + " " + source ); } } public String dumpStatus() throws Exception { StringBuffer sb=new StringBuffer(); Enumeration en=instances.keys(); while (en.hasMoreElements()) { String on = (String) en.nextElement(); Object mbean=instances.get(on); Hashtable mbeanAtt=(Hashtable)attributes.get(mbean); sb.append( ""); sb.append( "\n"); Enumeration attEn=mbeanAtt.keys(); while (attEn.hasMoreElements()) { String an = (String) attEn.nextElement(); AttributeChangeNotification anotif= (AttributeChangeNotification)mbeanAtt.get(an); sb.append(" "); sb.append( "\n"); } sb.append( ""); sb.append( "\n"); } return sb.toString(); } public void replay() throws Exception { } public void init() throws Exception { MBeanServer mserver=(MBeanServer)Registry.getRegistry().getMBeanServer(); ObjectName delegate=new ObjectName("JMImplementation:type=MBeanServerDelegate"); // XXX need to extract info about previously loaded beans // we'll know of all registered beans mserver.addNotificationListener(delegate, this, null, null ); } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/Main.java100644 0 0 4610 10636604104 23100 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.io.File; import java.net.URL; import java.util.List; import org.apache.commons.modeler.util.IntrospectionUtils; /** * Small main that loads mbeans. * * Requires: commons-logging-api.jar, jaxp ( including DOM ), jmx * * Arguments: * -file FILE * Will load mbeans from the file * * @author Costin Manolache */ public class Main { String file; String home; public void setFile( String f ) { this.file=f; } // shortcut public void setF( String f ) { this.file=f; } public void execute( ) throws Exception { if( home==null ) { home=IntrospectionUtils.guessInstall("install.dir", "home.dir", "commons-modeler.jar", "org.apache.commons.modeler.Main"); } if( file==null ) throw new Exception( "No file, use -file file.xml"); Registry reg=Registry.getRegistry(); File fileF=new File( file ); URL url=new URL("file", null, fileF.getAbsolutePath()); // Load the mbeans defined in the file and set all // attributes List mbeans=reg.loadMBeans( url, null); reg.invoke(mbeans, "init", false); reg.invoke(mbeans, "start", false); } public static void main( String args[] ) { try { Main main=new Main(); IntrospectionUtils.processArgs(main, args); main.execute(); } catch( Exception ex ) { ex.printStackTrace(); } } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/ManagedBean.java100644 0 0 40314 10636604104 24357 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.Descriptor; import javax.management.InstanceNotFoundException; import javax.management.MBeanException; import javax.management.RuntimeOperationsException; import javax.management.modelmbean.InvalidTargetObjectTypeException; import javax.management.modelmbean.ModelMBean; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanConstructorInfo; import javax.management.modelmbean.ModelMBeanInfo; import javax.management.modelmbean.ModelMBeanInfoSupport; import javax.management.modelmbean.ModelMBeanNotificationInfo; import javax.management.modelmbean.ModelMBeanOperationInfo; /** *

Internal configuration information for a managed bean (MBean) * descriptor.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class ManagedBean implements java.io.Serializable { // ----------------------------------------------------- Instance Variables /** * The ModelMBeanInfo object that corresponds * to this ManagedBean instance. */ transient ModelMBeanInfo info = null; protected AttributeInfo attributes[] = new AttributeInfo[0]; protected String className = "org.apache.commons.modeler.BaseModelMBean"; protected ConstructorInfo constructors[] = new ConstructorInfo[0]; protected String description = null; protected String domain = null; protected String group = null; protected String name = null; protected List fields = new ArrayList(); protected NotificationInfo notifications[] = new NotificationInfo[0]; protected OperationInfo operations[] = new OperationInfo[0]; protected String type = null; /** Constructor. Will add default attributes. * */ public ManagedBean() { AttributeInfo ai=new AttributeInfo(); ai.setName("modelerType"); ai.setDescription("Type of the modeled resource. Can be set only once"); ai.setType("java.lang.String"); ai.setWriteable(false); addAttribute(ai); } // ------------------------------------------------------------- Properties /** * The collection of attributes for this MBean. */ public AttributeInfo[] getAttributes() { return (this.attributes); } /** * The fully qualified name of the Java class of the MBean * described by this descriptor. If not specified, the standard JMX * class (javax.management.modelmbean.RequiredModeLMBean) * will be utilized. */ public String getClassName() { return (this.className); } public void setClassName(String className) { this.className = className; this.info = null; } /** * The collection of constructors for this MBean. */ public ConstructorInfo[] getConstructors() { return (this.constructors); } /** * The human-readable description of this MBean. */ public String getDescription() { return (this.description); } public void setDescription(String description) { this.description = description; this.info = null; } /** * The (optional) ObjectName domain in which this MBean * should be registered in the MBeanServer. */ public String getDomain() { return (this.domain); } public void setDomain(String domain) { this.domain = domain; } /** *

Return a List of the {@link FieldInfo} objects for * the name/value pairs that should be * added to the Descriptor created from this metadata.

*/ public List getFields() { return (this.fields); } /** * The (optional) group to which this MBean belongs. */ public String getGroup() { return (this.group); } public void setGroup(String group) { this.group = group; } /** * The name of this managed bean, which must be unique among all * MBeans managed by a particular MBeans server. */ public String getName() { return (this.name); } public void setName(String name) { this.name = name; this.info = null; } /** * The collection of notifications for this MBean. */ public NotificationInfo[] getNotifications() { return (this.notifications); } /** * The collection of operations for this MBean. */ public OperationInfo[] getOperations() { return (this.operations); } /** * The fully qualified name of the Java class of the resource * implementation class described by the managed bean described * by this descriptor. */ public String getType() { return (this.type); } public void setType(String type) { this.type = type; this.info = null; } // --------------------------------------------------------- Public Methods /** * Add a new attribute to the set of attributes for this MBean. * * @param attribute The new attribute descriptor */ public void addAttribute(AttributeInfo attribute) { synchronized (attributes) { AttributeInfo results[] = new AttributeInfo[attributes.length + 1]; System.arraycopy(attributes, 0, results, 0, attributes.length); results[attributes.length] = attribute; attributes = results; this.info = null; } } /** * Add a new constructor to the set of constructors for this MBean. * * @param constructor The new constructor descriptor */ public void addConstructor(ConstructorInfo constructor) { synchronized (constructors) { ConstructorInfo results[] = new ConstructorInfo[constructors.length + 1]; System.arraycopy(constructors, 0, results, 0, constructors.length); results[constructors.length] = constructor; constructors = results; this.info = null; } } /** *

Add a new field to the fields associated with the * Descriptor that will be created from this metadata.

* * @param field The field to be added */ public void addField(FieldInfo field) { fields.add(field); } /** * Add a new notification to the set of notifications for this MBean. * * @param notification The new notification descriptor */ public void addNotification(NotificationInfo notification) { synchronized (notifications) { NotificationInfo results[] = new NotificationInfo[notifications.length + 1]; System.arraycopy(notifications, 0, results, 0, notifications.length); results[notifications.length] = notification; notifications = results; this.info = null; } } /** * Add a new operation to the set of operations for this MBean. * * @param operation The new operation descriptor */ public void addOperation(OperationInfo operation) { synchronized (operations) { OperationInfo results[] = new OperationInfo[operations.length + 1]; System.arraycopy(operations, 0, results, 0, operations.length); results[operations.length] = operation; operations = results; this.info = null; } } /** * Create and return a ModelMBean that has been * preconfigured with the ModelMBeanInfo information * for this managed bean, but is not associated with any particular * managed resource. The returned ModelMBean will * NOT have been registered with our * MBeanServer. * * @exception InstanceNotFoundException if the managed resource * object cannot be found * @exception InvalidTargetObjectTypeException if our MBean cannot * handle object references (should never happen) * @exception MBeanException if a problem occurs instantiating the * ModelMBean instance * @exception RuntimeOperationsException if a JMX runtime error occurs */ public ModelMBean createMBean() throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException { return (createMBean(null)); } /** * Create and return a ModelMBean that has been * preconfigured with the ModelMBeanInfo information * for this managed bean, and is associated with the specified * managed object instance. The returned ModelMBean * will NOT have been registered with our * MBeanServer. * * @param instance Instanced of the managed object, or null * for no associated instance * * @exception InstanceNotFoundException if the managed resource * object cannot be found * @exception InvalidTargetObjectTypeException if our MBean cannot * handle object references (should never happen) * @exception MBeanException if a problem occurs instantiating the * ModelMBean instance * @exception RuntimeOperationsException if a JMX runtime error occurs */ public ModelMBean createMBean(Object instance) throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException { // Load the ModelMBean implementation class Class clazz = null; Exception ex = null; try { clazz = Class.forName(getClassName()); } catch (Exception e) { } if( clazz==null ) { try { ClassLoader cl= Thread.currentThread().getContextClassLoader(); if ( cl != null) clazz= cl.loadClass(getClassName()); } catch (Exception e) { ex=e; } } if( clazz==null) { throw new MBeanException (ex, "Cannot load ModelMBean class " + getClassName()); } // Create a new ModelMBean instance ModelMBean mbean = null; try { mbean = (ModelMBean) clazz.newInstance(); mbean.setModelMBeanInfo(createMBeanInfo()); } catch (MBeanException e) { throw e; } catch (RuntimeOperationsException e) { throw e; } catch (Exception e) { throw new MBeanException (e, "Cannot instantiate ModelMBean of class " + getClassName()); } // Set the managed resource (if any) try { if (instance != null) mbean.setManagedResource(instance, "ObjectReference"); } catch (InstanceNotFoundException e) { throw e; } catch (InvalidTargetObjectTypeException e) { throw e; } return (mbean); } /** * Create and return a ModelMBeanInfo object that * describes this entire managed bean. */ public ModelMBeanInfo createMBeanInfo() { // Return our cached information (if any) if (info != null) return (info); // Create subordinate information descriptors as required AttributeInfo attrs[] = getAttributes(); ModelMBeanAttributeInfo attributes[] = new ModelMBeanAttributeInfo[attrs.length]; for (int i = 0; i < attrs.length; i++) attributes[i] = attrs[i].createAttributeInfo(); ConstructorInfo consts[] = getConstructors(); ModelMBeanConstructorInfo constructors[] = new ModelMBeanConstructorInfo[consts.length]; for (int i = 0; i < consts.length; i++) constructors[i] = consts[i].createConstructorInfo(); NotificationInfo notifs[] = getNotifications(); ModelMBeanNotificationInfo notifications[] = new ModelMBeanNotificationInfo[notifs.length]; for (int i = 0; i < notifs.length; i++) notifications[i] = notifs[i].createNotificationInfo(); OperationInfo opers[] = getOperations(); ModelMBeanOperationInfo operations[] = new ModelMBeanOperationInfo[opers.length]; for (int i = 0; i < opers.length; i++) operations[i] = opers[i].createOperationInfo(); /* // Add operations for attribute getters and setters as needed ArrayList list = new ArrayList(); for (int i = 0; i < operations.length; i++) list.add(operations[i]); for (int i = 0; i < attributes.length; i++) { Descriptor descriptor = attributes[i].getDescriptor(); String getMethod = (String) descriptor.getFieldValue("getMethod"); if (getMethod != null) { OperationInfo oper = new OperationInfo(getMethod, true, attributes[i].getType()); list.add(oper.createOperationInfo()); } String setMethod = (String) descriptor.getFieldValue("setMethod"); if (setMethod != null) { OperationInfo oper = new OperationInfo(setMethod, false, attributes[i].getType()); list.add(oper.createOperationInfo()); } } if (list.size() > operations.length) operations = (ModelMBeanOperationInfo[]) list.toArray(operations); */ // Construct and return a new ModelMBeanInfo object info = new ModelMBeanInfoSupport (getClassName(), getDescription(), attributes, constructors, operations, notifications); try { Descriptor descriptor = info.getMBeanDescriptor(); Iterator fields = getFields().iterator(); while (fields.hasNext()) { FieldInfo field = (FieldInfo) fields.next(); descriptor.setField(field.getName(), field.getValue()); } info.setMBeanDescriptor(descriptor); } catch (MBeanException e) { ; } return (info); } /** * Return a string representation of this managed bean. */ public String toString() { StringBuffer sb = new StringBuffer("ManagedBean["); sb.append("name="); sb.append(name); sb.append(", className="); sb.append(className); sb.append(", description="); sb.append(description); if (group != null) { sb.append(", group="); sb.append(group); } sb.append(", type="); sb.append(type); sb.append("]"); return (sb.toString()); } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/mbeans/MBeanProxy.java100644 0 0 5466 10636604104 25517 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.mbeans; import java.util.HashMap; import javax.management.Attribute; import javax.management.AttributeNotFoundException; import javax.management.MBeanException; import javax.management.ReflectionException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.modeler.BaseModelMBean; /** Use the same metadata, except that we replace the attribute * get/set methods. */ class MBeanProxy extends BaseModelMBean { private static Log log = LogFactory.getLog(MBeanProxy.class); HashMap atts=new HashMap(); SimpleRemoteConnector jkmx; public MBeanProxy(SimpleRemoteConnector jkmx, String code) throws Exception { this.jkmx=jkmx; initModelInfo(code); } /** Called by the connector - will update the value when a chunk of * data is received */ protected void update( String name, String val ) { if( log.isTraceEnabled() ) log.trace( "Updating " + oname + " " + name + " " + val); // XXX Conversions !!! atts.put( name, val); } public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { // If we're stale - refresh values jkmx.refresh(); return atts.get(name); } public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { try { jkmx.setAttribute(oname, attribute); } catch( Exception ex ) { throw new MBeanException(ex); } } public Object invoke(String name, Object params[], String signature[]) throws MBeanException, ReflectionException { try { jkmx.invoke(oname, name, params, signature); } catch( Exception ex ) { throw new MBeanException(ex); } return null; } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/mbeans/SimpleRemoteConnector.java100644 0 0 26540 10636604104 27767 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.mbeans; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.jar.Attributes; import java.util.jar.Manifest; import javax.management.Attribute; import javax.management.AttributeNotFoundException; import javax.management.MBeanException; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.ReflectionException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.modeler.Registry; /** * Based on jk2 proxy. * * Proxy using a very simple HTTP based protocol. * * For efficiency, it'll get bulk results and cache them - you * can force an update by calling the refreshAttributes and refreshMetadata * operations on this mbean. * * TODO: implement the user/pass auth ( right now you must use IP based security ) * TODO: eventually support https * TODO: support for metadata ( mbean-descriptors ) for description and type conversions * TODO: filter out trivial components ( mutexes, etc ) * * @author Costin Manolache */ public class SimpleRemoteConnector { private static Log log = LogFactory.getLog(SimpleRemoteConnector.class); // HTTP port of the remote JMX String webServerHost="localhost"; int webServerPort=8080; // URL of the remote JMX servlet ( or equivalent ) String statusPath="/jkstatus"; // Not used right now String user; String pass; // Domain we mirror String domain; // XXX Not used - allow translations String localDomain; String filter; // long lastRefresh=0; long updateInterval=5000; // 5 sec - it's min time between updates String prefix=""; Registry reg; MBeanServer mserver; // Last view HashMap mbeans=new HashMap(); public SimpleRemoteConnector() { } /* -------------------- Public methods -------------------- */ public String getWebServerHost() { return webServerHost; } public void setWebServerHost(String webServerHost) { this.webServerHost = webServerHost; } public int getWebServerPort() { return webServerPort; } public void setWebServerPort(int webServerPort) { this.webServerPort = webServerPort; } public long getUpdateInterval() { return updateInterval; } public void setUpdateInterval(long updateInterval) { this.updateInterval = updateInterval; } public String getUser() { return user; } public void setUser(String user) { this.user = user; } public String getPass() { return pass; } public String getDomain() { return domain; } public void setDomain(String domain) { this.domain = domain; } public void setPass(String pass) { this.pass = pass; } public String getStatusPath() { return statusPath; } public void setStatusPath(String statusPath) { this.statusPath = statusPath; } public String getFilter() { return filter; } public void setFilter(String filter) { this.filter = filter; } /* ==================== Start/stop ==================== */ public void destroy() { try { // We should keep track of loaded beans and call stop. // Modeler should do it... Iterator mbeansIt=mbeans.values().iterator(); while( mbeansIt.hasNext()) { MBeanProxy proxy=(MBeanProxy)mbeansIt.next(); ObjectName oname=proxy.getJmxName(); Registry.getRegistry().getMBeanServer().unregisterMBean(oname); } } catch( Throwable t ) { log.error( "Destroy error", t ); } } public void init() throws IOException { try { //if( log.isDebugEnabled() ) log.info("init " + webServerHost + " " + webServerPort); reg=Registry.getRegistry(); // Get metadata for all mbeans on the remote side //refreshMetadata(); // Get current values and mbeans refreshAttributes(); } catch( Throwable t ) { log.error( "Init error", t ); } } public void start() throws IOException { System.out.println("XXX start"); if( reg==null) init(); } /** Refresh the proxies, if updateInterval passed * */ public void refresh() { long time=System.currentTimeMillis(); if( time - lastRefresh < updateInterval ) { return; } System.out.println("refresh... "); lastRefresh=time; //refreshMetadata(); refreshAttributes(); } public void refreshAttributes() { try { int cnt=0; // connect to apache, get a list of mbeans if( filter==null ) { filter=domain + ":*"; } InputStream is=getStream( "qry=" + filter); if( is==null ) return; Manifest mf=new Manifest(is); HashMap currentObjects=new HashMap(); // used to remove older ones Map entries=mf.getEntries(); Iterator it=entries.keySet().iterator(); while( it.hasNext() ) { String name=(String)it.next(); Attributes attrs=(Attributes)entries.get( name ); ObjectName oname=new ObjectName(name); currentObjects.put( oname, ""); MBeanProxy proxy=(MBeanProxy)mbeans.get(oname); if( proxy==null ) { log.debug( "New object " + name); String code=attrs.getValue("modelerType"); if(log.isDebugEnabled()) log.debug("Register " + name + " " + code ); proxy= new MBeanProxy(this, code); mbeans.put( oname, proxy ); // Register MBeanServer mserver=Registry.getRegistry().getMBeanServer(); if( ! mserver.isRegistered(oname ) ) { mserver.registerMBean(proxy, oname); } } Iterator it2=attrs.keySet().iterator(); while( it2.hasNext() ) { Object o=it2.next(); String att=(o==null) ? null : o.toString(); if( "modelerType".equals( att )) continue; String val=attrs.getValue(att); proxy.update(att, val); cnt++; } } // Now we have to remove all the mbeans that are no longer there Iterator existingIt=mbeans.keySet().iterator(); while( existingIt.hasNext() ) { ObjectName on=(ObjectName)existingIt.next(); if(currentObjects.get( on ) != null ) continue; // still alive if( log.isDebugEnabled() ) log.debug("No longer alive " + on); try { mserver.unregisterMBean(on); } catch( Throwable t ) { log.info("Error unregistering " + on + " " + t.toString()); } } log.info( "Refreshing attributes " + cnt); } catch( Exception ex ) { log.info("Error ", ex); } } // Not used right now - assume the metadata is available locally // Could use mbeans-descriptors.xml or other formats. // Will be called if code= is not found locally public void refreshMetadata() { try { int cnt=0; int newCnt=0; InputStream is=getStream("getMetadata=" + domain + ":*"); if( is==null ) return; log.info( "Refreshing metadata " + cnt + " " + newCnt); } catch( Exception ex ) { log.info("Error ", ex); } } public Object invoke(Object oname, String name, Object params[], String signature[]) throws MBeanException, ReflectionException { try { // we support only string values InputStream is=this.getStream("invoke=" + name + "&name=" + oname.toString() ); if( is==null ) return null; // String res=is.readLine(); // if( log.isDebugEnabled()) // log.debug( "Invoking " + jkName + " " + name + " result " + res); //this.refreshMetadata(); this.refreshAttributes(); } catch( Exception ex ) { throw new MBeanException(ex); } return null; } public void setAttribute(ObjectName oname, Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { try { // we support only string values String val=(String)attribute.getValue(); String name=attribute.getName(); InputStream is=this.getStream("set=" + name + "&name=" + oname.toString() + "&value=" + val); if( is==null ) return; // String res=is.readLine(); // if( log.isDebugEnabled()) // log.debug( "Setting " + jkName + " " + name + " result " + res); //this.refreshMetadata(); this.refreshAttributes(); } catch( Exception ex ) { throw new MBeanException(ex); } } /** connect to apache using http, get a list of mbeans. Can be * overriten to support different protocols ( jk/Unix domain sockets, etc ) */ protected InputStream getStream(String qry) throws Exception { try { String path=statusPath + "?" + qry; URL url=new URL( "http", webServerHost, webServerPort, path); log.debug( "Connecting to " + url); URLConnection urlc=url.openConnection(); InputStream is=urlc.getInputStream(); return is; } catch (IOException e) { log.info( "Can't connect to jkstatus " + webServerHost + ":" + webServerPort + " " + e.toString()); return null; } } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/mbeans-descriptors.dtd100644 0 0 24501 10636604104 25673 0ustar 0 0 ././@LongLink100644 0 0 153 10636604104 10252 Lustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsDigesterSource.javacommons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsDigesterSourc100644 0 0 21274 10636604104 31123 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.modules; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.List; import org.apache.commons.digester.Digester; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.modeler.Registry; public class MbeansDescriptorsDigesterSource extends ModelerSource { private static Log log = LogFactory.getLog(MbeansDescriptorsDigesterSource.class); Registry registry; String location; String type; Object source; List mbeans=new ArrayList(); public void setRegistry(Registry reg) { this.registry=reg; } public void setLocation( String loc ) { this.location=loc; } /** Used if a single component is loaded * * @param type */ public void setType( String type ) { this.type=type; } public void setSource( Object source ) { this.source=source; } public List loadDescriptors( Registry registry, String location, String type, Object source) throws Exception { setRegistry(registry); setLocation(location); setType(type); setSource(source); execute(); return mbeans; } public void execute() throws Exception { if( registry==null ) registry=Registry.getRegistry(); InputStream stream=(InputStream)source; long t1=System.currentTimeMillis(); Digester digester = new Digester(); digester.setNamespaceAware(false); digester.setValidating(false); URL url = registry.getClass().getResource ("/org/apache/commons/modeler/mbeans-descriptors.dtd"); digester.register ("-//Apache Software Foundation//DTD Model MBeans Configuration File", url.toString()); // Push our registry object onto the stack digester.push(mbeans); // Configure the parsing rules digester.addObjectCreate ("mbeans-descriptors/mbean", "org.apache.commons.modeler.ManagedBean"); digester.addSetProperties ("mbeans-descriptors/mbean"); digester.addSetNext ("mbeans-descriptors/mbean", "add", "java.lang.Object"); digester.addObjectCreate ("mbeans-descriptors/mbean/attribute", "org.apache.commons.modeler.AttributeInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/attribute"); digester.addSetNext ("mbeans-descriptors/mbean/attribute", "addAttribute", "org.apache.commons.modeler.AttributeInfo"); digester.addObjectCreate ("mbeans-descriptors/mbean/attribute/descriptor/field", "org.apache.commons.modeler.FieldInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/attribute/descriptor/field"); digester.addSetNext ("mbeans-descriptors/mbean/attribute/descriptor/field", "addField", "org.apache.commons.modeler.FieldInfo"); digester.addObjectCreate ("mbeans-descriptors/mbean/constructor", "org.apache.commons.modeler.ConstructorInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/constructor"); digester.addSetNext ("mbeans-descriptors/mbean/constructor", "addConstructor", "org.apache.commons.modeler.ConstructorInfo"); digester.addObjectCreate ("mbeans-descriptors/mbean/constructor/descriptor/field", "org.apache.commons.modeler.FieldInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/constructor/descriptor/field"); digester.addSetNext ("mbeans-descriptors/mbean/constructor/descriptor/field", "addField", "org.apache.commons.modeler.FieldInfo"); digester.addObjectCreate ("mbeans-descriptors/mbean/constructor/parameter", "org.apache.commons.modeler.ParameterInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/constructor/parameter"); digester.addSetNext ("mbeans-descriptors/mbean/constructor/parameter", "addParameter", "org.apache.commons.modeler.ParameterInfo"); digester.addObjectCreate ("mbeans-descriptors/mbean/descriptor/field", "org.apache.commons.modeler.FieldInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/descriptor/field"); digester.addSetNext ("mbeans-descriptors/mbean/descriptor/field", "addField", "org.apache.commons.modeler.FieldInfo"); digester.addObjectCreate ("mbeans-descriptors/mbean/notification", "org.apache.commons.modeler.NotificationInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/notification"); digester.addSetNext ("mbeans-descriptors/mbean/notification", "addNotification", "org.apache.commons.modeler.NotificationInfo"); digester.addObjectCreate ("mbeans-descriptors/mbean/notification/descriptor/field", "org.apache.commons.modeler.FieldInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/notification/descriptor/field"); digester.addSetNext ("mbeans-descriptors/mbean/notification/descriptor/field", "addField", "org.apache.commons.modeler.FieldInfo"); digester.addCallMethod ("mbeans-descriptors/mbean/notification/notification-type", "addNotifType", 0); digester.addObjectCreate ("mbeans-descriptors/mbean/operation", "org.apache.commons.modeler.OperationInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/operation"); digester.addSetNext ("mbeans-descriptors/mbean/operation", "addOperation", "org.apache.commons.modeler.OperationInfo"); digester.addObjectCreate ("mbeans-descriptors/mbean/operation/descriptor/field", "org.apache.commons.modeler.FieldInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/operation/descriptor/field"); digester.addSetNext ("mbeans-descriptors/mbean/operation/descriptor/field", "addField", "org.apache.commons.modeler.FieldInfo"); digester.addObjectCreate ("mbeans-descriptors/mbean/operation/parameter", "org.apache.commons.modeler.ParameterInfo"); digester.addSetProperties ("mbeans-descriptors/mbean/operation/parameter"); digester.addSetNext ("mbeans-descriptors/mbean/operation/parameter", "addParameter", "org.apache.commons.modeler.ParameterInfo"); // Process the input file to configure our registry try { digester.parse(stream); } catch (Exception e) { log.error("Error digesting Registry data", e); throw e; } long t2=System.currentTimeMillis(); // if( t2-t1 > 500 ) log.info("Loaded registry information (digester) " + ( t2 - t1 ) + " ms"); } } ././@LongLink100644 0 0 146 10636604104 10254 Lustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsDOMSource.javacommons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsDOMSource.jav100644 0 0 27247 10636604104 30726 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.modules; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.modeler.AttributeInfo; import org.apache.commons.modeler.ConstructorInfo; import org.apache.commons.modeler.FieldInfo; import org.apache.commons.modeler.ManagedBean; import org.apache.commons.modeler.NotificationInfo; import org.apache.commons.modeler.OperationInfo; import org.apache.commons.modeler.ParameterInfo; import org.apache.commons.modeler.Registry; import org.apache.commons.modeler.util.DomUtil; import org.w3c.dom.Document; import org.w3c.dom.Node; public class MbeansDescriptorsDOMSource extends ModelerSource { private static Log log = LogFactory.getLog(MbeansDescriptorsDOMSource.class); Registry registry; String location; String type; Object source; List mbeans=new ArrayList(); public void setRegistry(Registry reg) { this.registry=reg; } public void setLocation( String loc ) { this.location=loc; } /** Used if a single component is loaded * * @param type */ public void setType( String type ) { this.type=type; } public void setSource( Object source ) { this.source=source; } public List loadDescriptors( Registry registry, String location, String type, Object source) throws Exception { setRegistry(registry); setLocation(location); setType(type); setSource(source); execute(); return mbeans; } public void execute() throws Exception { if( registry==null ) registry=Registry.getRegistry(); try { InputStream stream=(InputStream)source; long t1=System.currentTimeMillis(); Document doc=DomUtil.readXml(stream); // Ignore for now the name of the root element Node descriptorsN=doc.getDocumentElement(); //Node descriptorsN=DomUtil.getChild(doc, "mbeans-descriptors"); if( descriptorsN == null ) { log.error("No descriptors found"); return; } Node firstMbeanN=null; if( "mbean".equals( descriptorsN.getNodeName() ) ) { firstMbeanN=descriptorsN; } else { firstMbeanN=DomUtil.getChild(descriptorsN, "mbean"); } if( firstMbeanN==null ) { log.error(" No mbean tags "); return; } // Process each element for (Node mbeanN = firstMbeanN; mbeanN != null; mbeanN= DomUtil.getNext(mbeanN)) { // Create a new managed bean info ManagedBean managed=new ManagedBean(); DomUtil.setAttributes(managed, mbeanN); Node firstN; // Process descriptor subnode Node mbeanDescriptorN = DomUtil.getChild(mbeanN, "descriptor"); if (mbeanDescriptorN != null) { Node firstFieldN = DomUtil.getChild(mbeanDescriptorN, "field"); for (Node fieldN = firstFieldN; fieldN != null; fieldN = DomUtil.getNext(fieldN)) { FieldInfo fi = new FieldInfo(); DomUtil.setAttributes(fi, fieldN); managed.addField(fi); } } // process attribute nodes firstN=DomUtil.getChild( mbeanN, "attribute"); for (Node descN = firstN; descN != null; descN = DomUtil.getNext( descN )) { // Create new attribute info AttributeInfo ai=new AttributeInfo(); DomUtil.setAttributes(ai, descN); // Process descriptor subnode Node descriptorN = DomUtil.getChild(descN, "descriptor"); if (descriptorN != null) { Node firstFieldN = DomUtil.getChild(descriptorN, "field"); for (Node fieldN = firstFieldN; fieldN != null; fieldN = DomUtil.getNext(fieldN)) { FieldInfo fi = new FieldInfo(); DomUtil.setAttributes(fi, fieldN); ai.addField(fi); } } // Add this info to our managed bean info managed.addAttribute( ai ); if (log.isTraceEnabled()) { log.trace("Create attribute " + ai); } } // process constructor nodes firstN=DomUtil.getChild( mbeanN, "constructor"); for (Node descN = firstN; descN != null; descN = DomUtil.getNext( descN )) { // Create new constructor info ConstructorInfo ci=new ConstructorInfo(); DomUtil.setAttributes(ci, descN); // Process descriptor subnode Node firstDescriptorN = DomUtil.getChild(descN, "descriptor"); if (firstDescriptorN != null) { Node firstFieldN = DomUtil.getChild(firstDescriptorN, "field"); for (Node fieldN = firstFieldN; fieldN != null; fieldN = DomUtil.getNext(fieldN)) { FieldInfo fi = new FieldInfo(); DomUtil.setAttributes(fi, fieldN); ci.addField(fi); } } // Process parameter subnodes Node firstParamN=DomUtil.getChild( descN, "parameter"); for (Node paramN = firstParamN; paramN != null; paramN = DomUtil.getNext(paramN)) { ParameterInfo pi=new ParameterInfo(); DomUtil.setAttributes(pi, paramN); ci.addParameter( pi ); } // Add this info to our managed bean info managed.addConstructor( ci ); if (log.isTraceEnabled()) { log.trace("Create constructor " + ci); } } // process notification nodes firstN=DomUtil.getChild( mbeanN, "notification"); for (Node descN = firstN; descN != null; descN = DomUtil.getNext( descN )) { // Create new notification info NotificationInfo ni=new NotificationInfo(); DomUtil.setAttributes(ni, descN); // Process descriptor subnode Node firstDescriptorN = DomUtil.getChild(descN, "descriptor"); if (firstDescriptorN != null) { Node firstFieldN = DomUtil.getChild(firstDescriptorN, "field"); for (Node fieldN = firstFieldN; fieldN != null; fieldN = DomUtil.getNext(fieldN)) { FieldInfo fi = new FieldInfo(); DomUtil.setAttributes(fi, fieldN); ni.addField(fi); } } // Process notification-type subnodes Node firstParamN=DomUtil.getChild( descN, "notification-type"); for (Node paramN = firstParamN; paramN != null; paramN = DomUtil.getNext(paramN)) { ni.addNotifType( DomUtil.getContent(paramN) ); } // Add this info to our managed bean info managed.addNotification( ni ); if (log.isTraceEnabled()) { log.trace("Created notification " + ni); } } // process operation nodes firstN=DomUtil.getChild( mbeanN, "operation"); for (Node descN = firstN; descN != null; descN = DomUtil.getNext( descN )) { // Create new operation info OperationInfo oi=new OperationInfo(); DomUtil.setAttributes(oi, descN); // Process descriptor subnode Node firstDescriptorN = DomUtil.getChild(descN, "descriptor"); if (firstDescriptorN != null) { Node firstFieldN = DomUtil.getChild(firstDescriptorN, "field"); for (Node fieldN = firstFieldN; fieldN != null; fieldN = DomUtil.getNext(fieldN)) { FieldInfo fi = new FieldInfo(); DomUtil.setAttributes(fi, fieldN); oi.addField(fi); } } // Process parameter subnodes Node firstParamN=DomUtil.getChild( descN, "parameter"); for (Node paramN = firstParamN; paramN != null; paramN = DomUtil.getNext(paramN)) { ParameterInfo pi=new ParameterInfo(); DomUtil.setAttributes(pi, paramN); if( log.isTraceEnabled()) log.trace("Add param " + pi.getName()); oi.addParameter( pi ); } // Add this info to our managed bean info managed.addOperation( oi ); if( log.isTraceEnabled()) { log.trace("Create operation " + oi); } } // Add the completed managed bean info to the registry //registry.addManagedBean(managed); mbeans.add( managed ); } long t2=System.currentTimeMillis(); log.debug( "Reading descriptors ( dom ) " + (t2-t1)); } catch( Exception ex ) { log.error( "Error reading descriptors ", ex); } } } ././@LongLink100644 0 0 157 10636604104 10256 Lustar 0 0 commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsDynamicMBeanSource.javacommons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsDynamicMBeanS100644 0 0 13154 10636604104 30751 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.modules; import java.util.ArrayList; import java.util.List; import javax.management.DynamicMBean; import javax.management.MBeanAttributeInfo; import javax.management.MBeanInfo; import javax.management.MBeanOperationInfo; import javax.management.MBeanParameterInfo; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.modeler.AttributeInfo; import org.apache.commons.modeler.ManagedBean; import org.apache.commons.modeler.OperationInfo; import org.apache.commons.modeler.ParameterInfo; import org.apache.commons.modeler.Registry; /** Extract metadata from a dynamic mbean. * Used to wrap a dynamic mbean in order to implement persistence. * * This is really an ugly asspect of the JMX spec - we need to convery * from normal metainfo to model metainfo. The info is the same, but * they use a different class. Just like the DOM spec - where all implementations * get an order of unneeded complexity from the various types. * */ public class MbeansDescriptorsDynamicMBeanSource extends ModelerSource { private static Log log = LogFactory.getLog(MbeansDescriptorsDynamicMBeanSource.class); Registry registry; String location; String type; Object source; List mbeans=new ArrayList(); public void setRegistry(Registry reg) { this.registry=reg; } public void setLocation( String loc ) { this.location=loc; } /** Used if a single component is loaded * * @param type */ public void setType( String type ) { this.type=type; } public void setSource( Object source ) { this.source=source; } public List loadDescriptors( Registry registry, String location, String type, Object source) throws Exception { setRegistry(registry); setLocation(location); setType(type); setSource(source); execute(); return mbeans; } public void execute() throws Exception { if( registry==null ) registry=Registry.getRegistry(); try { ManagedBean managed=createManagedBean(registry, null, source, type); if( managed==null ) return; managed.setName( type ); mbeans.add(managed); } catch( Exception ex ) { log.error( "Error reading descriptors ", ex); } } // ------------ Implementation for non-declared introspection classes /** * XXX Find if the 'className' is the name of the MBean or * the real class ( I suppose first ) * XXX Read (optional) descriptions from a .properties, generated * from source * XXX Deal with constructors * */ public ManagedBean createManagedBean(Registry registry, String domain, Object realObj, String type) { if( ! ( realObj instanceof DynamicMBean )) { return null; } DynamicMBean dmb=(DynamicMBean)realObj; ManagedBean mbean= new ManagedBean(); MBeanInfo mbi=dmb.getMBeanInfo(); try { MBeanAttributeInfo attInfo[]=mbi.getAttributes(); for( int i=0; i updateInterval ) { lastUpdate=time; try { FileOutputStream fos=new FileOutputStream(location); DomUtil.writeXml(document, fos); } catch (TransformerException e) { log.error( "Error writing"); } catch (FileNotFoundException e) { log.error( "Error writing" ,e ); } } } private void processAttribute(MBeanServer server, Node descN, String objectName ) { String attName=DomUtil.getAttribute(descN, "name"); String value=DomUtil.getAttribute(descN, "value"); String type=null; // DomUtil.getAttribute(descN, "type"); if( value==null ) { // The value may be specified as CDATA value=DomUtil.getContent(descN); } try { if( log.isDebugEnabled()) log.debug("Set attribute " + objectName + " " + attName + " " + value); ObjectName oname=new ObjectName(objectName); // find the type if( type==null ) type=registry.getType( oname, attName ); if( type==null ) { log.info("Can't find attribute " + objectName + " " + attName ); } else { Object valueO=registry.convertValue( type, value); server.setAttribute(oname, new Attribute(attName, valueO)); } } catch( Exception ex) { log.error("Error processing attribute " + objectName + " " + attName + " " + value, ex); } } private ArgsInfo processArg(Node mbeanN) { Node firstArgN=DomUtil.getChild(mbeanN, "arg" ); if(firstArgN == null) { return null; } ArgsInfo info = new ArgsInfo(); // process all args for (Node argN = firstArgN; argN != null; argN = DomUtil.getNext( argN )) { String type=DomUtil.getAttribute(argN, "type"); String value=DomUtil.getAttribute(argN, "value"); if( value==null ) { // The value may be specified as CDATA value=DomUtil.getContent(argN); } info.addArgPair(type, registry.convertValue(type,value)); } return info; } private static class ArgsInfo { private List sigs = new ArrayList(); private List values = new ArrayList(); ArgsInfo() { } public String [] getSigs() { return (String [])sigs.toArray(new String[sigs.size()]); } public Object[] getValues () { return values.toArray(new Object[values.size()]); } public void addArgPair(String name, Object val) { sigs.add(name); values.add(val); } } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/MbeansSourceMBean.java100644 0 0 3472 10636604104 27162 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.modules; import java.util.List; /** * This mbean will load an extended mlet file ( similar in syntax with jboss ). * It'll keep track of all attribute changes and update the file when attributes * change. */ public interface MbeansSourceMBean { /** Set the source to be used to load the mbeans * * @param source File or URL */ public void setSource( Object source ); public Object getSource(); /** Return the list of loaded mbeans names * * @return List of ObjectName */ public List getMBeans(); /** Load the mbeans from the source. Called automatically on init() * * @throws Exception */ public void load() throws Exception; /** Call the init method on all mbeans. Will call load if not done already * * @throws Exception */ public void init() throws Exception; /** Save the file. */ public void save(); } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/ModelerSource.java100644 0 0 5374 10636604104 26444 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.modules; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.List; import javax.management.ObjectName; import org.apache.commons.modeler.Registry; /** Source for descriptor data. More sources can be added. * */ public class ModelerSource { protected Object source; protected String location; /** Load data, returns a list of items. * * @param registry * @param location * @param type * @param source Introspected object or some other source * @throws Exception */ public List loadDescriptors( Registry registry, String location, String type, Object source) throws Exception { // TODO return null; } /** Callback from the BaseMBean to notify that an attribute has changed. * Can be used to implement persistence. * * @param oname * @param name * @param value */ public void updateField( ObjectName oname, String name, Object value ) { // nothing by default } public void store() { // nothing } protected InputStream getInputStream() throws IOException { if( source instanceof URL ) { URL url=(URL)source; location=url.toString(); return url.openStream(); } else if( source instanceof File ) { location=((File)source).getAbsolutePath(); return new FileInputStream((File)source); } else if( source instanceof String) { location=(String)source; return new FileInputStream((String)source); } else if( source instanceof InputStream ) { return (InputStream)source; } return null; } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/modules/package.html100644 0 0 6254 10636604104 25310 0ustar 0 0 org.apache.commons.modeler.modules

Implementation classes - should not be used directly. The API is not stable but eventually the code will be refactored as a collection of mbeans that will be useable ( more or less ) indepedently.

The MbeanDescriptors* classes are used to extract metadata from different sources. They are result of few stages of refactoring - now they look very similar with ant tasks and are close to normal mbeans, with an execute() method. DOM, SER, Introspection and Dynamic mbean will load metadata from the corresponding sources.

MbeansSource will load an extended MLET file, similar with jboss. It is not completely implemented - only modeler mbeans and dynamic mbeans are loaded. The important characteristic is that all declared mbeans will be registered in the mbean server as model mbeans. For regular java classes, the description will be used to construct the model mbean. DynamicMbeans metadata will be converted to model mbean and the model mbean wrapper will be loaded.

The goal of MbeansSource is to implement a simple persistence mechanism. Since all components are model mbeans, we can detect all changes. The source will be loaded as DOM and modifications will be made to the tree. The save() method will save the DOM tree - preserving all comments and having only the changes that are needed.

There are few remaining issues. First, we need to use the persistence metadata to avoid saving transient fields ( we save an attribute when we detect a change - but we don't know if this attribute should be saved ). The solution is to use the persistence fields in the spec - with some reasonable defaults or patterns for introspection or backward compat.

Another problem is implementing adding and removing components. In catalina, a factory is used to create the components, and save will operate on all mbeans. For creation we need to also use a factory - using the "Type" as a parameter. This will also work very well with Ant1.6 where we can use the component factory to do a "natural" mapping ( i.e. mbeans can be treated as tasks, with attributes as task attributes ). The second part can be solve by either using a parameter on the factory method ( saveTo ? ), or by having a single mbeans source per domain.

commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/NotificationInfo.java100644 0 0 10144 10636604104 25475 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.io.Serializable; import javax.management.Descriptor; import javax.management.modelmbean.ModelMBeanNotificationInfo; /** *

Internal configuration information for a Notification * descriptor.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class NotificationInfo extends FeatureInfo implements Serializable { static final long serialVersionUID = -6319885418912650856L; // ----------------------------------------------------- Instance Variables /** * The ModelMBeanNotificationInfo object that corresponds * to this NotificationInfo instance. */ transient ModelMBeanNotificationInfo info = null; protected String notifTypes[] = new String[0]; // ------------------------------------------------------------- Properties /** * Override the description property setter. * * @param description The new description */ public void setDescription(String description) { super.setDescription(description); this.info = null; } /** * Override the name property setter. * * @param name The new name */ public void setName(String name) { super.setName(name); this.info = null; } /** * The set of notification types for this MBean. */ public String[] getNotifTypes() { return (this.notifTypes); } // --------------------------------------------------------- Public Methods /** * Add a new notification type to the set managed by an MBean. * * @param notifType The new notification type */ public void addNotifType(String notifType) { synchronized (notifTypes) { String results[] = new String[notifTypes.length + 1]; System.arraycopy(notifTypes, 0, results, 0, notifTypes.length); results[notifTypes.length] = notifType; notifTypes = results; this.info = null; } } /** * Create and return a ModelMBeanNotificationInfo object that * corresponds to the attribute described by this instance. */ public ModelMBeanNotificationInfo createNotificationInfo() { // Return our cached information (if any) if (info != null) return (info); // Create and return a new information object info = new ModelMBeanNotificationInfo (getNotifTypes(), getName(), getDescription()); Descriptor descriptor = info.getDescriptor(); addFields(descriptor); info.setDescriptor(descriptor); return (info); } /** * Return a string representation of this notification descriptor. */ public String toString() { StringBuffer sb = new StringBuffer("NotificationInfo["); sb.append("name="); sb.append(name); sb.append(", description="); sb.append(description); sb.append(", notifTypes="); sb.append(notifTypes.length); sb.append("]"); return (sb.toString()); } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/OperationInfo.java100644 0 0 16260 10636604104 25014 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.io.Serializable; import javax.management.Descriptor; import javax.management.MBeanParameterInfo; import javax.management.modelmbean.ModelMBeanOperationInfo; /** *

Internal configuration information for an Operation * descriptor.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class OperationInfo extends FeatureInfo implements Serializable { static final long serialVersionUID = 4418342922072614875L; // ----------------------------------------------------------- Constructors /** * Standard zero-arguments constructor. */ public OperationInfo() { super(); } /** * Special constructor for setting up getter and setter operations. * * @param name Name of this operation * @param getter Is this a getter (as opposed to a setter)? * @param type Data type of the return value (if this is a getter) * or the parameter (if this is a setter) * */ public OperationInfo(String name, boolean getter, String type) { super(); setName(name); if (getter) { setDescription("Attribute getter method"); setImpact("INFO"); setReturnType(type); setRole("getter"); } else { setDescription("Attribute setter method"); setImpact("ACTION"); setReturnType("void"); setRole("setter"); addParameter(new ParameterInfo("value", type, "New attribute value")); } } // ----------------------------------------------------- Instance Variables /** * The ModelMBeanOperationInfo object that corresponds * to this OperationInfo instance. */ transient ModelMBeanOperationInfo info = null; protected String impact = "UNKNOWN"; protected String role = "operation"; protected String returnType = "void"; // FIXME - Validate protected ParameterInfo parameters[] = new ParameterInfo[0]; // ------------------------------------------------------------- Properties /** * Override the description property setter. * * @param description The new description */ public void setDescription(String description) { super.setDescription(description); this.info = null; } /** * Override the name property setter. * * @param name The new name */ public void setName(String name) { super.setName(name); this.info = null; } /** * The "impact" of this operation, which should be a (case-insensitive) * string value "ACTION", "ACTION_INFO", "INFO", or "UNKNOWN". */ public String getImpact() { return (this.impact); } public void setImpact(String impact) { if (impact == null) this.impact = null; else this.impact = impact.toUpperCase(); } /** * The role of this operation ("getter", "setter", "operation", or * "constructor"). */ public String getRole() { return (this.role); } public void setRole(String role) { this.role = role; } /** * The fully qualified Java class name of the return type for this * operation. */ public String getReturnType() { return (this.returnType); } public void setReturnType(String returnType) { this.returnType = returnType; } /** * The set of parameters for this operation. */ public ParameterInfo[] getSignature() { return (this.parameters); } // --------------------------------------------------------- Public Methods /** * Add a new parameter to the set of arguments for this operation. * * @param parameter The new parameter descriptor */ public void addParameter(ParameterInfo parameter) { synchronized (parameters) { ParameterInfo results[] = new ParameterInfo[parameters.length + 1]; System.arraycopy(parameters, 0, results, 0, parameters.length); results[parameters.length] = parameter; parameters = results; this.info = null; } } /** * Create and return a ModelMBeanOperationInfo object that * corresponds to the attribute described by this instance. */ public ModelMBeanOperationInfo createOperationInfo() { // Return our cached information (if any) if (info != null) return (info); // Create and return a new information object ParameterInfo params[] = getSignature(); MBeanParameterInfo parameters[] = new MBeanParameterInfo[params.length]; for (int i = 0; i < params.length; i++) parameters[i] = params[i].createParameterInfo(); int impact = ModelMBeanOperationInfo.UNKNOWN; if ("ACTION".equals(getImpact())) impact = ModelMBeanOperationInfo.ACTION; else if ("ACTION_INFO".equals(getImpact())) impact = ModelMBeanOperationInfo.ACTION_INFO; else if ("INFO".equals(getImpact())) impact = ModelMBeanOperationInfo.INFO; info = new ModelMBeanOperationInfo (getName(), getDescription(), parameters, getReturnType(), impact); Descriptor descriptor = info.getDescriptor(); descriptor.removeField("class"); descriptor.setField("role", getRole()); addFields(descriptor); info.setDescriptor(descriptor); return (info); } /** * Return a string representation of this operation descriptor. */ public String toString() { StringBuffer sb = new StringBuffer("OperationInfo["); sb.append("name="); sb.append(name); sb.append(", description="); sb.append(description); sb.append(", returnType="); sb.append(returnType); sb.append(", parameters="); sb.append(parameters.length); sb.append("]"); return (sb.toString()); } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/package.html100644 0 0 25400 10636604104 23652 0ustar 0 0 Package Documentation for COMMONS-MODELER

The Modeler component of the Jakarta Commons subproject offers convenient support for configuring and instantiating Model MBeans (management beans), as described in the JMX Specification. It is typically used within a server-based application that wants to expose management features via JMX. See the JMX Specification (Version 1.1) for more information about Model MBeans and other JMX concepts.

Model MBeans are very powerful - and the JMX specification includes a mechanism to use a standard JMX-provided base class to satisfy many of the requirements, without having to create custom Model MBean implementation classes yourself. However, one of the requirements in creating such a Model MBean is to create the corresponding metadata information (i.e. an implementation of the javax.management.modelmbean.ModelMBeanInfo interface and its corresponding subordinate interfaces). Creating this information can be tedious and error prone. The Modeler package makes the process much simpler, because the required information is constructed dynamically from an easy-to-understand XML description of the metadata. Once you have the metadata defined, and registered at runtime in the provided Registry, Modeler also supports convenient factory methods to instantiate new Model MBean instances for you.

The steps required to use Modeler in your server-based application are described in detail below. You can find some simple usage code in the unit tests that come with Modeler (in the src/test subdirectory of the source distribution), and much more complex usage code in Tomcat 4.1 (in the org.apache.catalina.mbeans package).

. More advanced uses can be found in Tomcat 5 and jakarta-tomcat-connectors.

1. Acquire a JMX Implementation

Modeler has been tested with different JMX implementations:

After unpacking the release, you will need to ensure that the appropriate JAR file (jmxri.jar or mx4j.jar) is included on your compilation classpath, and in the classpath of your server application when it is executed.

2. Create a Modeler Configuration File

Modeler requires that you construct a configuration file that describes the metadata ultimately need to construct the javax.management.modelmbean.ModelMBeanInfo structure that is required by JMX. Your XML file must conform to the mbeans-descriptors.dtd DTD that defines the acceptable structure.

Fundamentally, you will be constructing an <mbean> element for each type of Model MBean that a registry will know how to create. Nested within this element will be other elements describing the constructors, attributes, operations, and notifications associated with this MBean. See the comments in the DTD for detailed information about the valid attributes and their meanings.

A simple example configuration file might include the following components (abstracted from the real definitions found in Tomcat 4.1's use of Modeler):


  <?xml version="1.0"?>
  <!DOCTYPE mbeans-descriptors PUBLIC
   "-//Apache Software Foundation//DTD Model MBeans Configuration File"
   "http://jakarta.apache.org/commons/dtds/mbeans-descriptors.dtd">

  <mbeans-descriptors>

    <!-- ... other MBean definitions ... -->

    <mbean         name="Group"
              className="org.apache.catalina.mbeans.GroupMBean"
            description="Group from a user database"
                 domain="Users"
                  group="Group"
                   type="org.apache.catalina.Group">

      <attribute   name="description"
            description="Description of this group"
                   type="java.lang.String"/>

      <attribute   name="groupname"
            description="Group name of this group"
                   type="java.lang.String"/>

      <attribute   name="roles"
            description="MBean Names of roles for this group"
                   type="java.lang.String[]"
              writeable="false"/>

      <attribute   name="users"
            description="MBean Names of user members of this group"
                   type="java.lang.String[]"
              writeable="false"/>

      <operation   name="addRole"
            description="Add a new authorized role for this group"
                 impact="ACTION"
             returnType="void">
        <parameter name="role"
            description="Role to be added"
                   type="java.lang.String"/>
      </operation>

      <operation   name="removeRole"
            description="Remove an old authorized role for this group"
                 impact="ACTION"
             returnType="void">
        <parameter name="role"
            description="Role to be removed"
                   type="java.lang.String"/>
      </operation>

      <operation   name="removeRoles"
            description="Remove all authorized roles for this group"
                 impact="ACTION"
             returnType="void">
      </operation>

    </mbean>

    <!-- ... other MBean definitions ... -->

  </mbeans-descriptors>

This MBean represents an instance of org.apache.catalina.Group, which is an entity representing a group of users (with a shared set of security roles that all users in the group inherit) in a user database. This MBean advertises support for four attributes (description, groupname, roles, and users) that roughly correspond to JavaBean properties. By default, attributes are assumed to have read/write access. For this particular MBean, the roles and users attributes are read-only (writeable="false"). Finally, this MBean supports three operations (addRole, removeRole, and removeRoles) that roughly correspond to JavaBean methods on the underlying component.

In general, Modeler provides a standard ModelMBean implementation that simply passes on JMX calls on attributes and operations directly through to the managed component that the ModelMBean is associated with. For special case requirements, you can define a subclass of BaseModelMBean that provides override methods for one or more of these attributes (i.e. the property getter and/or setter methods) and operations (i.e. direct method calls).

For this particular MBean, a custom BaseModelMBean implementation subclass is described (org.apache.catalina.mbeans.GroupMBean) is configured. It was necessary in this particular case because several of the underlying Catalina component's methods deal with internal objects or arrays of objects, rather than just the Strings and primitives that are supported by all JMX clients. Thus, the following method on the Group interface:

    public void addRole(Role role);

is represented, in the MBean, by an addRole method that takes a String argument representing the role name of the required role. The MBean's implementation class acts as an adapter, and looks up the required Role object (by name) before calling the addRole method on the underlying Group instance within the Server.

3. Create Modeler Registry at Startup Time

The metadata information, and the corresponding Model MBean factory, is represented at runtime in an instance of Registry whose contents are initialized from the configuration file prepared as was described above. Typically, such a file will be included in the JAR file containing the MBean implementation classes themselves, and loaded as follows:

    URL url= this.getClass().getResource
      ("/com/mycompany/mypackage/mbeans-descriptors.xml");
    Registry registry = Registry.getRegistry();
    registry.loadMetadata(url);

Besides using the configuration file, it is possible to configure the registry metadata by hand, using the addManagedBean() and removeManagedBean() methods. However, most users will find the standard support for loading a configuration file to be convenient and sufficient.

Modeler will also look for a mbeans-descriptors.xml in the same package with the class beeing registered and in its parent. If no metadata is found, modeler will use a number of simple patterns, similar with the ones used by ant, to determine a reasonable metadata

In a future version we should also support xdoclet-based generation of the descriptors

4. Instantiate Model MBeans As Needed

When your server application needs to instantiate a new MBean and register it with the corresponding MBeanServer, it can execute code like this:

  Group group = ... managed component instance ...;

  MBeanServer mserver = registry.getMBeanServer();

  String oname="myDomain:type=Group,name=myGroup";

  registry.registerComponent( group, oname, "Group" );

After the Model MBean has been created and registered, it is accessible to JMX clients through the standard JMX client APIs.

commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/ParameterInfo.java100644 0 0 10044 10636604104 24766 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.io.Serializable; import javax.management.MBeanParameterInfo; /** *

Internal configuration information for a Parameter * descriptor.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class ParameterInfo extends FeatureInfo implements Serializable { static final long serialVersionUID = 2222796006787664020L; // ----------------------------------------------------------- Constructors /** * Standard zero-arguments constructor. */ public ParameterInfo() { super(); } /** * Special constructor for setting up parameters programatically. * * @param name Name of this parameter * @param type Java class of this parameter * @param description Description of this parameter */ public ParameterInfo(String name, String type, String description) { super(); setName(name); setType(type); setDescription(description); } // ----------------------------------------------------- Instance Variables /** * The MBeanParameterInfo object that corresponds * to this ParameterInfo instance. */ transient MBeanParameterInfo info = null; protected String type = null; // ------------------------------------------------------------- Properties /** * Override the description property setter. * * @param description The new description */ public void setDescription(String description) { super.setDescription(description); this.info = null; } /** * Override the name property setter. * * @param name The new name */ public void setName(String name) { super.setName(name); this.info = null; } /** * The fully qualified Java class name of this parameter. */ public String getType() { return (this.type); } public void setType(String type) { this.type = type; this.info = null; } // --------------------------------------------------------- Public Methods /** * Create and return a MBeanParameterInfo object that * corresponds to the parameter described by this instance. */ public MBeanParameterInfo createParameterInfo() { // Return our cached information (if any) if (info != null) return (info); // Create and return a new information object info = new MBeanParameterInfo (getName(), getType(), getDescription()); return (info); } /** * Return a string representation of this parameter descriptor. */ public String toString() { StringBuffer sb = new StringBuffer("ParameterInfo["); sb.append("name="); sb.append(name); sb.append(", description="); sb.append(description); sb.append(", type="); sb.append(type); sb.append("]"); return (sb.toString()); } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/Registry.java100644 0 0 105337 10636604104 24074 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Collections; import java.util.Map; import javax.management.DynamicMBean; import javax.management.MBeanAttributeInfo; import javax.management.MBeanInfo; import javax.management.MBeanOperationInfo; import javax.management.MBeanRegistration; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.management.modelmbean.ModelMBean; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.modeler.modules.ModelerSource; /* Issues: - exceptions - too many "throws Exception" - double check the interfaces - start removing the use of the experimental methods in tomcat, then remove the methods ( before 1.1 final ) - is the security enough to prevent Registry beeing used to avoid the permission checks in the mbean server ? */ /** * Registry for modeler MBeans. * * This is the main entry point into modeler. It provides methods to create * and manipulate model mbeans and simplify their use. * * Starting with version 1.1, this is no longer a singleton and the static * methods are strongly deprecated. In a container environment we can expect * different applications to use different registries. * * This class is itself an mbean. * * IMPORTANT: public methods not marked with @since x.x are experimental or * internal. Should not be used. * * @author Craig R. McClanahan * @author Costin Manolache */ public class Registry implements RegistryMBean, MBeanRegistration { /** Experimental support for manifest-based discovery. */ public static String MODELER_MANIFEST="/META-INF/mbeans-descriptors.xml"; /** * The Log instance to which we will write our log messages. */ private static Log log = LogFactory.getLog(Registry.class); // Support for the factory methods /** Will be used to isolate different apps and enhance security */ private static HashMap perLoaderRegistries=null; /** * The registry instance created by our factory method the first time * it is called. */ private static Registry registry = null; // Per registy fields /** * The MBeanServer instance that we will use to register * management beans. */ private MBeanServer server = null; /** * The set of ManagedBean instances for the beans this registry * knows about, keyed by name. */ private final HashMap descriptors = new HashMap(); /** List of managed byeans, keyed by class name */ private final HashMap descriptorsByClass = new HashMap(); // map to avoid duplicated searching or loading descriptors private final Map searchedPaths= Collections.synchronizedMap(new HashMap()); private Object guard; // Id - small ints to use array access. No reset on stop() private Hashtable idDomains=new Hashtable(); private Hashtable ids=new Hashtable(); // ----------------------------------------------------------- Constructors /** */ public Registry() { super(); } // -------------------- Static methods -------------------- // Factories /** * Factory method to create (if necessary) and return our * Registry instance. * * Use this method to obtain a Registry - all other static methods * are deprecated and shouldn't be used. * * The current version uses a static - future versions could use * the thread class loader. * * @param key Support for application isolation. If null, the context class * loader will be used ( if setUseContextClassLoader is called ) or the * default registry is returned. * @param guard Prevent access to the registry by untrusted components * * @since 1.1 */ public synchronized static Registry getRegistry(Object key, Object guard) { Registry localRegistry; if( perLoaderRegistries!=null ) { if( key==null ) key=Thread.currentThread().getContextClassLoader(); if( key != null ) { localRegistry=(Registry)perLoaderRegistries.get(key); if( localRegistry == null ) { localRegistry=new Registry(); localRegistry.guard=guard; perLoaderRegistries.put( key, localRegistry ); return localRegistry; } if( localRegistry.guard != null && localRegistry.guard != guard ) { return null; // XXX Should I throw a permission ex ? } return localRegistry; } } // static if (registry == null) { registry = new Registry(); } if( registry.guard != null && registry.guard != guard ) { return null; } return (registry); } /** Allow containers to isolate apps. Can be called only once. * It is highly recommended you call this method if using Registry in * a container environment. The default is false for backward compatibility * * @param enable * @since 1.1 */ public static void setUseContextClassLoader( boolean enable ) { if( enable ) { perLoaderRegistries=new HashMap(); } } // -------------------- Generic methods -------------------- /** Set a guard object that will prevent access to this registry * by unauthorized components * * @param guard * * @since 1.1 */ public void setGuard( Object guard ) { if( this.guard!=null ) { return; // already set, only once } this.guard=guard; } /** Lifecycle method - clean up the registry metadata. * * @since 1.1 */ public void stop() { synchronized(descriptors) { descriptorsByClass.clear(); descriptors.clear(); searchedPaths.clear(); } } /** * Load an extended mlet file. The source can be an URL, File or * InputStream. * * All mbeans will be instantiated, registered and the attributes will be * set. The result is a list of ObjectNames. * * @param source InputStream or URL of the file * @param cl ClassLoader to be used to load the mbeans, or null to use the * default JMX mechanism ( i.e. all registered loaders ) * @return List of ObjectName for the loaded mbeans * @throws Exception * * @since 1.1 */ public List loadMBeans( Object source, ClassLoader cl ) throws Exception { return load("MbeansSource", source, null ); } /** Load descriptors. The source can be a File or URL or InputStream for the * descriptors file. In the case of File and URL, if the extension is ".ser" * a serialized version will be loaded. * * Also ( experimental for now ) a ClassLoader - in which case META-INF/ will * be used. * * This method should be used to explicitely load metadata - but this is not * required in most cases. The registerComponent() method will find metadata * in the same pacakge. * * @param source */ public void loadMetadata(Object source ) throws Exception { if( source instanceof ClassLoader ) { loadMetaInfDescriptors((ClassLoader)source); } else { loadDescriptors( null, source, null ); } } /** Register a bean by creating a modeler mbean and adding it to the * MBeanServer. * * If metadata is not loaded, we'll look up and read a file named * "mbeans-descriptors.ser" or "mbeans-descriptors.xml" in the same package * or parent. * * If the bean is an instance of DynamicMBean. it's metadata will be converted * to a model mbean and we'll wrap it - so modeler services will be supported * * If the metadata is still not found, introspection will be used to extract * it automatically. * * If an mbean is already registered under this name, it'll be first * unregistered. * * If the component implements MBeanRegistration, the methods will be called. * If the method has a method "setRegistry" that takes a RegistryMBean as * parameter, it'll be called with the current registry. * * * @param bean Object to be registered * @param oname Name used for registration * @param type The type of the mbean, as declared in mbeans-descriptors. If * null, the name of the class will be used. This can be used as a hint or * by subclasses. * * @since 1.1 */ public void registerComponent(Object bean, String oname, String type) throws Exception { registerComponent(bean, new ObjectName(oname), type); } /** Unregister a component. We'll first check if it is registered, * and mask all errors. This is mostly a helper. * * @param oname * * @since 1.1 */ public void unregisterComponent( String oname ) { try { unregisterComponent(new ObjectName(oname)); } catch (MalformedObjectNameException e) { log.info("Error creating object name " + e ); } } /** Invoke a operation on a list of mbeans. Can be used to implement * lifecycle operations. * * @param mbeans list of ObjectName on which we'll invoke the operations * @param operation Name of the operation ( init, start, stop, etc) * @param failFirst If false, exceptions will be ignored * @throws Exception * @since 1.1 */ public void invoke( List mbeans, String operation, boolean failFirst ) throws Exception { if( mbeans==null ) { return; } Iterator itr=mbeans.iterator(); while(itr.hasNext()) { Object current=itr.next(); ObjectName oN=null; try { if( current instanceof ObjectName) { oN=(ObjectName)current; } if( current instanceof String ) { oN=new ObjectName( (String)current ); } if( oN==null ) { continue; } if( getMethodInfo(oN, operation) == null) { continue; } getMBeanServer().invoke(oN, operation, new Object[] {}, new String[] {}); } catch( Exception t ) { if( failFirst ) throw t; log.info("Error initializing " + current + " " + t.toString()); } } } // -------------------- ID registry -------------------- /** Return an int ID for faster access. Will be used for notifications * and for other operations we want to optimize. * * @param domain Namespace * @param name Type of the notification * @return An unique id for the domain:name combination * @since 1.1 */ public synchronized int getId( String domain, String name) { if( domain==null) { domain=""; } Hashtable domainTable=(Hashtable)idDomains.get( domain ); if( domainTable == null ) { domainTable=new Hashtable(); idDomains.put( domain, domainTable); } if( name==null ) { name=""; } Integer i=(Integer)domainTable.get(name); if( i!= null ) { return i.intValue(); } int id[]=(int [])ids.get( domain ); if( id == null ) { id=new int[1]; ids.put( domain, id); } int code=id[0]++; domainTable.put( name, new Integer( code )); return code; } // -------------------- Metadata -------------------- // methods from 1.0 /** * Add a new bean metadata to the set of beans known to this registry. * This is used by internal components. * * @param bean The managed bean to be added * @since 1.0 */ public void addManagedBean(ManagedBean bean) { // XXX Use group + name synchronized(descriptors) { descriptors.put(bean.getName(), bean); if( bean.getType() != null ) { descriptorsByClass.put( bean.getType(), bean ); } } } /** * Find and return the managed bean definition for the specified * bean name, if any; otherwise return null. * * @param name Name of the managed bean to be returned. Since 1.1, both * short names or the full name of the class can be used. * @since 1.0 */ public ManagedBean findManagedBean(String name) { // XXX Group ?? Use Group + Type synchronized(descriptors) { ManagedBean mb=((ManagedBean) descriptors.get(name)); if( mb==null ) mb=(ManagedBean)descriptorsByClass.get(name); return mb; } } /** * Return the set of bean names for all managed beans known to * this registry. * * @since 1.0 */ public String[] findManagedBeans() { synchronized(descriptors) { return ((String[]) descriptors.keySet().toArray(new String[0])); } } /** * Return the set of bean names for all managed beans known to * this registry that belong to the specified group. * * @param group Name of the group of interest, or null * to select beans that do not belong to a group * @since 1.0 */ public String[] findManagedBeans(String group) { ArrayList results = new ArrayList(); synchronized (descriptors) { for (Iterator items = descriptors.values().iterator(); items.hasNext(); ) { ManagedBean item = (ManagedBean) items.next(); if (group == null) { if (item.getGroup() == null) { results.add(item.getName()); } } else if (group.equals(item.getGroup())) { results.add(item.getName()); } } } String values[] = new String[results.size()]; return ((String[]) results.toArray(values)); } /** * Remove an existing bean from the set of beans known to this registry. * * @param bean The managed bean to be removed * @since 1.0 */ public void removeManagedBean(ManagedBean bean) { // TODO: change this to use group/name synchronized (descriptors) { descriptors.remove(bean.getName()); descriptorsByClass.remove( bean.getType()); } } // -------------------- Deprecated 1.0 methods -------------------- /** * Factory method to create (if necessary) and return our * MBeanServer instance. * * @since 1.0 * @deprecated Use the instance method */ public static MBeanServer getServer() { return Registry.getRegistry().getMBeanServer(); } /** * Set the MBeanServer to be utilized for our * registered management beans. * * @param mbeanServer The new MBeanServer instance * @since 1.0 * @deprecated Use the instance method */ public static void setServer(MBeanServer mbeanServer) { Registry.getRegistry().setMBeanServer(mbeanServer); } /** * Load the registry from the XML input found in the specified input * stream. * * @param stream InputStream containing the registry configuration * information * * @exception Exception if any parsing or processing error occurs * @deprecated use normal class method instead * @since 1.0 */ public static void loadRegistry(InputStream stream) throws Exception { Registry registry = getRegistry(); registry.loadMetadata(stream); } /** Get a "singelton" registry, or one per thread if setUseContextLoader * was called * * @deprecated Not enough info - use the method that takes CL and domain * @since 1.0 */ public synchronized static Registry getRegistry() { return getRegistry(null, null); } // -------------------- Helpers -------------------- /** Get the type of an attribute of the object, from the metadata. * * @param oname * @param attName * @return null if metadata about the attribute is not found * @since 1.1 */ public String getType( ObjectName oname, String attName ) { String type=null; MBeanInfo info; try { info=server.getMBeanInfo(oname); } catch (Exception e) { log.info( "Can't find metadata for object" + oname ); return null; } MBeanAttributeInfo attInfo[]=info.getAttributes(); for( int i=0; iMBeanServer
instance. * */ public synchronized MBeanServer getMBeanServer() { long t1=System.currentTimeMillis(); if (server == null) { if( MBeanServerFactory.findMBeanServer(null).size() > 0 ) { server=(MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0); if( log.isDebugEnabled() ) { log.debug("Using existing MBeanServer " + (System.currentTimeMillis() - t1 )); } } else { server=MBeanServerFactory.createMBeanServer(); if( log.isDebugEnabled() ) { log.debug("Creating MBeanServer"+ (System.currentTimeMillis() - t1 )); } } } return (server); } /** Find or load metadata. */ public ManagedBean findManagedBean(Object bean, Class beanClass, String type) throws Exception { if( bean!=null && beanClass==null ) { beanClass=bean.getClass(); } if( type==null ) { type=beanClass.getName(); } // first look for existing descriptor ManagedBean managed = findManagedBean(type); // Search for a descriptor in the same package if( managed==null ) { // check package and parent packages if( log.isDebugEnabled() ) { log.debug( "Looking for descriptor "); } findDescriptor( beanClass, type ); managed=findManagedBean(type); } if( bean instanceof DynamicMBean ) { if( log.isDebugEnabled() ) { log.debug( "Dynamic mbean support "); } // Dynamic mbean loadDescriptors("MbeansDescriptorsDynamicMBeanSource", bean, type); managed=findManagedBean(type); } // Still not found - use introspection if( managed==null ) { if( log.isDebugEnabled() ) { log.debug( "Introspecting "); } // introspection loadDescriptors("MbeansDescriptorsIntrospectionSource", beanClass, type); managed=findManagedBean(type); if( managed==null ) { log.warn( "No metadata found for " + type ); return null; } managed.setName( type ); addManagedBean(managed); } return managed; } /** EXPERIMENTAL Convert a string to object, based on type. Used by several * components. We could provide some pluggability. It is here to keep * things consistent and avoid duplication in other tasks * * @param type Fully qualified class name of the resulting value * @param value String value to be converted * @return Converted value */ public Object convertValue(String type, String value) { Object objValue=value; if( type==null || "java.lang.String".equals( type )) { // string is default objValue=value; } else if( "javax.management.ObjectName".equals( type ) || "ObjectName".equals( type )) { try { objValue=new ObjectName( value ); } catch (MalformedObjectNameException e) { return null; } } else if( "java.lang.Integer".equals( type ) || "int".equals( type )) { objValue=new Integer( value ); } else if("java.lang.Long".equals( type ) || "long".equals( type )) { objValue = new Long( value ); } else if( "java.lang.Boolean".equals( type ) || "boolean".equals( type )) { objValue=Boolean.valueOf( value ); } return objValue; } /** Experimental. * * @param sourceType * @param source * @param param * @return List of descriptors * @throws Exception * @deprecated bad interface, mixing of metadata and mbeans */ public List load( String sourceType, Object source, String param) throws Exception { if( log.isTraceEnabled()) { log.trace("load " + source ); } String location=null; String type=null; Object inputsource=null; if( source instanceof DynamicMBean ) { sourceType="MbeansDescriptorsDynamicMBeanSource"; inputsource=source; } else if( source instanceof URL ) { URL url=(URL)source; location=url.toString(); type=param; inputsource=url.openStream(); if( sourceType == null ) { sourceType = sourceTypeFromExt(location); } } else if( source instanceof File ) { location=((File)source).getAbsolutePath(); inputsource=new FileInputStream((File)source); type=param; if( sourceType == null ) { sourceType = sourceTypeFromExt(location); } } else if( source instanceof InputStream ) { type=param; inputsource=source; } else if( source instanceof Class ) { location=((Class)source).getName(); type=param; inputsource=source; if( sourceType== null ) { sourceType="MbeansDescriptorsIntrospectionSource"; } } if( sourceType==null ) { sourceType="MbeansDescriptorsDOMSource"; } ModelerSource ds=getModelerSource(sourceType); List mbeans=ds.loadDescriptors(this, location, type, inputsource); return mbeans; } private String sourceTypeFromExt( String s ) { if( s.endsWith( ".ser")) { return "MbeansDescriptorsSerSource"; } else if( s.endsWith(".xml")) { return "MbeansDescriptorsDOMSource"; } return null; } /** Register a component * XXX make it private * * @param bean * @param oname * @param type * @throws Exception */ public void registerComponent(Object bean, ObjectName oname, String type) throws Exception { if( log.isDebugEnabled() ) { log.debug( "Managed= "+ oname); } if( bean ==null ) { log.error("Null component " + oname ); return; } try { if( type==null ) { type=bean.getClass().getName(); } ManagedBean managed = findManagedBean(bean.getClass(), type); // The real mbean is created and registered ModelMBean mbean = managed.createMBean(bean); if( getMBeanServer().isRegistered( oname )) { if( log.isDebugEnabled()) { log.debug("Unregistering existing component " + oname ); } getMBeanServer().unregisterMBean( oname ); } getMBeanServer().registerMBean( mbean, oname); } catch( Exception ex) { log.error("Error registering " + oname, ex ); throw ex; } } /** Lookup the component descriptor in the package and * in the parent packages. * * @param packageName */ public synchronized void loadDescriptors( String packageName, ClassLoader classLoader ) { String res=packageName.replace( '.', '/'); if( log.isTraceEnabled() ) { log.trace("Finding descriptor " + res ); } if( searchedPaths.get( packageName ) != null ) { return; } String descriptors=res + "/mbeans-descriptors.ser"; URL dURL=classLoader.getResource( descriptors ); if( dURL == null ) { descriptors=res + "/mbeans-descriptors.xml"; dURL=classLoader.getResource( descriptors ); } if( dURL == null ) { return; } log.debug( "Found " + dURL); searchedPaths.put( packageName, dURL ); try { if( descriptors.endsWith(".xml" )) loadDescriptors("MbeansDescriptorsDOMSource", dURL, null); else loadDescriptors("MbeansDescriptorsSerSource", dURL, null); } catch(Exception ex ) { log.error("Error loading " + dURL); } } /** Experimental. Will become private, some code may still use it * * @param sourceType * @param source * @param param * @throws Exception * @deprecated */ public void loadDescriptors( String sourceType, Object source, String param) throws Exception { List mbeans=load( sourceType, source, param ); if( mbeans == null) return; Iterator itr=mbeans.iterator(); while( itr.hasNext() ) { Object mb=itr.next(); if( mb instanceof ManagedBean) { addManagedBean((ManagedBean)mb); } } } /** Discover all META-INF/modeler.xml files in classpath and register * the components * * @since EXPERIMENTAL */ private void loadMetaInfDescriptors(ClassLoader cl) { try { Enumeration en=cl.getResources(MODELER_MANIFEST); while( en.hasMoreElements() ) { URL url=(URL)en.nextElement(); InputStream is=url.openStream(); if( log.isDebugEnabled()) log.debug("Loading " + url); loadDescriptors("MBeansDescriptorDOMSource", is, null ); } } catch( Exception ex ) { ex.printStackTrace(); } } /** Lookup the component descriptor in the package and * in the parent packages. * * @param beanClass * @param type */ private void findDescriptor( Class beanClass, String type ) { if( type==null ) { type=beanClass.getName(); } ClassLoader classLoader=null; if( beanClass!=null ) { classLoader=beanClass.getClassLoader(); } if( classLoader==null ) { classLoader=Thread.currentThread().getContextClassLoader(); } if( classLoader==null ) { classLoader=this.getClass().getClassLoader(); } String pkg=type; while( pkg.indexOf( ".") > 0 ) { int lastComp=pkg.lastIndexOf( "."); if( lastComp <= 0 ) return; pkg=pkg.substring(0, lastComp); if( searchedPaths.get( pkg ) != null ) { return; } loadDescriptors(pkg, classLoader); } } private ModelerSource getModelerSource( String type ) throws Exception { if( type==null ) type="MbeansDescriptorsDOMSource"; if( type.indexOf( ".") < 0 ) { type="org.apache.commons.modeler.modules." + type; } Class c=Class.forName( type ); ModelerSource ds=(ModelerSource)c.newInstance(); return ds; } // -------------------- Registration -------------------- public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { this.server=server; return name; } public void postRegister(Boolean registrationDone) { } public void preDeregister() throws Exception { } public void postDeregister() { } // -------------------- DEPRECATED METHODS -------------------- // May still be used in tomcat // Never part of an official release /** Called by a registry or by the container to unload a loader * @param loader */ public void unregisterRegistry(ClassLoader loader ) { // XXX Cleanup ? perLoaderRegistries.remove(loader); } public ManagedBean findManagedBean(Class beanClass, String type) throws Exception { return findManagedBean(null, beanClass, type); } /** * Set the MBeanServer to be utilized for our * registered management beans. * * @param server The new MBeanServer instance */ public void setMBeanServer( MBeanServer server ) { this.server=server; } public void resetMetadata() { stop(); } /** * Load the registry from the XML input found in the specified input * stream. * * @param source Source to be used to load. Can be an InputStream or URL. * * @exception Exception if any parsing or processing error occurs */ public void loadDescriptors( Object source ) throws Exception { loadDescriptors("MbeansDescriptorsDOMSource", source, null ); } /** @deprecated - may still be used in code using pre-1.1 builds */ public void registerComponent(Object bean, String domain, String type, String name) throws Exception { StringBuffer sb=new StringBuffer(); sb.append( domain ).append(":"); sb.append( name ); String nameStr=sb.toString(); ObjectName oname=new ObjectName( nameStr ); registerComponent(bean, oname, type ); } // should be removed public void unregisterComponent( String domain, String name ) { try { ObjectName oname=new ObjectName( domain + ":" + name ); // XXX remove from our tables. getMBeanServer().unregisterMBean( oname ); } catch( Throwable t ) { log.error( "Error unregistering mbean ", t ); } } public List loadMBeans( Object source ) throws Exception { return loadMBeans( source, null ); } /** * Load the registry from a cached .ser file. This is typically 2-3 times * faster than parsing the XML. * * @param source Source to be used to load. Can be an InputStream or URL. * * @exception Exception if any parsing or processing error occurs * @deprecated Loaded automatically or using a File or Url ending in .ser */ public void loadCachedDescriptors( Object source ) throws Exception { loadDescriptors("MbeansDescriptorsSerSource", source, null ); } } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/RegistryMBean.java100644 0 0 11726 10636604104 24755 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.util.List; /** * Interface for modeler MBeans. * * This is the main entry point into modeler. It provides methods to create * and manipulate model mbeans and simplify their use. * * Starting with version 1.1, this is no longer a singleton and the static * methods are strongly deprecated. In a container environment we can expect * different applications to use different registries. * * @author Craig R. McClanahan * @author Costin Manolache * * @since 1.1 */ public interface RegistryMBean { /** * Load an extended mlet file. The source can be an URL, File or * InputStream. * * All mbeans will be instantiated, registered and the attributes will be * set. The result is a list of ObjectNames. * * @param source InputStream or URL of the file * @param cl ClassLoader to be used to load the mbeans, or null to use the * default JMX mechanism ( i.e. all registered loaders ) * @return List of ObjectName for the loaded mbeans * @throws Exception * * @since 1.1 */ public List loadMBeans( Object source, ClassLoader cl ) throws Exception; /** Invoke an operation on a set of mbeans. * * @param mbeans List of ObjectNames * @param operation Operation to perform. Typically "init" "start" "stop" or "destroy" * @param failFirst Behavior in case of exceptions - if false we'll ignore * errors * @throws Exception */ public void invoke( List mbeans, String operation, boolean failFirst ) throws Exception; /** Register a bean by creating a modeler mbean and adding it to the * MBeanServer. * * If metadata is not loaded, we'll look up and read a file named * "mbeans-descriptors.ser" or "mbeans-descriptors.xml" in the same package * or parent. * * If the bean is an instance of DynamicMBean. it's metadata will be converted * to a model mbean and we'll wrap it - so modeler services will be supported * * If the metadata is still not found, introspection will be used to extract * it automatically. * * If an mbean is already registered under this name, it'll be first * unregistered. * * If the component implements MBeanRegistration, the methods will be called. * If the method has a method "setRegistry" that takes a RegistryMBean as * parameter, it'll be called with the current registry. * * * @param bean Object to be registered * @param oname Name used for registration * @param type The type of the mbean, as declared in mbeans-descriptors. If * null, the name of the class will be used. This can be used as a hint or * by subclasses. * * @since 1.1 */ public void registerComponent(Object bean, String oname, String type) throws Exception; /** Unregister a component. We'll first check if it is registered, * and mask all errors. This is mostly a helper. * * @param oname * * @since 1.1 */ public void unregisterComponent( String oname ); /** Return an int ID for faster access. Will be used for notifications * and for other operations we want to optimize. * * @param domain Namespace * @param name Type of the notification * @return An unique id for the domain:name combination * @since 1.1 */ public int getId( String domain, String name); /** Reset all metadata cached by this registry. Should be called * to support reloading. Existing mbeans will not be affected or modified. * * It will be called automatically if the Registry is unregistered. * @since 1.1 */ public void stop(); /** Load descriptors. The source can be a File, URL pointing to an * mbeans-descriptors.xml. * * Also ( experimental for now ) a ClassLoader - in which case META-INF/ will * be used. * * @param source */ public void loadMetadata(Object source ) throws Exception; } commons-modeler-2.0.1-src/src/java/org/apache/commons/modeler/util/DomUtil.java100644 0 0 22532 10636604104 24571 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.util; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** * Few simple utils to read DOM * * @author Costin Manolache */ public class DomUtil { private static org.apache.commons.logging.Log log= org.apache.commons.logging.LogFactory.getLog( DomUtil.class ); // -------------------- DOM utils -------------------- /** Get the trimed text content of a node or null if there is no text */ public static String getContent(Node n ) { if( n==null ) return null; Node n1=DomUtil.getChild(n, Node.TEXT_NODE); if( n1==null ) return null; String s1=n1.getNodeValue(); return s1.trim(); } /** Get the first element child. * @param parent lookup direct childs * @param name name of the element. If null return the first element. */ public static Node getChild( Node parent, String name ) { if( parent==null ) return null; Node first=parent.getFirstChild(); if( first==null ) return null; for (Node node = first; node != null; node = node.getNextSibling()) { //System.out.println("getNode: " + name + " " + node.getNodeName()); if( node.getNodeType()!=Node.ELEMENT_NODE) continue; if( name != null && name.equals( node.getNodeName() ) ) { return node; } if( name == null ) { return node; } } return null; } public static String getAttribute(Node element, String attName ) { NamedNodeMap attrs=element.getAttributes(); if( attrs==null ) return null; Node attN=attrs.getNamedItem(attName); if( attN==null ) return null; return attN.getNodeValue(); } public static void setAttribute(Node node, String attName, String val) { NamedNodeMap attributes=node.getAttributes(); Node attNode=node.getOwnerDocument().createAttribute(attName); attNode.setNodeValue( val ); attributes.setNamedItem(attNode); } public static void removeAttribute( Node node, String attName ) { NamedNodeMap attributes=node.getAttributes(); attributes.removeNamedItem(attName); } /** Set or replace the text value */ public static void setText(Node node, String val) { Node chld=DomUtil.getChild(node, Node.TEXT_NODE); if( chld == null ) { Node textN=node.getOwnerDocument().createTextNode(val); node.appendChild(textN); return; } // change the value chld.setNodeValue(val); } /** Find the first direct child with a given attribute. * @param parent * @param elemName name of the element, or null for any * @param attName attribute we're looking for * @param attVal attribute value or null if we just want any */ public static Node findChildWithAtt(Node parent, String elemName, String attName, String attVal) { Node child=DomUtil.getChild(parent, Node.ELEMENT_NODE); if( attVal== null ) { while( child!= null && ( elemName==null || elemName.equals( child.getNodeName())) && DomUtil.getAttribute(child, attName) != null ) { child=getNext(child, elemName, Node.ELEMENT_NODE ); } } else { while( child!= null && ( elemName==null || elemName.equals( child.getNodeName())) && ! attVal.equals( DomUtil.getAttribute(child, attName)) ) { child=getNext(child, elemName, Node.ELEMENT_NODE ); } } return child; } /** Get the first child's content ( ie it's included TEXT node ). */ public static String getChildContent( Node parent, String name ) { Node first=parent.getFirstChild(); if( first==null ) return null; for (Node node = first; node != null; node = node.getNextSibling()) { //System.out.println("getNode: " + name + " " + node.getNodeName()); if( name.equals( node.getNodeName() ) ) { return getContent( node ); } } return null; } /** Get the first direct child with a given type */ public static Node getChild( Node parent, int type ) { Node n=parent.getFirstChild(); while( n!=null && type != n.getNodeType() ) { n=n.getNextSibling(); } if( n==null ) return null; return n; } /** Get the next sibling with the same name and type */ public static Node getNext( Node current ) { String name=current.getNodeName(); int type=current.getNodeType(); return getNext( current, name, type); } /** Return the next sibling with a given name and type */ public static Node getNext( Node current, String name, int type) { Node first=current.getNextSibling(); if( first==null ) return null; for (Node node = first; node != null; node = node.getNextSibling()) { if( type >= 0 && node.getNodeType() != type ) continue; //System.out.println("getNode: " + name + " " + node.getNodeName()); if( name==null ) return node; if( name.equals( node.getNodeName() ) ) { return node; } } return null; } public static class NullResolver implements EntityResolver { public InputSource resolveEntity (String publicId, String systemId) throws SAXException, IOException { if( log.isTraceEnabled()) log.trace("ResolveEntity: " + publicId + " " + systemId); return new InputSource(new StringReader("")); } } public static void setAttributes( Object o, Node parent) { NamedNodeMap attrs=parent.getAttributes(); if( attrs==null ) return; for (int i=0; i 1 ) d("setProperty(" + o.getClass() + " " + name + "=" + value +")" ); String setter= "set" +capitalize(name); try { Method methods[]=findMethods( o.getClass() ); Method setPropertyMethod=null; // First, the ideal case - a setFoo( String ) method for( int i=0; i< methods.length; i++ ) { Class paramT[]=methods[i].getParameterTypes(); if( setter.equals( methods[i].getName() ) && paramT.length == 1 && "java.lang.String".equals( paramT[0].getName())) { methods[i].invoke( o, new Object[] { value } ); return; } } // Try a setFoo ( int ) or ( boolean ) for( int i=0; i< methods.length; i++ ) { boolean ok=true; if( setter.equals( methods[i].getName() ) && methods[i].getParameterTypes().length == 1) { // match - find the type and invoke it Class paramType=methods[i].getParameterTypes()[0]; Object params[]=new Object[1]; // Try a setFoo ( int ) if ("java.lang.Integer".equals( paramType.getName()) || "int".equals( paramType.getName())) { try { params[0]=new Integer(value); } catch( NumberFormatException ex ) {ok=false;} // Try a setFoo ( boolean ) } else if ("java.lang.Boolean". equals( paramType.getName()) || "boolean".equals( paramType.getName())) { params[0]=new Boolean(value); // Try a setFoo ( InetAddress ) } else if ("java.net.InetAddress". equals( paramType.getName())){ try{ params[0]= InetAddress.getByName(value); }catch(UnknownHostException exc) { d("Unable to resolve host name:" + value); ok=false; } // Try a setFoo ( Object ) } else if ("java.lang.Object". equals( paramType.getName())) { params[0] = value; // Unknown type } else { d("Unknown type " + paramType.getName() ); } if( ok ) { methods[i].invoke( o, params ); return; } } // save "setProperty" for later if( "setProperty".equals( methods[i].getName())) { setPropertyMethod=methods[i]; } } // Ok, no setXXX found, try a setProperty("name", "value") if( setPropertyMethod != null ) { Object params[]=new Object[2]; params[0]=name; params[1]=value; setPropertyMethod.invoke( o, params ); } } catch( IllegalArgumentException ex2 ) { System.err.println("IAE " + o + " " + name + " " + value); ex2.printStackTrace(); } catch( SecurityException ex1 ) { if( dbg > 0 ) d("SecurityException for " + o.getClass() + " " + name + "=" + value +")" ); if( dbg > 1 ) ex1.printStackTrace(); } catch (IllegalAccessException iae) { if( dbg > 0 ) d("IllegalAccessException for " + o.getClass() + " " + name + "=" + value +")" ); if( dbg > 1 ) iae.printStackTrace(); } catch (InvocationTargetException ie) { if( dbg > 0 ) d("InvocationTargetException for " + o.getClass() + " " + name + "=" + value +")" ); if( dbg > 1 ) ie.printStackTrace(); } } public static Object getProperty( Object o, String name ) { String getter= "get" +capitalize(name); try { Method methods[]=findMethods( o.getClass() ); Method getPropertyMethod=null; // First, the ideal case - a getFoo() method for( int i=0; i< methods.length; i++ ) { Class paramT[]=methods[i].getParameterTypes(); if( getter.equals( methods[i].getName() ) && paramT.length == 0 ) { return methods[i].invoke( o, (Object [])null ); } if( "getProperty".equals( methods[i].getName())) { getPropertyMethod=methods[i]; } if( "getAttribute".equals( methods[i].getName())) { getPropertyMethod=methods[i]; } } // Ok, no setXXX found, try a getProperty("name") if( getPropertyMethod != null ) { Object params[]=new Object[1]; params[0]=name; getPropertyMethod.invoke( o, params ); } } catch( IllegalArgumentException ex2 ) { System.err.println("IAE " + o + " " + name ); ex2.printStackTrace(); } catch( SecurityException ex1 ) { if( dbg > 0 ) d("SecurityException for " + o.getClass() + " " + name + ")" ); if( dbg > 1 ) ex1.printStackTrace(); } catch (IllegalAccessException iae) { if( dbg > 0 ) d("IllegalAccessException for " + o.getClass() + " " + name +")" ); if( dbg > 1 ) iae.printStackTrace(); } catch (InvocationTargetException ie) { if( dbg > 0 ) d("InvocationTargetException for " + o.getClass() + " " + name +")" ); if( dbg > 1 ) ie.printStackTrace(); } return null; } /** */ public static void setProperty( Object o, String name ) { String setter= "set" +capitalize(name); try { Method methods[]=findMethods( o.getClass() ); Method setPropertyMethod=null; // find setFoo() method for( int i=0; i< methods.length; i++ ) { Class paramT[]=methods[i].getParameterTypes(); if( setter.equals( methods[i].getName() ) && paramT.length == 0 ) { methods[i].invoke( o, new Object[] {} ); return; } } } catch( Exception ex1 ) { if( dbg > 0 ) d("Exception for " + o.getClass() + " " + name); if( dbg > 1 ) ex1.printStackTrace(); } } /** Replace ${NAME} with the property value * @deprecated Use the explicit method */ public static String replaceProperties(String value, Object getter ) { if( getter instanceof Hashtable ) return replaceProperties( value, (Hashtable)getter, null ); if( getter instanceof PropertySource ) { PropertySource src[]=new PropertySource[] {(PropertySource)getter}; return replaceProperties( value, null, src); } return value; } /** Replace ${NAME} with the property value */ public static String replaceProperties(String value, Hashtable staticProp, PropertySource dynamicProp[] ) { StringBuffer sb=new StringBuffer(); int prev=0; // assert value!=nil int pos; while( (pos=value.indexOf( "$", prev )) >= 0 ) { if(pos>0) { sb.append( value.substring( prev, pos ) ); } if( pos == (value.length() - 1)) { sb.append('$'); prev = pos + 1; } else if (value.charAt( pos + 1 ) != '{' ) { sb.append( value.charAt( pos + 1 ) ); prev=pos+2; // XXX } else { int endName=value.indexOf( '}', pos ); if( endName < 0 ) { sb.append( value.substring( pos )); prev=value.length(); continue; } String n=value.substring( pos+2, endName ); String v= null; if( staticProp != null ) { v=(String)((Hashtable)staticProp).get(n); } if( v==null && dynamicProp != null) { for( int i=0; icp to a Vector * jars as file URLs (We use Vector for JDK 1.1 compat). * * @param jars A vector of URLs * @param cp a String classpath of directory or jar file * elements separated by path.separator delimiters. */ public static void addJarsFromClassPath(Vector jars, String cp) throws IOException,MalformedURLException { String sep = System.getProperty("path.separator"); String token; StringTokenizer st; if(cp!=null){ st = new StringTokenizer(cp,sep); while(st.hasMoreTokens()){ File f = new File(st.nextToken()); String path = f.getCanonicalPath(); if(f.isDirectory()){ path += "/"; } URL url = new URL("file","",path); if(!jars.contains(url)){ jars.addElement(url); } } } } /** Return a URL[] that can be used to construct a class loader */ public static URL[] getClassPath(Vector v){ URL[] urls=new URL[ v.size() ]; for( int i=0; i= args.length ) return false; setProperty( proxy, arg, args[i]); break; } } } else { // if args1 is not specified,assume all other options have param i++; if( i >= args.length ) return false; setProperty( proxy,arg, args[i]); } } return true; } // -------------------- other utils -------------------- public static String[] findVoidSetters( Class c ) { Method m[]=findMethods( c ); if( m==null ) return null; Vector v=new Vector(); for( int i=0; i 0 ) d("callMethod1 " + target.getClass().getName() + " " + param1.getClass().getName() + " " + typeParam1 ); Class params[]=new Class[1]; if( typeParam1==null ) params[0]=param1.getClass(); else params[0]=cl.loadClass( typeParam1 ); Method m=findMethod( target.getClass(), methodN, params); if( m==null ) throw new NoSuchMethodException(target.getClass().getName() + " " + methodN); return m.invoke(target, new Object[] {param1 } ); } public static Object callMethod0( Object target, String methodN) throws Exception { if( target==null ) { d("Assert: Illegal params " + target ); return null; } if( dbg > 0 ) d("callMethod0 " + target.getClass().getName() + "." + methodN); Class params[]=new Class[0]; Method m=findMethod( target.getClass(), methodN, params); if( m==null ) throw new NoSuchMethodException(target.getClass().getName() + " " + methodN); return m.invoke(target, emptyArray ); } static Object[] emptyArray=new Object[] {}; public static Object callMethodN( Object target, String methodN, Object params[], Class typeParams[] ) throws Exception { Method m=null; m=findMethod( target.getClass(), methodN, typeParams ); if( m== null ) { d("Can't find method " + methodN + " in " + target + " CLASS " + target.getClass()); return null; } Object o=m.invoke( target, params ); if(dbg > 0 ) { // debug StringBuffer sb=new StringBuffer(); sb.append("" + target.getClass().getName() + "." + methodN + "( " ); for(int i=0; i0) sb.append( ", "); sb.append(params[i]); } sb.append(")"); d(sb.toString()); } return o; } // -------------------- Get property -------------------- // This provides a layer of abstraction public static interface PropertySource { public String getProperty( String key ); } public static interface AttributeHolder { public void setAttribute( String key, Object o ); } // debug -------------------- static final int dbg=0; static void d(String s ) { System.out.println("IntrospectionUtils: " + s ); } } commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/demo/Connector.java100644 0 0 7413 10636604104 25134 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.demo; /** *

Sample managed object for the Modeler Demonstration Application, * based on the Catalina architecture of Tomcat 4.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class Connector { // ----------------------------------------------------------- Constructors /** * Construct a default instance of this class. */ public Connector() { super(); } /** * Construct a configured instance of this class. * * @param port Port number * @param scheme Protocol (scheme) * @param secure Secure flag * @param service Associated service * @param container Associated container */ public Connector(int port, String scheme, boolean secure, Service service, Container container) { super(); setPort(port); setScheme(scheme); setSecure(secure); setService(service); setContainer(container); } // ----------------------------------------------------- Instance Variables // ------------------------------------------------------------- Properties /** * The Container for this Connector. */ private Container container = null; public Container getContainer() { return (this.container); } public void setContainer(Container container) { this.container = container; } /** * The port number of this Connector. */ private int port = 8080; public int getPort() { return (this.port); } public void setPort(int port) { this.port = port; } /** * The scheme of this Connector. */ private String scheme = "http"; public String getScheme() { return (this.scheme); } public void setScheme(String scheme) { this.scheme = scheme; } /** * The secure flag of this Connector. */ private boolean secure = false; public boolean getSecure() { return (this.secure); } public void setSecure(boolean secure) { this.secure = secure; } /** * The associated Service of this Connector. */ private Service service = null; public Service getService() { return (this.service); } public void setService(Service service) { this.service = service; } /** * Return a String representation of this object. */ public String toString() { StringBuffer sb = new StringBuffer("Connector["); sb.append("port="); sb.append(port); sb.append(", scheme="); sb.append(scheme); sb.append(", secure="); sb.append(secure); sb.append("]"); return (sb.toString()); } } commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/demo/Container.java100644 0 0 3517 10636604104 25125 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.demo; /** *

Sample managed object for the Modeler Demonstration Application, * based on the Catalina architecture of Tomcat 4.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public interface Container { // ----------------------------------------------------- Instance Variables // ------------------------------------------------------------- Properties /** * Return the name of this Container. */ public String getName(); /** * Set the name of this Container. * * @param name The new name */ public void setName(String name); /** * Return the parent Container of this Container. */ public Container getParent(); /** * Set the parent Container of this Container. * * @param parent The new parent container */ public void setParent(Container parent); } commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/demo/Demo.java100644 0 0 41175 10636604104 24111 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.demo; import java.io.InputStream; import java.net.URL; import java.util.Iterator; import javax.management.Attribute; import javax.management.Descriptor; import javax.management.MBeanAttributeInfo; import javax.management.MBeanConstructorInfo; import javax.management.MBeanException; import javax.management.MBeanNotificationInfo; import javax.management.MBeanOperationInfo; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.modelmbean.ModelMBean; import javax.management.modelmbean.ModelMBeanInfo; import org.apache.commons.modeler.ManagedBean; import org.apache.commons.modeler.Registry; /** *

Demonstration program for the Modeller package. Instantiates a set * of simple managed objects, and a set of corresponding MBeans, then * manipulates the objects through the MBean interfaces. * * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class Demo implements NotificationListener { // ----------------------------------------------------- Instance Variables // ------------------------------------------------------- Instance Methods /** * Handle the notification of a JMX event. * * @param notification The event that has occurred * @param handback The handback object for this event */ public void handleNotification(Notification notification, Object handback) { System.out.println("NOTIFICATION=" + notification + ", HANDBACK=" + handback); } // ------------------------------------------------------- Static Variables /** * The attribute notification listener. */ private static Demo demo = null; /** * The configuration information registry for our managed beans. */ private static Registry registry = null; /** * The MBeanServer for this application. */ private static MBeanServer server = null; /** * The managed object tree. */ private static Server tree = null; // ----------------------------------------------------------- Main Program /** * The main program for this demonstration. * * @param args Command line arguments */ public static void main(String arg[]) { createRegistry(); createServer(); createTree(); createMBeans(); listMBeans(); dumpServer(); updateServer(); } // -------------------------------------------------------- Support Methods /** * Create the MBeans that correspond to every node of our tree. */ private static void createMBeans() { try { // NOTE: JMXRI crashes on server.setAttribute() unless there has // been an attribute change listener registered at some point // on every ModelMBean. :-( // NOTE: Despite the documentation, you cannot register an // attribute change listener for all attributes. :-( Demo demo = new Demo(); System.out.println("Creating MBeans ..."); // Create the MBean for the top-level Server object String domain = server.getDefaultDomain(); ManagedBean managed = registry.findManagedBean("StandardServer"); ModelMBean mm = managed.createMBean(tree); mm.addAttributeChangeNotificationListener(demo, "shutdown", tree); mm.addAttributeChangeNotificationListener(demo, "port", tree); server.registerMBean(mm, createName(domain, tree)); // Create the MBean for each associated Service and friendes Service services[] = tree.findServices(); for (int i = 0; i < services.length; i++) { // The MBean for the Service itself managed = registry.findManagedBean("StandardService"); mm = managed.createMBean(services[i]); mm.addAttributeChangeNotificationListener(demo, "name", services[i]); server.registerMBean(mm, createName(domain, services[i])); // The MBean for the corresponding Engine managed = registry.findManagedBean("StandardEngine"); Engine container = (Engine) services[i].getContainer(); mm = managed.createMBean(container); mm.addAttributeChangeNotificationListener(demo, "name", container); server.registerMBean(mm, createName(domain, container)); // The MBeans for the corresponding Connectors managed = registry.findManagedBean("HttpConnector"); Connector connectors[] = services[i].findConnectors(); for (int j = 0; j < connectors.length; j++) { mm = managed.createMBean(connectors[j]); mm.addAttributeChangeNotificationListener(demo, "port", connectors[j]); server.registerMBean (mm, createName(domain, connectors[j])); } } } catch (MBeanException t) { Exception e = t.getTargetException(); if (e == null) e = t; System.out.println(e.getMessage()); e.printStackTrace(System.out); } catch (Throwable t) { System.out.println(t.getMessage()); t.printStackTrace(System.out); } } /** * Create an ObjectName for this object. * * @param domain Domain in which this name is to be created * @param connector The Connector to be named */ private static ObjectName createName(String domain, Connector connector) { ObjectName name = null; try { name = new ObjectName(domain + ":type=Connector,port=" + connector.getPort() + ",service=" + connector.getService().getName()); } catch (Throwable t) { System.out.println("Creating name for " + connector); t.printStackTrace(System.out); System.exit(1); } return (name); } /** * Create an ObjectName for this object. * * @param domain Domain in which this name is to be created * @param engine The Engine to be named */ private static ObjectName createName(String domain, Engine engine) { ObjectName name = null; try { name = new ObjectName(domain + ":type=Engine,service=" + engine.getService().getName()); } catch (Throwable t) { System.out.println("Creating name for " + engine); t.printStackTrace(System.out); System.exit(1); } return (name); } /** * Create an ObjectName for this object. * * @param domain Domain in which this name is to be created * @param server The Server to be named */ private static ObjectName createName(String domain, Server server) { ObjectName name = null; try { name = new ObjectName(domain + ":type=Server"); } catch (Throwable t) { System.out.println("Creating name for " + server); t.printStackTrace(System.out); System.exit(1); } return (name); } /** * Create an ObjectName for this object. * * @param domain Domain in which this name is to be created * @param service The Service to be named */ private static ObjectName createName(String domain, Service service) { ObjectName name = null; try { name = new ObjectName(domain + ":type=Service,name=" + service.getName()); } catch (Throwable t) { System.out.println("Creating name for " + server); t.printStackTrace(System.out); System.exit(1); } return (name); } /** * Create and configure the registry of managed objects. */ private static void createRegistry() { System.out.println("Create configuration registry ..."); try { URL url = Demo.class.getResource ("/org/apache/commons/modeler/demo/mbeans-descriptors.xml"); InputStream stream = url.openStream(); Registry.loadRegistry(stream); stream.close(); registry = Registry.getRegistry(); } catch (Throwable t) { t.printStackTrace(System.out); System.exit(1); } } /** * Create the MBeanServer with which we will be * registering our ModelMBean implementations. */ private static void createServer() { System.out.println("Creating MBeanServer ..."); try { // System.setProperty("LEVEL_TRACE", "true"); server = MBeanServerFactory.createMBeanServer(); } catch (Throwable t) { t.printStackTrace(System.out); System.exit(1); } } /** * Create the tree of managed objects. */ private static void createTree() { System.out.println("Create managed object tree ..."); tree = new Server(8005, "SHUTDOWN"); Service service = new Service("Standard Service", tree); tree.addService(service); Engine engine = new Engine("Standard Engine", "localhost", service); service.setContainer(engine); Connector conn1 = new Connector(8080, "http", false, service, engine); service.addConnector(conn1); Connector conn2 = new Connector(8443, "https", true, service, engine); service.addConnector(conn2); } /** * Dump known information about the "Server" we are managing. */ private static void dumpServer() { try { System.out.println("Dump ModelMBeanInfo for Server:"); ObjectName name = new ObjectName(server.getDefaultDomain() + ":type=Server"); // Return static ModelMBeanInfo information ModelMBeanInfo info = (ModelMBeanInfo) server.getMBeanInfo(name); System.out.println(" className=" + info.getClassName()); System.out.println(" description=" + info.getDescription()); System.out.println(" mbeanDescriptor=" + info.getMBeanDescriptor()); MBeanAttributeInfo attrs[] = info.getAttributes(); for (int i = 0; i < attrs.length; i++) System.out.println(" AttributeInfo=" + attrs[i]); MBeanConstructorInfo consts[] = info.getConstructors(); for (int i = 0; i < consts.length; i++) System.out.println(" ConstructorInfo=" + consts[i]); Descriptor descs[] = info.getDescriptors(null); for (int i = 0; i < descs.length; i++) System.out.println(" Descriptor=" + descs[i]); MBeanNotificationInfo notifs[] = info.getNotifications(); for (int i = 0; i < notifs.length; i++) System.out.println(" Notification=" + notifs[i]); MBeanOperationInfo opers[] = info.getOperations(); for (int i = 0; i < opers.length; i++) System.out.println(" Operation=" + opers[i]); } catch (MBeanException t) { Exception e = t.getTargetException(); if (e == null) e = t; System.out.println(e.getMessage()); e.printStackTrace(System.out); } catch (Throwable t) { System.out.println(t.getMessage()); t.printStackTrace(System.out); } } /** * List information about all registered MBeans. */ private static void listMBeans() { System.out.println("There are " + server.getMBeanCount().intValue() + " registered MBeans"); Iterator instances = server.queryMBeans(null, null).iterator(); while (instances.hasNext()) { ObjectInstance instance = (ObjectInstance) instances.next(); System.out.println(" objectName=" + instance.getObjectName() + ", className=" + instance.getClassName()); } } /** * Test updating an attribute through the JMX interfaces. */ private static void updateServer() { try { System.out.println("==========================================="); System.out.println("Test updating Server properties ..."); ObjectName name = new ObjectName(server.getDefaultDomain() + ":type=Server"); System.out.println(" Retrieving current value of 'shutdown'"); String value = (String) server.getAttribute(name, "shutdown"); if (!"SHUTDOWN".equals(value)) throw new IllegalStateException("Current shutdown value is '" + value + "'"); System.out.println(" Setting new value of 'shutdown'"); server.setAttribute(name, new Attribute("shutdown", "NEW VALUE")); System.out.println(" Checking new value of 'shutdown'"); value = (String) server.getAttribute(name, "shutdown"); if (!"NEW VALUE".equals(value)) throw new IllegalStateException("New shutdown value is '" + value + "'"); System.out.println("==========================================="); System.out.println("Test updating Server properties ..."); System.out.println(" Retrieving current value of 'port'"); Integer ivalue = (Integer) server.getAttribute(name, "port"); if (ivalue.intValue() != 8005) throw new IllegalStateException("Current port value is '" + ivalue + "'"); System.out.println(" Setting new value of 'port'"); server.setAttribute(name, new Attribute("port", new Integer(8765))); /* server.invoke(name, "setPort", new Object[] { new java.lang.Integer(8765) }, new String[] { "int" }); */ System.out.println(" Checking new value of 'port'"); ivalue = (Integer) server.getAttribute(name, "port"); if (ivalue.intValue() != 8765) throw new IllegalStateException("New port value is '" + ivalue + "'"); } catch (MBeanException t) { Exception e = t.getTargetException(); if (e == null) e = t; System.out.println(e.getMessage()); e.printStackTrace(System.out); } catch (Throwable t) { System.out.println(t.getMessage()); t.printStackTrace(System.out); } } } commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/demo/Engine.java100644 0 0 6516 10636604104 24412 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.demo; /** *

Sample managed object for the Modeler Demonstration Application, * based on the Catalina architecture of Tomcat 4.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class Engine implements Container { // ----------------------------------------------------------- Constructors /** * Construct a default instance of this class. */ public Engine() { super(); } /** * Construct a configured instance of this class. * * @param name Name of this Engine * @param defaultHost Default host name for this Engine * @param service Associated service */ public Engine(String name, String defaultHost, Service service) { super(); setName(name); setDefaultHost(defaultHost); setService(service); } // ----------------------------------------------------- Instance Variables // ------------------------------------------------------------- Properties /** * The default host name of this Engine. */ private String defaultHost = null; public String getDefaultHost() { return (this.defaultHost); } public void setDefaultHost(String defaultHost) { this.defaultHost = null; } /** * The name of this Engine. */ private String name = null; public String getName() { return (this.name); } public void setName(String name) { this.name = name; } /** * The parent Container of this Engine. */ private Container parent = null; public Container getParent() { return (this.parent); } public void setParent(Container parent) { this.parent = parent; } /** * The associated Service of this Engine. */ private Service service = null; public Service getService() { return (this.service); } public void setService(Service service) { this.service = service; } /** * Return a String representation of this object. */ public String toString() { StringBuffer sb = new StringBuffer("Engine["); sb.append("name="); sb.append(name); sb.append(", defaultHost="); sb.append(defaultHost); sb.append("]"); return (sb.toString()); } } commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/demo/mbeans-descriptors.xml100644 0 0 13121 10636604104 26676 0ustar 0 0 commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/demo/Server.java100644 0 0 7637 10636604104 24460 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.demo; import java.util.HashMap; /** *

Sample managed object for the Modeler Demonstration Application, * based on the Catalina architecture of Tomcat 4.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class Server { // ----------------------------------------------------------- Constructors /** * Construct a default instance of this class. */ public Server() { super(); } /** * Construct a configured instance of this class. * * @param port Port number of this server * @param shutdown Shutdown command of this server */ public Server(int port, String shutdown) { super(); setPort(port); setShutdown(shutdown); } // ----------------------------------------------------- Instance Variables /** * The set of services associated with this Server, keyed by name. */ private HashMap services = new HashMap(); // ------------------------------------------------------------- Properties /** * The port number for our shutdown commands. */ private int port = 8005; public int getPort() { return (this.port); } public void setPort(int port) { this.port = port; } /** * The shutdown command password. */ private String shutdown = "SHUTDOWN"; public String getShutdown() { return (this.shutdown); } public void setShutdown(String shutdown) { this.shutdown = shutdown; } // --------------------------------------------------------- Public Methods /** * Add a new Service to this Server. * * @param service The service to be added */ public void addService(Service service) { services.put(service.getName(), service); } /** * Find and return the specified Service associated with this Server. * * @param name Name of the requested service */ public Service findService(String name) { return ((Service) services.get(name)); } /** * Find and return all Services associated with this Server. */ public Service[] findServices() { Service results[] = new Service[services.size()]; return ((Service[]) services.values().toArray(results)); } /** * Remove the specified Service from association with this Server. * * @param service The Service to be removed */ public void removeService(Service service) { services.remove(service.getName()); } /** * Return a String representation of this object. */ public String toString() { StringBuffer sb = new StringBuffer("Server["); sb.append("port="); sb.append(port); sb.append(", shutdown="); sb.append(shutdown); sb.append("]"); return (sb.toString()); } } commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/demo/Service.java100644 0 0 10232 10636604104 24613 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler.demo; import java.util.HashMap; /** *

Sample managed object for the Modeler Demonstration Application, * based on the Catalina architecture of Tomcat 4.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class Service { // ----------------------------------------------------------- Constructors /** * Construct a default instance of this class. */ public Service() { super(); } /** * Construct a configured instance of this class. * * @param name Name of this service * @param server Associated server */ public Service(String name, Server server) { super(); setName(name); setServer(server); } // ----------------------------------------------------- Instance Variables /** * The set of connectors associated with this Service, keyed by port. */ private HashMap connectors = new HashMap(); // ------------------------------------------------------------- Properties /** * The associated Container for this Service. */ public Container container = null; public Container getContainer() { return (this.container); } public void setContainer(Container container) { this.container = container; } /** * The name of this Service. */ private String name = null; public String getName() { return (this.name); } public void setName(String name) { this.name = name; } /** * The associated Server for this Service. */ private Server server = null; public Server getServer() { return (this.server); } public void setServer(Server server) { this.server = server; } // --------------------------------------------------------- Public Methods /** * Add a new Connector to this Service. * * @param connector The connector to be added */ public void addConnector(Connector connector) { connectors.put(new Integer(connector.getPort()), connector); } /** * Find and return the specified Connector associated with this Service. * * @param port Port number of the requested connector */ public Connector findConnector(int port) { return ((Connector) connectors.get(new Integer(port))); } /** * Find and return all Connectors associated with this Service. */ public Connector[] findConnectors() { return ((Connector[]) connectors.values().toArray(new Connector[0])); } /** * Remove the specified Connector from association with this Service. * * @param connector The Connector to be removed */ public void removeConnector(Connector connector) { connectors.remove(new Integer(connector.getPort())); } /** * Return a String representation of this object. */ public String toString() { StringBuffer sb = new StringBuffer("Service["); sb.append("name="); sb.append(name); sb.append("]"); return (sb.toString()); } } commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/mbeans-descriptors.xml100644 0 0 36565 10636604104 25773 0ustar 0 0 This is a problem commons-modeler-2.0.1-src/src/test/org/apache/commons/modeler/RegistryTestCase.java100644 0 0 34004 10636604104 25536 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.modeler; import java.io.FileInputStream; import java.util.List; import javax.management.Descriptor; import javax.management.MBeanConstructorInfo; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanConstructorInfo; import javax.management.modelmbean.ModelMBeanInfo; import javax.management.modelmbean.ModelMBeanNotificationInfo; import javax.management.modelmbean.ModelMBeanOperationInfo; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** *

Test Case for the Registry class.

* * @author Craig R. McClanahan * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ */ public class RegistryTestCase extends TestCase { // ----------------------------------------------------- Instance Variables /** * The Registry we will be testing. */ protected Registry registry = null; // ----------------------------------------------------------- Constructors /** * Construct a new instance of this test case. * * @param name Name of the test case */ public RegistryTestCase(String name) { super(name); } // --------------------------------------------------- Overall Test Methods /** * Set up instance variables required by this test case. */ public void setUp() throws Exception { registry = Registry.getRegistry(); String names[] = registry.findManagedBeans(); if (names.length == 0) { FileInputStream stream = new FileInputStream ("src/test/org/apache/commons/modeler/mbeans-descriptors.xml"); Registry.loadRegistry(stream); stream.close(); } } /** * Return the tests included in this test suite. */ public static Test suite() { return (new TestSuite(RegistryTestCase.class)); } /** * Tear down instance variables required by this test case. */ public void tearDown() { registry = null; } // ------------------------------------------------ Individual Test Methods /** * Test ModelMBeanAttributeInfo information. */ public void testModelMBeanAttributeInfo() throws Exception { // Retrieve a ManagedBean ManagedBean http = registry.findManagedBean("HttpConnector"); assertNotNull("Found HttpConnector managed bean"); // Create the associated ModelMBeanInfo ModelMBeanInfo info = http.createMBeanInfo(); assertNotNull("Found HttpConnector ModelMBeanInfo", info); // Retrieve the specified ModelMBeanAttributeInfo ModelMBeanAttributeInfo mmainfo = info.getAttribute("acceptCount"); assertNotNull("Found HttpConnector acceptCount info", mmainfo); // Get the Descriptor Descriptor desc = mmainfo.getDescriptor(); assertNotNull("Found HttpConnector acceptCount descriptor", desc); // Check the configured fields checkDescriptor(desc, "field1", "HttpConnector.acceptCount/field1"); checkDescriptor(desc, "field2", "HttpConnector.acceptCount/field2"); } /** * Test ModelMBeanConstructorInfo information. */ public void testModelMBeanConstructorInfo() throws Exception { // Retrieve a ManagedBean ManagedBean http = registry.findManagedBean("HttpConnector"); assertNotNull("Found HttpConnector managed bean"); // Create the associated ModelMBeanInfo ModelMBeanInfo info = http.createMBeanInfo(); assertNotNull("Found HttpConnector ModelMBeanInfo", info); // Retrieve the relevant MBeanConstructorInfo array MBeanConstructorInfo mcinfo[] = info.getConstructors(); assertNotNull("Found HttpConnector MBeanConstructorInfo array", mcinfo); assertEquals("Found HttpConnector MBeanConstructorInfo entry", 1, mcinfo.length); // Cast first entry to ModelMBeanConstructorInfo ModelMBeanConstructorInfo mmcinfo = (ModelMBeanConstructorInfo) mcinfo[0]; // Get the Descriptor Descriptor desc = mmcinfo.getDescriptor(); assertNotNull("Found HttpConnector constructor descriptor", desc); // Check the configured fields checkDescriptor(desc, "role", "constructor"); checkDescriptor(desc, "field1", "HttpConnector.constructor/field1"); checkDescriptor(desc, "field2", "HttpConnector.constructor/field2"); } /** * Test descriptor entries. */ public void testDescriptorEntries() { // Retrive the ManageBean that has descriptor info ManagedBean http = registry.findManagedBean("HttpConnector"); assertNotNull("Found HttpConnector managed bean"); // Check descriptor fields on the ManagedBean itself List beanFields = http.getFields(); assertNotNull("Found HttpConnector fields"); checkField(beanFields, "field1", "HttpConnector/field1"); checkField(beanFields, "field2", "HttpConnector/field2"); // Retrieve the AttributeInfo that has descriptors set AttributeInfo attrs[] = http.getAttributes(); AttributeInfo attr = null; for (int i = 0; i < attrs.length; i++) { if ("acceptCount".equals(attrs[i].getName())) { attr = attrs[i]; break; } } assertNotNull("Found attribute"); // Check descriptor fields on the AttributeInfo List attrFields = attr.getFields(); assertNotNull("Found attribute fields"); checkField(attrFields, "field1", "HttpConnector.acceptCount/field1"); checkField(attrFields, "field2", "HttpConnector.acceptCount/field2"); // Retrieve the ConstructorInfo that has descriptors set ConstructorInfo constrs[] = http.getConstructors(); ConstructorInfo constr = null; for (int i = 0; i < constrs.length; i++) { if ("HttpConnector".equals(constrs[i].getName())) { constr = constrs[i]; break; } } assertNotNull("Found constructor"); // Check descriptor fields on the ConstructorInfo List constrFields = constr.getFields(); assertNotNull("Found constructor fields"); checkField(constrFields, "field1", "HttpConnector.constructor/field1"); checkField(constrFields, "field2", "HttpConnector.constructor/field2"); // Retrieve the NotificationInfo that has descriptors set NotificationInfo notifs[] = http.getNotifications(); NotificationInfo notif = null; for (int i = 0; i < notifs.length; i++) { if ("Problem".equals(notifs[i].getName())) { notif = notifs[i]; break; } } assertNotNull("Found notification"); // Check descriptor fields on the NotificationInfo List notifFields = notif.getFields(); assertNotNull("Found notification fields"); checkField(notifFields, "field1", "HttpConnector.problem/field1"); checkField(notifFields, "field2", "HttpConnector.problem/field2"); // Retrieve the OperationInfo that has descriptors set OperationInfo opers[] = http.getOperations(); OperationInfo oper = null; for (int i = 0; i < opers.length; i++) { if ("initialize".equals(opers[i].getName())) { oper = opers[i]; break; } } assertNotNull("Found operation"); // Check descriptor fields on the OperationInfo List operFields = oper.getFields(); assertNotNull("Found operation fields"); checkField(operFields, "field1", "HttpConnector.initialize/field1"); checkField(operFields, "field2", "HttpConnector.initialize/field2"); } /** * Test ModelMBeanInfo information. */ public void testModelMBeanInfo() throws Exception { // Retrive a ManagedBean ManagedBean http = registry.findManagedBean("HttpConnector"); assertNotNull("Found HttpConnector managed bean"); // Create the associated ModelMBeanInfo ModelMBeanInfo info = http.createMBeanInfo(); assertNotNull("Found HttpConnector ModelMBeanInfo", info); // Check the basic properties assertEquals("Correct className", "org.apache.catalina.mbeans.HttpConnectorModelMBean", info.getClassName()); assertEquals("Correct description", "HTTP/1.1 Connector for Tomcat Standalone", info.getDescription()); // Get the Descriptor Descriptor desc = info.getMBeanDescriptor(); assertNotNull("Found HttpConnector MBeanDescriptor", desc); // Check the configured fields checkDescriptor(desc, "field1", "HttpConnector/field1"); checkDescriptor(desc, "field2", "HttpConnector/field2"); } /** * Test ModelMBeanNotificationInfo information. */ public void testModelMBeanNotificationInfo() throws Exception { // Retrieve a ManagedBean ManagedBean http = registry.findManagedBean("HttpConnector"); assertNotNull("Found HttpConnector managed bean"); // Create the associated ModelMBeanInfo ModelMBeanInfo info = http.createMBeanInfo(); assertNotNull("Found HttpConnector ModelMBeanInfo", info); // Retrieve the specified ModelMBeanNotificationInfo ModelMBeanNotificationInfo mmninfo = info.getNotification("Problem"); assertNotNull("Found HttpConnector problem info", mmninfo); // Get the Descriptor Descriptor desc = mmninfo.getDescriptor(); assertNotNull("Found HttpConnector problem descriptor", desc); // Check the configured fields checkDescriptor(desc, "field1", "HttpConnector.problem/field1"); checkDescriptor(desc, "field2", "HttpConnector.problem/field2"); } /** * Test ModelMBeanOperationInfo information. */ public void testModelMBeanOperationInfo() throws Exception { // Retrieve a ManagedBean ManagedBean http = registry.findManagedBean("HttpConnector"); assertNotNull("Found HttpConnector managed bean"); // Create the associated ModelMBeanInfo ModelMBeanInfo info = http.createMBeanInfo(); assertNotNull("Found HttpConnector ModelMBeanInfo", info); // Retrieve the specified ModelMBeanOperationInfo ModelMBeanOperationInfo mmoinfo = info.getOperation("initialize"); assertNotNull("Found HttpConnector initialize info", mmoinfo); // Get the Descriptor Descriptor desc = mmoinfo.getDescriptor(); assertNotNull("Found HttpConnector initialize descriptor", desc); // Check the configured fields checkDescriptor(desc, "field1", "HttpConnector.initialize/field1"); checkDescriptor(desc, "field2", "HttpConnector.initialize/field2"); } /** * Test registry creation. */ public void testRegistryCreation() { String names[] = null; System.out.println("Registered managed beans:"); names = registry.findManagedBeans(); for (int i = 0; i < names.length; i++) System.out.println(" " + names[i]); System.out.println("-------------------------"); System.out.println("Registered managed beans for Containers:"); names = registry.findManagedBeans("org.apache.catalina.Container"); for (int i = 0; i < names.length; i++) System.out.println(" " + names[i]); System.out.println("-------------------------"); } // ------------------------------------------------------ Protected Methods // Check presence of an appropriate name/value pair in the descriptor protected void checkDescriptor(Descriptor desc, String name, Object value) { String names[] = desc.getFieldNames(); boolean found = false; for (int i = 0; i < names.length; i++) { if (name.equals(names[i])) { found = true; break; } } assertTrue("Found name " + name, found); assertEquals("Correct name " + name + " value", value, desc.getFieldValue(name)); } // Check presence of an appropriate FieldInfo protected void checkField(List fields, String name, Object value) { int n = fields.size(); for (int i = 0; i < n; i++) { FieldInfo field = (FieldInfo) fields.get(i); if (name.equals(field.getName())) { assertEquals("name=" + name + " value", value, field.getValue()); return; } } fail("Cannot find field name=" + name + " and value=" + value); } } commons-modeler-2.0.1-src/xdocs/building.xml100644 0 0 5466 10636604104 16200 0ustar 0 0 Building Commons Documentation Team

Commons Modeler uses Maven or Ant as a build system.

To build a jar file, change into Modeler's root directory and run maven jar. The result will be in the "target" subdirectory.

To build the Javadocs, run maven javadoc. The result will be in "target/docs/apidocs".

To build the full website, run maven site. The result will be in "target/docs".

Further details can be found in the commons build instructions.

To build a jar file and the javadocs, change into Modeler's root directory and run ant dist. The result will be in the "dist" subdirectory.

Nightly Builds are built once a day from the current SVN HEAD. These are provided purely for test purposes and are NOT official releases of the Apache Software Foundation - Released versions of Commons Modeler are available here.

commons-modeler-2.0.1-src/xdocs/cvs-usage.xml100644 0 0 3707 10636604104 16274 0ustar 0 0 Source repository Commons Documentation Team

Jakarta Commons Modeler is hosted on the Apache subversion repository.

The project URL is:
http://svn.apache.org/repos/asf/jakarta/commons/proper/modeler/trunk

The best way to view the repository is via the subversion viewer.

The alternative is to use the native subversion display.

For more information on subversion and creating patches see the Apache Contributors Guide.

commons-modeler-2.0.1-src/xdocs/downloads.xml100644 0 0 6516 10636604104 16372 0ustar 0 0 Downloads Commons Documentation Team $Id: downloads.xml 549645 2007-06-21 23:20:58Z niallp $

The following releases are available:


The latest binary and source releases are always available on the Commons Modeler Downloads page.

Older releases are retained by the Apache Software Foundation but are moved into a special archive area.

Access to the source tree to see the latest and greatest code is possible through anonymous SVN access.

commons-modeler-2.0.1-src/xdocs/images/modeler-logo-white.png100644 0 0 30155 10636604104 21350 0ustar 0 0 PNG  IHDRQƥvbKGD pHYs  tIMEe9LtEXtCommentCreated with The GIMPd%n IDATx}ytUE䅐Úe5DAɌ gx@θ 22,P -Av$ , y[ҿ?ƾn{o`|'{R]nB@#Yuht}S2:h^|fK+jhC+W.j7> `٩fu;w֯_xCy}6V=18pΞ=8J/{aX` 6:!550\?8p@2oLL-zU+˗(ib=+˾IMMR)H#@JJ ZgCRSSaZ?Ӱ`6oa"&&F雒"N:%<z '~bꈉSNmt=~_[Nje[N~w P=`qIQWWgx_}USe^ۭvӧł D||VU;|:z)C}uuuĉ⩧2gW^<{m3vGW7{ӦMӵ?~SN55kE5}ӧOו*RSSumMIIx._~ A!5~bϞ=Z:uJ&jkk +W~:M&v-^x<ԩS^cЪ'O^{|aŨ߿բZl۶MDGG-jjj {⩧R ISL~͛w޼y2eV:^W>}ZǤbݺuh;vX]V(˝;w }_M'iw H#vehW]]rV *p裏t?x`Z{ϟ?~\sPg͚K,љ˖-%t8ʾYb$%%xSvv63F9پٳgû ɐN?񏐑. ⷿVдi4PCCC׃>|>C>} ճgOz7]'xB+>^.ϧu~G+z4O߾}aٲeZ: … v+_ QWL鮯7{饗`ԨQ:z)n['3c :t(K#!..NHW># oOqy 22RW͛apo^|Exmڵ+DDD>| Y:tHk Ɓl׫ ?\kBD̅ ¹ste Ɔы/uE ,,0Id)hyſ0EEEtR,,LbCo âEt)%#_H]~~MQ l߾=ٳΟ? gXk&a޽ ͙T1VZe`'ҧAȴM.n-0p*s>vuyWJc.WҌu8l^n۰nH(gtJv֭PTTK۫W/z'̇+V9rOtr4~xΚ5 יx*$tJta3)sb U&*(o%_|$cq>̜ݠQp%&ISL׫3C8FWEx^]8p:ګ^0Ds0e^3,\ƳG3sذaZU}# D0N .ٳ!##fΜ zbح[7|񥠤 :8],(18JJJX̠Fp&@vv6tD3TSu6/_U1tJcbpb'T3*ƕy)R I# (x *..@kM`@yuNA>uT(..LC#GСCaĉ0ap\Jo;hs !t' LC,:gN ի|WLJsvv@- 3;.WiLD}+ P\xAICC6U=Rcˠjofbm)EWʹsBxx8Ymڵk!33z!?~Z47U@ *:tAcR9 ]Off&[> Y:btc ̜c؄ut^eE*^=aLe~c ñ,\f Bn~N Vb;@II ,ZP:8[9zy&؜WKN|NPSCteI19jK5)mN,lp̌iP=Rsq״)'<< hJ`!`m.R ܭ[7غu+L>]YNii)L4 k9^ PUqFS-9?2:Nxz233Y)uC[nfW &f2n .)PFRM)PٞBk2۾};ki\kTrEFi\__ǏM6\x1ߎ@ B@JJ RǙX,AN ((N! //5T O= Z*`rbVL'fiA=4UKm(l,jLV-0内ɓ!==̂3==U6;*6@n^>lsSi~OҚt@=TkÆ cM6`rY1ܙc|wsAv1V1UMh>S-2MKͱh_~!3""B?fNP %R̓?ش0x7k.wjsS…  BQGI&ҥK Aχ|H jpkhÆ c`6X[i14]3َQIVI5 ޱcGh׮!~Tson<n 4&W>=ʖKCrrAPb+°&. 2e CQQrnC*'M}}\Ɓзo_; رjMj?D5VSV1UT  q7f>ٳǒO(5ozVgY޽ƎtLq&ʣ[.2e 53)M͆XjBQQ,Y]> wyPGzzd5B"##aƌJ`TEe>u5N̥t4YF向[o& ʫ9@nXav̱3 @`ЩS'%GZf9s(hL'N%KΝ;a_… W_}yTJ(x뭷 ^~evG]ʫWւ###{3pX9<a@rbLW˼ӧO7i[\\E;T.\U^?8`B/!!53k҉dX|`ƍ0w\xaٰn:-4n…0b˵#Goᅦy)=B/5 6lHp3W9/Z\xxJN;u8PVVҫbp+ -Uvܹs 9s&V o69᱔eKЂFOzX~m֔RO?u]9YgIPƌۙoq\+@bb"+ 1b={G ݠn߾{1x!""u`pe]妚p;ܾ}MOOgAk-Oon_2믿 ڵyu&I -- ?eAA[0j(x"DDD[o<[l1аi&KwΝ{o>(A4vA7LfN 8KnH=}4<䓐kJpJJ ?bbbYfЬY3mݒ^/n:KMѣGxgO> }>deeAII ڵ ;Ɩ׾}{ܹ3$$$輌'OǏ޽{Ws=w m۶:@aa!8q٣r{Xh۶-n j=]BΝ!66V3;ĉ{ne\.|mۦivAll, <NVXpp.@x@z!''t {/ nfe4¬Y8j̘1бcGǏWzSN0zhB@FFZ%P6m:!NUXq:JgGt:u&Ǵhnc2X px4N۫gY.t纝cTnRz{i {BPD9t.'U1ϔ0vah7WtE ֖R"_Ղ2m4TmZvG$#*$< n) )#rgJ&<\ ..2ǜt/6q[G ٜ/(PƞS?rOzHj,a N;5Bb 'G6C10c93GXZi8Cۥ@3 <;cӼ~V2?f$↩Jĸ8sNq+5UN;~cFwS-3`RwRj̠ 6P-Il:yU,L0.MT:? XQ 03 )ԡ-.VLp[Smci"|r~y g+SNTcYhړ %̏T:9m&% ;D&6(Po#fq1c VjZI5w*/B5;OjZδࢎ ye~Z/[Vβ2g\Zw-qҘ9p~0 -Xt,&/le5 IVX ! ((-bgW1e<Nz2GJH):lMN'{-p[9a`3JNXyU3 S>~S .*(U8d%6Z^&,I'tF 3yygqUvd\TQKCx7U5ޝ UVXa:~n _ Vii 4ri-|KɪYR?]{scZjXƖmly.ߋz38@Y=L^ׁwpNB?>nϬţ7Ayi^,Y{/on&ڵ+̘1u'@_ ** Zl ]t***{367x m۶f͚ADD1VZ={ P߿?|J`ʫz.\C!C!°an[oaŊx 3;2GֿuV6lj `U iZ_4=SVV&̙#.]@tA={V?~\$$$(ʼnRq[WW''n"$$DlذATUU-[-[ v^#fϞ,233EII.ݡC it^f X~8q!͠ApZUaS] 9KJa߸ӡE콦:` Su~/]3Pw|es[sh8+9A V>555ʹ8zJJJ8Xy٩fTJ> %ƪBJ)nMAz-M6pEpYܺuk-Z@uu[nmaL yd*""B;~L9G Caaa9`4 HOKm]ąיMpq4&gb e;!jԩPFǎ5|pQsAppJ33kH8y.Mnn.Owc%F`4cw$UuH+_EyJͬmsM+|! 便ںrCKRѣGvC]]n itbHw^hKgyrݺu3|߿|YǡC-w-Wkܺ&`ޠkU9(s1nvn[@QQ{LL GcL;w_4p@]7nԵVX'Nl/6- WUU-[t¯VZ&L0;Y5瘺֛XzT&T^~Immq{1&\x9} I&Bcذ0>|<̄ʂ-[8p@ٺukCY~)lڴ ,Xwy'zZ;Tsl_Bh׮1f˖-uV/›o qqqp-JUt,q< pٳp}}!$$nvHLL8#eĉ}s6Ν;̙3PSS͛7_0dٳ^W Ǐ?-e h޼788X&`^g-98ʕ+p 7T$+y*;^ dF3w]M7dx·I/,00fQ$\,'887o!!!oZ}MLzfnt*=j'5ٽ\vmj -kmR&C%.: J0sPj#`5ky \ ̝0gzAZ7QIf;ƝX .Cu:- 7(b5xofriT^ClJrf,3U4eV/L͸E8 k: L z LNxkޛ:82;:91jձvmjuK.?hVnFU9&~,H9GʗNKLd>IM!|U=g1;gvAcš9TZ֧2J`S:'T5ͭc 71XxR`b͎5&{{shI:)7,{47ftp X3Ԛ?zJ Z=*Yz"vMdb`rz&>(QcR,((HLj45j.j!sZ Vċv0K0yR1U;K)*Fј_ ҀprfEb.fT(sS2zjF֥:Δlo& #gRPho5-/tmz旍15J[il+O]g6WkfNѲqlBw#zeeOCM+ &IENDB`commons-modeler-2.0.1-src/xdocs/images/modeler-logo-white.xcf100644 0 0 54250 10636604104 21346 0ustar 0 0 gimp xcf fileQBBN/ gimp-commentCreated with The GIMPS gimp-commentCreated with The GIMPgimp-image-grid(style intersections) (fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000)) (bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000)) (xspacing 10.000000) (yspacing 10.000000) (spacing-unit inches) (xoffset 0.000000) (yoffset 0.000000) (offset-unit inches)  Fz-Vw)modeler     c$L-gimp-text-layer(text "modeler") (font "Times New Roman Bold") (font-size 34.000000) (font-size-unit pixels) (hinting yes) (antialias yes) (language "nl-be") (base-direction ltr) (color (color-rgba 0.000000 0.000000 0.000000 1.000000)) (justify left) (box-mode dynamic) (box-unit pixels) w) :w) @ @ @w8V9::::hوUچ q`9Yy% 1NF0{?  ) u!{,`#%H3 J6 E(Pe!    0L%Wc>B$o (4aaYtGBDOt:JJ=3 vvl$ɥ\7?/ s0 1111$ zf zfIL4545pr-W-WK5?5? T T S?D    !! NN  ~ C~ C44 vv vq  is FKFK;5Drop-Shadow#1     \&N 5 bn5 $_ @ @ @?<<                        !#$$#"!   $(*,..//.-,,++**)('&%#"!  !"! "$' "(-1579::98766554321/-,**))**++,,+*)*+-0 ")/6;?BDEEFFEDCBA@@?>=<:87544565457:  '07?EJMOPQQPONMLLKKJIGFDB@??@?@ACE $,6?GNSWY[\\[ZYXWWVVUTSQONLKJJKLMNP '1;ENV\`cdeeffedcbaa``__^\[YWVUUTTUVWXZ[ !*5@KU]chjlmmnmkjiihhgfecb`__^^]]^_`aabcde "-8DOYbimprrssttsrqpoopponlkihggfeefghijklmnn $.:FR\elqtuvwwxyyxwvuttuvvutrqponmlkklnoprsttuv %0HQY^acddeefghhggffhikllkihfecba`__`abcdefgh '0:CKRVY[\\]^^__^]^_abccba`^][ZYXWWXYZ[]^ #+4>?@?>??@@AA@?>=;::99887679: !&*.0233454566543210//..-,+,-/ "%'()) *+*)('&%%$#"!"#$   !"!               ' ' @ @ @                   !!   !!    !%(**)&"  !%()*(&"  $).1331.*$  #(,0221.*% %+17;==;72,&$*059<<:72,&      %,3:?DFFD@:3,& $*17=BDEC@:4-'! &,4;BIMPPMIC;4-&! %*18?EJMNMIC<5.(#"'-483.+(&%$#""#$&()+,,*49>ELT[afhhe`ZRJC=85311247;@GNU\aefda[UNGA<8420.-++*+,-/2457764>BHNT[bhlnnkf`YRKEA><;;<=@CHNT[bgjlkgb\VPJEB><:865434579<>@AA@>HLQW]cinrttqmf`YSNJHFEEFHKOTZagmprqnjd^YTOLIFDA@>=<=>@CFIKLLKHSVZ_dioswyxvqlf`[WTRPOONNOPRVZ`flquvvtpkfb]YVSPNKIGEDEFILORUVVTQ]`cfkotx{||zvqlgb_][ZYXWVVX[_djpuxz{yvrnjfc_\YVSQNLLNPTW[]_^\Xgiknqtx{~}zuqmigedca`_]\\]_cgmsx|~~{xurnkheb^[WURQRTVZ^befeb]oprsvx{~}yuromlkjhgeca``bejotz~~{xusplhd`\YVUVW[_cgjkif`vvwxy{}|yvtrqqonlifdbbcfjouz}{xurmid`\YWXZ]afjmmlhb{{|}}{ywvuusrolhecbcfjouz|yuqlfa]ZXY[^chlnomib~~}}~~|zyxxwvspmiecabdhnsy~元{wrmga]YWXZ^bgknnlg`~~}}~}{yyxxwvsplhda_`bfkqw|焃{wrlf`[WUVX\afjllje]||{|}~~~|zxwwvvutrnjfa^\]_chnty}}zupjd^XUSSUY^cgjjgbZxxyz{{zyxvtsrrqpnjfb^ZXYZ^ciotx{}~~}{yvqlf`ZUQOOQUZ_ceeb]Urrstuusrpnmllkiea]YVTTVY^cinruwwxwvusplga[VPMKKMQVZ^``]XPijkklmmnnmljhfeedcb_[WSPNNPSX]bgjmoonmkiea[VPKHFFHLPTXZZWRJ_abccdeedca_]\[[YWTPMJHHILQUZ^adeffedcb_\XTOJEB@@BEIMQRRPKDTUWXYZ[[ZXVTRQQPNKHEBAABEHLPTWYZZYXWUSOKGB>;::;>BEHJJGC:753357:=@AA?;5<>?ABCDDCBA?=<;::;;:86421124695-% YQH>5,$ ZPG=3*" YOE:1(  WLB7-$ SI>3*! PE:0& KA6," G<2( A7.$ ;2)  5-$ .'  '! !          fJ% commons     :--V#['Y,8qU8Uq8q8q q UU88UU8qUqUUUqUUUqUUq8U8 UU 8q8U8 q   8U 8U UU UU UU 8UU U 8 88 U q 8888 q8 q8qUUUUUqU UUUU U 8qUq q8UqUU8qU 8q8U8 8UqU8qqq88qqUUqUUUqƪUqUUUU8Uqq q8UUU 88UUqq UUUU UUUU UUUU UUUU UUUU UUUU UUUU UUUU UUUU UUUU UUUU UUUU UUUU UUUU UUUU qUq qUqU8qU88qU8UƍUUUU8q qq q8  8qUU88qU 88 8UU UUUU8U8UUUUUUUUU8q 8UqUUU UUUUU 8UUUU UUUUU UUUU UUUU UUUUUU UUUUUU UUUUU UUUUUU UUUUU8 UUUU qUUUUq UUUUq8UUUUUUUUqUqU88UUqqU8q8qUU 8Uq8 q 8VVV UU ⪪88888Uqqq88  q 8 qU  qU qq8qƪq888UUk 58 Drop-Shadow     9.J8.fVV8.8CNVU                    !#$%%$# !"##$%%$"   "$&')*+,,+*'%"!#$&'())*+,,*(&#! !$&(*+-.01221.,)&#! !#$'(*+,--./0234431.,)  #'),-/01346787642/,)(''(*,./11223568:;;9752 !&*-/12334679:;<;9742/..0245677665668:=?ABCB@=: "',02456678:<=>>=;97544579;<==<:9878:>=;:99:<>ABCCB@=;988:=@EIMOPONK &-38;==<:8655679;<=>==>@BEGIIHFC?;9779<@FKPSUVTR $+29=@AA>;853223579:;<==?ADGKMOOMJE@;7556:?EKQVZ[ZX  (08>CEED@<830..024689;=@CGLPSTSQLGA;63237=CKRX\__] $,5=CGJIGB=72.+))*,.1369<@EJOTWXWTOHA:40/04:AJRY^aba '09AHLNMID>71+(%%'),/26:@FLRW[\[WQIA93.,-17?HQY_cdd  )3=ELPRPLF?70*%"!!"$'*.38?FMTZ^_^YSJA92-*+/5=FOX_dfe ",6@HOTUSOIA81*$!!#'+06>ENU\`a`[TKB91,))-3;DNW^cff #-8BKSWYWRLC;2+% !$(.55-'" #'-471,)&%&'*.3:AJRZ_bc`ZSJA93/-/28@HOUY[[ !+6ALV]bdd`[TME>83/,*)*+.38?GOV\`a_ZTLC<610149@FMRUWW (3>IS[aeec_ZSLE?:52/--/27=DKRX\]\YSME>94336:?EJOQRR %/:EOX_ceeb^XRLFA<741/./149?FMSWYYWSMF@;7557;?CGKLML !+5@JS[`dec`\WQLFA<741/./15:@FLQTUSPLGB=9778;>ADFGGF &0:DMU\`bba]YTOID?:51.-,.04:?EJMOOMJFA=:88:<>@AA@? !*3=FNUZ]_^\YUPJE?:50-*))+.27=AEHIHFC@=:87789:;;:98 $-5>FMRVYYXVRNIC>83.*'%$%(+059=@BBA?=:8755421 &-5=DINPRQPMID?:4/*%" !$(,048:;;:875321100/.,+* %,3:?CFHIHEB>94/*%! $(,/13310/.-,+*('%$# $*059<>?><:62.)$  #&)+,,+*)('&%#"  !&+.134431.*&"!#$%%$$#"!  !$')**)'%"                    "                              !!"#$$%%$#"!  !"##! !!"#$%!$&'))*+,-.//.-,*))()*+,,*(%!"$&())**+,-. #&*-/123345789987642112345531-*&" #'*-012334567'%%&(+/369;<==<<=>@ACCDCB@><::;=>>=:62.)&$$%'+/37:;<=<<=>@/--.037<@CEFFEDDFGIKMMKIGECAABCDFGFEC?:51-+*,.27<@CEFFEDDEFH86558;@DILNOOMLKJJLNPSUVVTROMJHGGIJLMNMKGB=841125:?DILNONMKJJKLN@>==?CHLQTVWVTRPOOPRUX[\]\YVSPMLLMOQSTTRNID?:778;@FKPTVVUSQOOQSHEDDFJNSX[]][YVSRQRUX\_aba_\XTQONOQTVXXWTPJE@=<=@EKQWZ\\ZXUSQQSVOLKJLOTY]`ba_\XUSRSUY^adfec_[VRPOPRUX[\[YUOJEA@ADJPV[_``^ZWTRRTWUSQPQTY]adedb^YURQRUY^bfhgea\WSONOQUY\^^\XSNHECDHMSY_bcb`\WTQQSV[XUU;X\`dggfc^YTPOPSW]bfhhfb\WRNLMPTX\_`_[VQLHFGJOU\aded`[WRPOQT_\YXY[^bfhhfb]WRNLMPU[`ehhfb\VPLJKNRW\_a`]YSNJHHKPW]befd`[UPMLNRb_\[[]`dgiifb\UPKIJMRY_dggea[TNJHHKPU[_ba_ZUPKIJLQW]beec_YSNJIKOca^\\^adgiheaZTMIGGJPV]befd`YSLHEFINTZ_ab`\VQLJJMRX]beeb^WQKHGHLda_]]^adghhe`YRKGDEHMT[`dec^XQKFCDGLRY^ab`\WQMJJMRW]bdda\VOIFDFJda_]]^adghgd^XPJEBCFLRY_cdb]WPIDBBEKQX^aba]XRNKKMRW]adc`[UNHDBDHc`^\\^`cfgfc^WOICAAEJQX^bca\VOHCAADJPW]aba]XSNKKMRW]acc`ZTMFBABG`^\[[]_cegfc]VNHC@@DJQX^aba\UNHB@@DIPW]aba^YSOLLNRW]acc_ZSLFB@BF][YXY[^befeb\UNGB?@CIPW]ab`\UNGB@@CIPW]aba^YSOLLNRW\`cb_YRKEA@AEZXVVWY]`deea\UNGB?@CIPW]ab`[UNGB@@CIOW]aba^YTOLLNRW\`bb_YRKEA?AEUTRRTW[_bdda[UMGB?@CIPW\`a`[UNGB@@CIOV\`ba^YTOMLNRW\`ba^YRKEA?AEPONNPTX]acb_[TMFB?@CHOV\_`_ZTMGB@@CHOV\`a`]YTPMMNRW\_a`]XQJEA?AEJIIJLPUZ^``^YSLFA??CHNU[^_^YTMGB@@CHNU[_`_\XSOMLNRV[^`_\WQJD@?ADD2EHMRW[^^\WQKEA>?BGMSY\]\XRLFA??BGMSY]^][WRNLLMQUY]^]ZUOIC@>@D>=>@CHMSWZZXTNHC?==@EKQVYZXUOJD@>>AEKQVY[ZXTPLJIKNRVY[ZWRLFA>=>B778:>CHNRUUTPKE@=;;>BHMRUVTQLGB><<>CHMRUWVTPLIGGHKOSUVVSOID?<;CHLOPNKGB>:88;>CHLOPPNKHECCDFJMOPPMID?;878;))+.27BFHIHEA=96446:>BFHJIGEB?>>?ADGIIGC?:64347"#$'+059=?@?<952/..037;>@A@>:731//147;>@AA@=;9878:=?AA?<841/./1!$(-146641.+)((*,/2578752/,*))*-035788753100134688630-*)()+!%(+-.-+)'$#""#%(*-./.,*(%$##$&(+-.//.-+*))+,.//-+)&$""$!#$%$#!  #$%&%$" !#$&&%$#"!!"#$%&&%#!                         9 ,                     %%$#"!  !""##"    !"#//.,+*)(()*+,,+)&# !"#$%%$#!"$')+,,89987532112245542/+'" "$%&'()*+,--,+*(&#"!!"$'*.13566BCDCCA?=;::;<=>><84/*&" "%')*+,-./01234420.,*))*-037;=?@@JLMMLKIFDBAABCEFGFDA=83.)&%%&(*,.0112234689;<<;975321358=AEGIJJQSUVUTQNLIHGHIKMNNLJE@;61.,,-/24567665679<>ABCCB@><::;>AFJNQSSVY[\\[XUROMLLMORSTSQMHC>964468:;==<;9889;>BEHJKJIGECBCFINRVY[[ZZ]`bba^ZVRPNNPRUWYYWTOJEA><=>@ACCB@>;9889;?CHLOQQPOMKJKMQUY]`aa_[_cefeb^YUQOOQSWZ\]\ZVQLHFDEFGIIGD@=9778;?DIOSVWWVTRQRTW[_cefebZ_dghgd`ZUQONPSV[^``^[WSOMLLMOPONKGB=86458=CIPUZ\]\ZYWWY\_cghigdY^cghhe`ZUPMLNQUZ^acb_\XUSRSTUVURNIC=74236;AIPW\`aa`^\\]`cfikjhdW]bfhhe`ZTOKJLOTY_bdec`][YXYZ[[ZVQJC<61/028?GOW^bdedb``acehklkhcT[`eggd_XRMIHIMRX^cfgfda_^^=`a`^ZTLD<50--055.*(*.5>HQZaeggfeddegijjhc]LSZ_bb_ZSLFA@AFLS[bgijjhggijkkid]TJ@70+)+/5>GPX_ceedcbbdfhiigb\LSY_bb_YSLEA@AELS[afijihffhijjid^ULB92-+,/5=FNV\`bba``bdghhfb\KRY^aa^YRKEA?AEKSZafhihfeddeghigd^VMD<50-.16=EMTY]^^]]^`ceggea[KRY^aa^YRKEA@AEKSZ`eghfdbaabdefeb^WOF>830037=DKQVXZYYXYZ]`cefd`ZKQX]``]XRKEA@AEKRY_dffdb_^]^_abb`\WPHA:63358>CINRTTUWZ]addc_ZJQW\__\WQKEA@AEJQX^bcca^[YXYZ\]^]ZUOIC=86569=BGJMNONNPRVZ^aba^XIOUZ]]ZVPJDA?@DIPV[_``]ZWTSRSUWXXVSNIC>:878:=@DFHIHHJMRV[^_^[WGMRWYYWSMHB?>?BGMSX[\[XUQNLLNPQRQOLGC?;9889;>@ABBABDHLQVY[ZXSDJOSUUSOJE@=<=@DJOSVWVSOKHEDEFHIKKJGDA>;97789:;<<;::<>BGLPTVVSO@EIMOOMJE@<989<@EIMPPOLHD@><<=?ABCCB@>;976556543357;@EJMOOMJ;?CGHIGD@;85457;?CFHIGDA=9654568:;<;:9754221100/.-,+,.049>BFHHFC48?@><-14677641.+*))+.13677530,)&%$$%'(*+,,+*)('&%$"!  "&*.256764&)+-./.,)'%##$&)+-..,*(%" "#$%%$#"! #&),-.-+!#$%%#" !#$%%$" !#$%$#                        !   *                  #$$%$"  -.-,)&"  678753/+'"!#$%&&%$#! @?@AA@?<84/*%" !#%(*,--,+*(&# IHGGHIIGEA<71,)&%&'*-/1344321/-*'# QPNNOPPOMJE?94/-,,.1479:;::8641.*&! WUSRRSTUVVTQLF@;632247;>@AA?=;851-(# \YVUUWYZ[ZWRMGA<978:=ADFHHGEB?<840*% _[XVUVX[]^^\XRLFA><=?BFJLNNMKHD@<72,'! _[WUTUX[^`a_\VPJEB@ACGKNQSSRPMID@:5/(" _ZVSRSVZ^aba^YTMHDCCFINRUWXWURNID>81*$ ^XSPOQTX]acc`\VPJFDEGKPTXZ\[YWSNHB<4-& \VQNMNRV\`cca]WQKGEEGKPUY\^^][WSMG@91)" ZTNKJKOTZ_bcb^XRLGEDFJOTY]`aa_\XSLE=5-% YRLIGIMSY^bcb^XRLGDCDHMRW\_bcb`\XRKC:1)  WPJGFGLQX^bcb^XRKFBABEJOUZ^acdc`\WPH?6-$ VOIEDFJPW]acb^XQKEA?@BFKQV[_bddc`[UMD;1( UNHDCEJPV]acb^XQJD@==?CGMRW\`bdcb^XQH?5+" UNHDCEIPV\acb^XQJD?<;;:;=@EINSX\_aa_[UMD:0& TMGDCEIOV\`bb^XQJD>;99;>AEJNSW[]^]ZUNE;1( SMGDCEIOU[`ba^XQJD>;98:<>BFJNRVYZZXSMD;1( RLGCCDINUZ_a`]WQJD>;989::8789:@CFIJJIE@:2*" JEA?>?CHMRUWVSOJD?;75445678:<>@BCCB?:4-& EA=;:BFHJIGC?;630/../0123455430,'" 95311247;>@AA?<840.+*))*+,--..-+)%! 1.,**+-025787630-*'%$$%&'&%$! )'%$$&(*-./.-+(&#!  ! !"$%&%$#!                    z=,d Background     Wl,dWXXX,dWWWWXXXDXTXdXt:        &>>Q            00002K% commons-modeler-2.0.1-src/xdocs/index.xml100644 0 0 5323 10636604104 15502 0ustar 0 0 Commons Commons Documentation Team

Java Management Extensions (JMX) is an API that facilitates building management applications that can configure, and perform operations on, a server application. In general, each manageable component of the server application is represented by a Management Bean (or MBean, for short). JMX defines three types of MBeans, of which Model MBeans are the most flexible. Model MBeans provide a way to define MBeans for many different components, without having to write a specific MBean implementation class for each one.

However, this power comes at a price. It is necessary to set up a substantial amount of metadata about each MBean, including the attributes it should expose (similar to JavaBeans properties), the operations it should make available (similar to calling methods of a Java object via reflection), and other related information. The Modeler component is designed to make this process fairly painless -- the required metadata is configured from an XML description of each Model MBean to be supported. In addition, Modeler provides a factory mechanism to create the actual Model MBean instances themselves.

For further information, see the package description for the Modeler package.

See the downloads page for information on obtaining releases.


The JavaDoc API documents are available online.

commons-modeler-2.0.1-src/xdocs/issue-tracking.xml100644 0 0 7517 10636604104 17332 0ustar 0 0 Issue tracking Commons Documentation Team

Commons Modeler uses ASF JIRA for for tracking issues. See Modeler's JIRA project page.

To use JIRA you may need to create an account (if you have previously created/updated Commons issues using Bugzilla an account will have been automatically created and you can use the Forgot Password page to get a new password).

If you would like to report a bug, or raise an enhancement request with Commons Modeler please do the following:

  1. Search existing open bugs. If you find your issue listed then please add a comment with your details.
  2. Search the mailing list archive. You may find your issue or idea has already been discussed.
  3. Decide if your issue is a bug or an enhancement.
  4. Submit either a bug report or enhancement request.

Please also remember these points:

  • the more information you provide, the better we can help you
  • test cases are vital, particularly for any proposed enhancements
  • the developers of Commons Modeler are all unpaid volunteers

For more information on subversion and creating patches see the Apache Contributors Guide.

You may also find these links useful:

commons-modeler-2.0.1-src/xdocs/navigation.xml100644 0 0 7117 10636604104 16535 0ustar 0 0 Commons Modeler &commons; commons-modeler-2.0.1-src/xdocs/style/project.css100644 0 0 103 10636604104 17140 0ustar 0 0 @import url("http://jakarta.apache.org/style/jakarta-maven.css"); Issue tracking Commons Documentation Team

Commons Modeler uses ASF JIRA for for tracking issues. See Modeler's JIRA project page.

To use JIRA you may need to create an account (if you have previously created/updated Commons issues using Bugzilla an account will have been automatically created and you can use the Forgot Password page to get a new password).

If you would like to report a bug, or raise an enhancement request with Commons Modeler please do the following:

  1. Search existing open bugs. If you find your issue listed then please add a comment with your details.
  2. Search the mailing list archive. You may find your issue or idea has already been discussed.
  3. Decide if your issue is a bug or an enhancement.
  4. Submit either a bug report or enhancement request.

Please also remember these points:

  • the more information you provide, the better we can help you
  • test cases are vital, particularly for any proposed enhancements
  • the developers of Commons Modeler are all unpaid volunteers

For more information on subversion and creating patches see the