KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > javax > management > support > ExceptionGeneratingDMB


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package test.javax.management.support;
10
11 import javax.management.Attribute JavaDoc;
12 import javax.management.AttributeList JavaDoc;
13 import javax.management.AttributeNotFoundException JavaDoc;
14 import javax.management.DynamicMBean JavaDoc;
15 import javax.management.InvalidAttributeValueException JavaDoc;
16 import javax.management.MBeanAttributeInfo JavaDoc;
17 import javax.management.MBeanConstructorInfo JavaDoc;
18 import javax.management.MBeanException JavaDoc;
19 import javax.management.MBeanInfo JavaDoc;
20 import javax.management.MBeanNotificationInfo JavaDoc;
21 import javax.management.MBeanOperationInfo JavaDoc;
22 import javax.management.MBeanRegistration JavaDoc;
23 import javax.management.MBeanServer JavaDoc;
24 import javax.management.ObjectName JavaDoc;
25 import javax.management.ReflectionException JavaDoc;
26
27 /**
28  * @version $Revision: 1.3 $
29  */

30 public class ExceptionGeneratingDMB
31         implements DynamicMBean JavaDoc, MBeanRegistration JavaDoc
32 {
33    private boolean invoked = false;
34    private boolean register;
35
36    public ExceptionGeneratingDMB(boolean register)
37    {
38       this.register = register;
39    }
40
41    public MBeanInfo JavaDoc getMBeanInfo()
42    {
43       if ((this.register == false) || (this.invoked == true))
44       {
45          throw new RuntimeException JavaDoc();
46       }
47       else
48       {
49          invoked = true;
50          return new MBeanInfo JavaDoc("test.javax.management.support.test.ExceptionGeneratingDMB",
51                               "Exception generating DynamicMBean",
52                               new MBeanAttributeInfo JavaDoc[0],
53                               new MBeanConstructorInfo JavaDoc[0],
54                               new MBeanOperationInfo JavaDoc[0],
55                               new MBeanNotificationInfo JavaDoc[0]);
56       }
57    }
58
59    public Object JavaDoc getAttribute(String JavaDoc attribute)
60            throws AttributeNotFoundException JavaDoc, MBeanException JavaDoc, ReflectionException JavaDoc
61    {
62       return null;
63    }
64
65    public void setAttribute(Attribute JavaDoc attribute)
66            throws
67            AttributeNotFoundException JavaDoc,
68            InvalidAttributeValueException JavaDoc,
69            MBeanException JavaDoc,
70            ReflectionException JavaDoc
71    {
72    }
73
74    public AttributeList JavaDoc getAttributes(String JavaDoc[] attributes)
75    {
76       return null;
77    }
78
79    public AttributeList JavaDoc setAttributes(AttributeList JavaDoc attributes)
80    {
81       return null;
82    }
83
84    public Object JavaDoc invoke(String JavaDoc method, Object JavaDoc[] arguments, String JavaDoc[] params)
85            throws MBeanException JavaDoc, ReflectionException JavaDoc
86    {
87       return null;
88    }
89
90    public ObjectName JavaDoc preRegister(MBeanServer JavaDoc server, ObjectName JavaDoc name)
91            throws Exception JavaDoc
92    {
93       if (name.getKeyProperty("register").compareTo("no") == 0)
94       {
95          this.register = false;
96       }
97       return name;
98    }
99
100    public void postRegister(Boolean JavaDoc registrationDone)
101    {
102    }
103
104    public void preDeregister() throws Exception JavaDoc
105    {
106    }
107
108    public void postDeregister()
109    {
110    }
111
112 }
113
Popular Tags