KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > mx4j > tools > i18n > I18NStandardMBeanSupport


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.mx4j.tools.i18n;
10
11 import java.util.Locale JavaDoc;
12 import javax.management.NotCompliantMBeanException JavaDoc;
13
14 import mx4j.tools.i18n.I18NStandardMBean;
15
16
17 /**
18  */

19 public class I18NStandardMBeanSupport
20 {
21    /**
22     * No management interface and it is not a standard MBean
23     */

24    public static class SubclassNotCompliant extends I18NStandardMBean
25    {
26       public SubclassNotCompliant() throws NotCompliantMBeanException JavaDoc
27       {
28          super(null);
29       }
30    }
31
32    /**
33     * A simple management interface.
34     */

35    public interface FullManagement
36    {
37       public void setAttrib(int i);
38
39       public void operation(int i, Object JavaDoc obj);
40    }
41
42    /**
43     * A management interface have overloaded operations.
44     */

45    public interface OverloadManagement
46    {
47       public void setAttrib(int i);
48
49       public void operation();
50
51       public void operation(int i);
52
53       public void operation(Object JavaDoc obj);
54
55       public void operation(int[] array);
56
57       public void operation(Object JavaDoc[] array);
58
59       public void operation(int i, Object JavaDoc obj);
60
61       public void operation(int i, int j, int k);
62
63       public void operation(int i, int j, String JavaDoc s);
64    }
65
66    /**
67     * A base subclass of I18NStandardMBean (for factorization).
68     */

69    public static class BaseSubclass extends I18NStandardMBean
70    {
71       private int m_attrib = 0;
72
73       protected BaseSubclass(Class JavaDoc mbeanInterface) throws NotCompliantMBeanException JavaDoc
74       {
75          super(mbeanInterface);
76       }
77
78       protected BaseSubclass(Class JavaDoc mbeanInterface, Locale JavaDoc locale) throws NotCompliantMBeanException JavaDoc
79       {
80          super(mbeanInterface, locale);
81       }
82
83       public void setAttrib(int i)
84       {
85          m_attrib = i;
86       }
87
88       public void operation(int i, Object JavaDoc obj)
89       {
90       }
91    }
92
93    /**
94     * A base implementation NOT derrived from I18NStandardMBean.
95     */

96    public static class BaseImplementation implements FullManagement
97    {
98       private int m_attrib = 0;
99
100       public void setAttrib(int i)
101       {
102          m_attrib = i;
103       }
104
105       public void operation(int i, Object JavaDoc obj)
106       {
107       }
108    }
109
110    /**
111     * An I18NStandardMBean subclass having just a global name decription.
112     */

113    public static class SubclassNameOnly extends BaseSubclass implements FullManagement
114    {
115       public SubclassNameOnly() throws NotCompliantMBeanException JavaDoc
116       {
117          super(FullManagement.class);
118       }
119
120       public SubclassNameOnly(Locale JavaDoc locale) throws NotCompliantMBeanException JavaDoc
121       {
122          super(FullManagement.class, locale);
123       }
124    }
125
126    /**
127     * An I18NStandardMBean subclass having full descriptions.
128     */

129    public static class SubclassComplete extends BaseSubclass implements FullManagement
130    {
131       public SubclassComplete(Locale JavaDoc locale) throws NotCompliantMBeanException JavaDoc
132       {
133          super(FullManagement.class, locale);
134       }
135
136       public SubclassComplete() throws NotCompliantMBeanException JavaDoc
137       {
138          super(FullManagement.class);
139       }
140    }
141
142    /**
143     * An I18NStandardMBean subclass having no bundle.
144     */

145    public static class SubclassNoBundle extends BaseSubclass implements FullManagement
146    {
147       public SubclassNoBundle() throws NotCompliantMBeanException JavaDoc
148       {
149          super(FullManagement.class);
150       }
151    }
152
153    /**
154     * An I18NStandardMBean subclass having ambiguous constructors
155     */

156    public static class SubclassAmbiguousConstructors extends BaseSubclass implements FullManagement
157    {
158       // desciption can be found based on number of parameters
159
public SubclassAmbiguousConstructors() throws NotCompliantMBeanException JavaDoc
160       {
161          super(FullManagement.class);
162       }
163
164       // with no signature info in the bundle this cannot be distinguished from the Locale version
165
public SubclassAmbiguousConstructors(Locale JavaDoc locale) throws NotCompliantMBeanException JavaDoc
166       {
167          super(FullManagement.class, locale);
168       }
169
170       // with no signature info in the bundle this cannot be distinguished from the Locale version
171
public SubclassAmbiguousConstructors(int i) throws NotCompliantMBeanException JavaDoc
172       {
173          super(FullManagement.class);
174       }
175
176       // with no signature info in the bundle this cannot be distinguished from the Locale version
177
public SubclassAmbiguousConstructors(String JavaDoc s) throws NotCompliantMBeanException JavaDoc
178       {
179          super(FullManagement.class);
180       }
181
182       // This can determined with no signature (2 args)
183
public SubclassAmbiguousConstructors(int i, int j) throws NotCompliantMBeanException JavaDoc
184       {
185          super(FullManagement.class);
186       }
187
188       // of the two 3 arg constructors below only one is described in the bundle
189
// BUT they should both still be considered ambiguous
190
public SubclassAmbiguousConstructors(int i, int j, int k) throws NotCompliantMBeanException JavaDoc
191       {
192          super(FullManagement.class);
193       }
194
195       public SubclassAmbiguousConstructors(int i, int j, String JavaDoc s) throws NotCompliantMBeanException JavaDoc
196       {
197          super(FullManagement.class);
198       }
199    }
200
201    /**
202     * An I18NStandardMBean subclass overloaded constructors and operations.
203     */

204    public static class SubclassOverload extends BaseSubclass implements OverloadManagement
205    {
206
207       // no arguments
208
public SubclassOverload() throws NotCompliantMBeanException JavaDoc
209       {
210          super(OverloadManagement.class);
211       }
212
213       // one argument Object
214
public SubclassOverload(Object JavaDoc obj) throws NotCompliantMBeanException JavaDoc
215       {
216          super(OverloadManagement.class);
217       }
218
219       // one argument int
220
public SubclassOverload(int i) throws NotCompliantMBeanException JavaDoc
221       {
222          super(OverloadManagement.class);
223       }
224
225       // one argument int[]
226
public SubclassOverload(int[] i) throws NotCompliantMBeanException JavaDoc
227       {
228          super(OverloadManagement.class);
229       }
230
231       // one argument Object[]
232
public SubclassOverload(Object JavaDoc[] objs) throws NotCompliantMBeanException JavaDoc
233       {
234          super(OverloadManagement.class);
235       }
236
237       // 2 arguments
238
public SubclassOverload(int a, Object JavaDoc b) throws NotCompliantMBeanException JavaDoc
239       {
240          super(OverloadManagement.class);
241       }
242
243       public void operation()
244       {
245       }
246
247       public void operation(int i)
248       {
249       }
250
251       public void operation(Object JavaDoc obj)
252       {
253       }
254
255       public void operation(int[] array)
256       {
257       }
258
259       public void operation(Object JavaDoc[] array)
260       {
261       }
262
263       public void operation(int i, int j, int k)
264       {
265       }
266
267       public void operation(int i, int j, String JavaDoc s)
268       {
269       }
270
271    }
272
273    /**
274     * A subclass whose bundle will not specify sigs (so operations are ambiguous).
275     */

276    public static class SubclassAmbiguousOperation extends BaseSubclass implements OverloadManagement
277    {
278       public SubclassAmbiguousOperation() throws NotCompliantMBeanException JavaDoc
279       {
280          super(OverloadManagement.class);
281       }
282
283       public void operation()
284       {
285       }
286
287       public void operation(int i)
288       {
289       }
290
291       public void operation(Object JavaDoc obj)
292       {
293       }
294
295       public void operation(int[] array)
296       {
297       }
298
299       public void operation(Object JavaDoc[] array)
300       {
301       }
302
303       public void operation(int i, int j, int k)
304       {
305       }
306
307       public void operation(int i, int j, String JavaDoc s)
308       {
309       }
310
311    }
312
313    /**
314     * An I18N MBean implementation having just a global name decription.
315     */

316    public static class ImplementationNameOnly extends BaseImplementation
317    {
318    }
319
320    /**
321     * An I18N MBean implementation having full decriptions.
322     */

323    public static class ImplementationComplete extends BaseImplementation
324    {
325    }
326
327    /**
328     * An I18N MBean implementation having no bundle.
329     */

330    public static class ImplementationNoBundle extends BaseImplementation
331    {
332    }
333
334
335 }
336
Popular Tags