01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package test.javax.management.support;
10:
11: import javax.management.Attribute;
12: import javax.management.AttributeList;
13: import javax.management.AttributeNotFoundException;
14: import javax.management.DynamicMBean;
15: import javax.management.InvalidAttributeValueException;
16: import javax.management.MBeanAttributeInfo;
17: import javax.management.MBeanConstructorInfo;
18: import javax.management.MBeanException;
19: import javax.management.MBeanInfo;
20: import javax.management.MBeanNotificationInfo;
21: import javax.management.MBeanOperationInfo;
22: import javax.management.MBeanRegistration;
23: import javax.management.MBeanServer;
24: import javax.management.ObjectName;
25: import javax.management.ReflectionException;
26:
27: /**
28: * @version $Revision: 1.3 $
29: */
30: public class ExceptionGeneratingDMB implements DynamicMBean,
31: MBeanRegistration {
32: private boolean invoked = false;
33: private boolean register;
34:
35: public ExceptionGeneratingDMB(boolean register) {
36: this .register = register;
37: }
38:
39: public MBeanInfo getMBeanInfo() {
40: if ((this .register == false) || (this .invoked == true)) {
41: throw new RuntimeException();
42: } else {
43: invoked = true;
44: return new MBeanInfo(
45: "test.javax.management.support.test.ExceptionGeneratingDMB",
46: "Exception generating DynamicMBean",
47: new MBeanAttributeInfo[0],
48: new MBeanConstructorInfo[0],
49: new MBeanOperationInfo[0],
50: new MBeanNotificationInfo[0]);
51: }
52: }
53:
54: public Object getAttribute(String attribute)
55: throws AttributeNotFoundException, MBeanException,
56: ReflectionException {
57: return null;
58: }
59:
60: public void setAttribute(Attribute attribute)
61: throws AttributeNotFoundException,
62: InvalidAttributeValueException, MBeanException,
63: ReflectionException {
64: }
65:
66: public AttributeList getAttributes(String[] attributes) {
67: return null;
68: }
69:
70: public AttributeList setAttributes(AttributeList attributes) {
71: return null;
72: }
73:
74: public Object invoke(String method, Object[] arguments,
75: String[] params) throws MBeanException, ReflectionException {
76: return null;
77: }
78:
79: public ObjectName preRegister(MBeanServer server, ObjectName name)
80: throws Exception {
81: if (name.getKeyProperty("register").compareTo("no") == 0) {
82: this .register = false;
83: }
84: return name;
85: }
86:
87: public void postRegister(Boolean registrationDone) {
88: }
89:
90: public void preDeregister() throws Exception {
91: }
92:
93: public void postDeregister() {
94: }
95:
96: }
|