001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package test.implementation.util.support;
023:
024: import javax.management.modelmbean.ModelMBeanInfo;
025: import javax.management.modelmbean.ModelMBeanInfoSupport;
026: import javax.management.modelmbean.ModelMBeanAttributeInfo;
027: import javax.management.modelmbean.ModelMBeanOperationInfo;
028: import javax.management.MBeanParameterInfo;
029:
030: /**
031: * Overrides and exposes java.lang.Object methods in the management
032: * interface.
033: *
034: * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
035: * @version $Revision: 57200 $
036: */
037: public class ResourceOverride {
038:
039: // Attributes ----------------------------------------------------
040:
041: private String state = null;
042:
043: // Constructors --------------------------------------------------
044: public ResourceOverride(String state) {
045: this .state = state;
046: }
047:
048: public ResourceOverride() {
049: }
050:
051: // Public --------------------------------------------------------
052:
053: public ModelMBeanInfo getMBeanInfo() {
054: ModelMBeanAttributeInfo[] attributes = new ModelMBeanAttributeInfo[] {
055: new ModelMBeanAttributeInfo("AttributeName",
056: "java.lang.String", "description", false, true,
057: false),
058: new ModelMBeanAttributeInfo("AttributeName2",
059: "java.lang.String", "description", true, true,
060: false) };
061:
062: ModelMBeanOperationInfo[] operations = new ModelMBeanOperationInfo[] {
063: new ModelMBeanOperationInfo("doOperation",
064: "description", null, "java.lang.Object", 1),
065:
066: new ModelMBeanOperationInfo("toString",
067: "toString override", null, "java.lang.String",
068: 1),
069:
070: new ModelMBeanOperationInfo(
071: "equals",
072: "equals override",
073: new MBeanParameterInfo[] { new MBeanParameterInfo(
074: "object", "java.lang.Object",
075: "object to compare to") }, "boolean", 1),
076:
077: new ModelMBeanOperationInfo("hashCode",
078: "hashCode override in resource", null,
079: Integer.TYPE.getName(), 1) };
080:
081: ModelMBeanInfoSupport info = new ModelMBeanInfoSupport(
082: "test.implementation.util.support.Resource",
083: "description", attributes, null, operations, null);
084:
085: return info;
086: }
087:
088: public Object doOperation() {
089: return "tamppi";
090: }
091:
092: // Object overrides ----------------------------------------------
093:
094: public String toString() {
095: return "Resource";
096: }
097:
098: public boolean equals(Object o) {
099: return true;
100: }
101:
102: public int hashCode() {
103: return 10;
104: }
105: }
|