001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package test.mx4j.tools.i18n;
010:
011: import java.util.Locale;
012: import javax.management.NotCompliantMBeanException;
013:
014: import mx4j.tools.i18n.I18NStandardMBean;
015:
016: /**
017: */
018: public class I18NStandardMBeanSupport {
019: /**
020: * No management interface and it is not a standard MBean
021: */
022: public static class SubclassNotCompliant extends I18NStandardMBean {
023: public SubclassNotCompliant() throws NotCompliantMBeanException {
024: super (null);
025: }
026: }
027:
028: /**
029: * A simple management interface.
030: */
031: public interface FullManagement {
032: public void setAttrib(int i);
033:
034: public void operation(int i, Object obj);
035: }
036:
037: /**
038: * A management interface have overloaded operations.
039: */
040: public interface OverloadManagement {
041: public void setAttrib(int i);
042:
043: public void operation();
044:
045: public void operation(int i);
046:
047: public void operation(Object obj);
048:
049: public void operation(int[] array);
050:
051: public void operation(Object[] array);
052:
053: public void operation(int i, Object obj);
054:
055: public void operation(int i, int j, int k);
056:
057: public void operation(int i, int j, String s);
058: }
059:
060: /**
061: * A base subclass of I18NStandardMBean (for factorization).
062: */
063: public static class BaseSubclass extends I18NStandardMBean {
064: private int m_attrib = 0;
065:
066: protected BaseSubclass(Class mbeanInterface)
067: throws NotCompliantMBeanException {
068: super (mbeanInterface);
069: }
070:
071: protected BaseSubclass(Class mbeanInterface, Locale locale)
072: throws NotCompliantMBeanException {
073: super (mbeanInterface, locale);
074: }
075:
076: public void setAttrib(int i) {
077: m_attrib = i;
078: }
079:
080: public void operation(int i, Object obj) {
081: }
082: }
083:
084: /**
085: * A base implementation NOT derrived from I18NStandardMBean.
086: */
087: public static class BaseImplementation implements FullManagement {
088: private int m_attrib = 0;
089:
090: public void setAttrib(int i) {
091: m_attrib = i;
092: }
093:
094: public void operation(int i, Object obj) {
095: }
096: }
097:
098: /**
099: * An I18NStandardMBean subclass having just a global name decription.
100: */
101: public static class SubclassNameOnly extends BaseSubclass implements
102: FullManagement {
103: public SubclassNameOnly() throws NotCompliantMBeanException {
104: super (FullManagement.class);
105: }
106:
107: public SubclassNameOnly(Locale locale)
108: throws NotCompliantMBeanException {
109: super (FullManagement.class, locale);
110: }
111: }
112:
113: /**
114: * An I18NStandardMBean subclass having full descriptions.
115: */
116: public static class SubclassComplete extends BaseSubclass implements
117: FullManagement {
118: public SubclassComplete(Locale locale)
119: throws NotCompliantMBeanException {
120: super (FullManagement.class, locale);
121: }
122:
123: public SubclassComplete() throws NotCompliantMBeanException {
124: super (FullManagement.class);
125: }
126: }
127:
128: /**
129: * An I18NStandardMBean subclass having no bundle.
130: */
131: public static class SubclassNoBundle extends BaseSubclass implements
132: FullManagement {
133: public SubclassNoBundle() throws NotCompliantMBeanException {
134: super (FullManagement.class);
135: }
136: }
137:
138: /**
139: * An I18NStandardMBean subclass having ambiguous constructors
140: */
141: public static class SubclassAmbiguousConstructors extends
142: BaseSubclass implements FullManagement {
143: // desciption can be found based on number of parameters
144: public SubclassAmbiguousConstructors()
145: throws NotCompliantMBeanException {
146: super (FullManagement.class);
147: }
148:
149: // with no signature info in the bundle this cannot be distinguished from the Locale version
150: public SubclassAmbiguousConstructors(Locale locale)
151: throws NotCompliantMBeanException {
152: super (FullManagement.class, locale);
153: }
154:
155: // with no signature info in the bundle this cannot be distinguished from the Locale version
156: public SubclassAmbiguousConstructors(int i)
157: throws NotCompliantMBeanException {
158: super (FullManagement.class);
159: }
160:
161: // with no signature info in the bundle this cannot be distinguished from the Locale version
162: public SubclassAmbiguousConstructors(String s)
163: throws NotCompliantMBeanException {
164: super (FullManagement.class);
165: }
166:
167: // This can determined with no signature (2 args)
168: public SubclassAmbiguousConstructors(int i, int j)
169: throws NotCompliantMBeanException {
170: super (FullManagement.class);
171: }
172:
173: // of the two 3 arg constructors below only one is described in the bundle
174: // BUT they should both still be considered ambiguous
175: public SubclassAmbiguousConstructors(int i, int j, int k)
176: throws NotCompliantMBeanException {
177: super (FullManagement.class);
178: }
179:
180: public SubclassAmbiguousConstructors(int i, int j, String s)
181: throws NotCompliantMBeanException {
182: super (FullManagement.class);
183: }
184: }
185:
186: /**
187: * An I18NStandardMBean subclass overloaded constructors and operations.
188: */
189: public static class SubclassOverload extends BaseSubclass implements
190: OverloadManagement {
191:
192: // no arguments
193: public SubclassOverload() throws NotCompliantMBeanException {
194: super (OverloadManagement.class);
195: }
196:
197: // one argument Object
198: public SubclassOverload(Object obj)
199: throws NotCompliantMBeanException {
200: super (OverloadManagement.class);
201: }
202:
203: // one argument int
204: public SubclassOverload(int i)
205: throws NotCompliantMBeanException {
206: super (OverloadManagement.class);
207: }
208:
209: // one argument int[]
210: public SubclassOverload(int[] i)
211: throws NotCompliantMBeanException {
212: super (OverloadManagement.class);
213: }
214:
215: // one argument Object[]
216: public SubclassOverload(Object[] objs)
217: throws NotCompliantMBeanException {
218: super (OverloadManagement.class);
219: }
220:
221: // 2 arguments
222: public SubclassOverload(int a, Object b)
223: throws NotCompliantMBeanException {
224: super (OverloadManagement.class);
225: }
226:
227: public void operation() {
228: }
229:
230: public void operation(int i) {
231: }
232:
233: public void operation(Object obj) {
234: }
235:
236: public void operation(int[] array) {
237: }
238:
239: public void operation(Object[] array) {
240: }
241:
242: public void operation(int i, int j, int k) {
243: }
244:
245: public void operation(int i, int j, String s) {
246: }
247:
248: }
249:
250: /**
251: * A subclass whose bundle will not specify sigs (so operations are ambiguous).
252: */
253: public static class SubclassAmbiguousOperation extends BaseSubclass
254: implements OverloadManagement {
255: public SubclassAmbiguousOperation()
256: throws NotCompliantMBeanException {
257: super (OverloadManagement.class);
258: }
259:
260: public void operation() {
261: }
262:
263: public void operation(int i) {
264: }
265:
266: public void operation(Object obj) {
267: }
268:
269: public void operation(int[] array) {
270: }
271:
272: public void operation(Object[] array) {
273: }
274:
275: public void operation(int i, int j, int k) {
276: }
277:
278: public void operation(int i, int j, String s) {
279: }
280:
281: }
282:
283: /**
284: * An I18N MBean implementation having just a global name decription.
285: */
286: public static class ImplementationNameOnly extends
287: BaseImplementation {
288: }
289:
290: /**
291: * An I18N MBean implementation having full decriptions.
292: */
293: public static class ImplementationComplete extends
294: BaseImplementation {
295: }
296:
297: /**
298: * An I18N MBean implementation having no bundle.
299: */
300: public static class ImplementationNoBundle extends
301: BaseImplementation {
302: }
303:
304: }
|