KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > system > controller > support > Simple


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.test.system.controller.support;
23
24 import java.math.BigDecimal JavaDoc;
25 import java.math.BigInteger JavaDoc;
26 import java.util.Collection JavaDoc;
27 import java.util.Date JavaDoc;
28
29 import javax.management.ObjectName JavaDoc;
30
31 import org.jboss.system.ServiceMBeanSupport;
32 import org.jboss.test.system.controller.integration.support.SimpleBean;
33 import org.jboss.util.NotImplementedException;
34 import org.w3c.dom.Element JavaDoc;
35
36 /**
37  * Simple.
38  *
39  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
40  * @version $Revision: 1.1 $
41  */

42 public class Simple extends ServiceMBeanSupport implements SimpleMBean, SimpleStandardMBeanInterface
43 {
44    public String JavaDoc constructorUsed;
45    
46    public int createOrder;
47    public int startOrder;
48    public int stopOrder;
49    public int destroyOrder;
50    
51    boolean touched = false;
52    
53    /** An object */
54    private Object JavaDoc object;
55    
56    /** A string */
57    private String JavaDoc aString;
58
59    /** Byte */
60    private Byte JavaDoc aByte;
61
62    /** Boolean */
63    private Boolean JavaDoc aBoolean;
64
65    /** Character */
66    private Character JavaDoc aCharacter;
67
68    /** Short */
69    private Short JavaDoc aShort;
70
71    /** Int */
72    private Integer JavaDoc anInt;
73
74    /** Long */
75    private Long JavaDoc aLong;
76
77    /** Float */
78    private Float JavaDoc aFloat;
79
80    /** Double */
81    private Double JavaDoc aDouble;
82
83    /** Date */
84    private Date JavaDoc aDate;
85
86    /** BigDecimal */
87    private BigDecimal JavaDoc aBigDecimal;
88
89    /** BigDecimal */
90    private BigInteger JavaDoc aBigInteger;
91
92    /** byte */
93    private byte abyte;
94
95    /** boolean */
96    private boolean aboolean;
97
98    /** char */
99    private char achar;
100
101    /** short */
102    private short ashort;
103
104    /** int */
105    private int anint;
106
107    /** long */
108    private long along;
109
110    /** float */
111    private float afloat;
112
113    /** double */
114    private double adouble;
115
116    /** number */
117    private Number JavaDoc aNumber;
118    
119    /** objectName */
120    private ObjectName JavaDoc objectName;
121    
122    /** objectNames */
123    private Collection JavaDoc<ObjectName JavaDoc> objectNames;
124    
125    /** First attribute */
126    private String JavaDoc attribute1;
127    
128    /** Second attribute */
129    private String JavaDoc attribute2;
130    
131    /** First attribute */
132    private ObjectName JavaDoc objectNameAttribute1;
133    
134    /** Second attribute */
135    private ObjectName JavaDoc objectNameAttribute2;
136    
137    /** First attribute */
138    private Collection JavaDoc<ObjectName JavaDoc> objectNamesAttribute1;
139    
140    /** Second attribute */
141    private Collection JavaDoc<ObjectName JavaDoc> objectNamesAttribute2;
142
143    private SimpleStandardMBeanInterface proxy;
144
145    private Element JavaDoc element;
146
147    private JavaBean javaBean;
148    
149    private Simple simple;
150    
151    private SimpleBean simpleBean;
152
153    public Simple()
154    {
155       constructorUsed = "()";
156    }
157    
158    public Simple(String JavaDoc string)
159    {
160       constructorUsed = "(java.lang.String)";
161       aString = string;
162       if ("error".equals(string))
163          throw new Error JavaDoc();
164       if ("exception".equals(string))
165          throw new RuntimeException JavaDoc();
166    }
167    
168    public Simple(int integer)
169    {
170       constructorUsed = "(int)";
171       anint = integer;
172    }
173    
174    public Simple(int integer, float number)
175    {
176       constructorUsed = "(int,float)";
177       anint = integer;
178       afloat = number;
179    }
180    
181    public Simple getInstance()
182    {
183       return this;
184    }
185    
186    protected void createService()
187    {
188       createOrder = Order.getOrder();
189       if ("ERRORINCREATE".equals(aString))
190          throw new Error JavaDoc("BROKEN CREATE");
191    }
192    
193    protected void startService()
194    {
195       startOrder = Order.getOrder();
196       if ("ERRORINSTART".equals(aString))
197          throw new Error JavaDoc("BROKEN START");
198    }
199    
200    protected void stopService()
201    {
202       stopOrder = Order.getOrder();
203       if ("ERRORINSTOP".equals(aString))
204          throw new Error JavaDoc("BROKEN STOP");
205    }
206    
207    protected void destroyService()
208    {
209       destroyOrder = Order.getOrder();
210       if ("ERRORINDESTROY".equals(aString))
211          throw new Error JavaDoc("BROKEN DESTROY");
212    }
213
214    public Object JavaDoc getObject()
215    {
216       return object;
217    }
218
219    public void setObject(Object JavaDoc object)
220    {
221       this.object = object;
222    }
223
224    public BigDecimal JavaDoc getABigDecimal()
225    {
226       return aBigDecimal;
227    }
228
229    public void setABigDecimal(BigDecimal JavaDoc bigDecimal)
230    {
231       aBigDecimal = bigDecimal;
232    }
233
234    public BigInteger JavaDoc getABigInteger()
235    {
236       return aBigInteger;
237    }
238
239    public void setABigInteger(BigInteger JavaDoc bigInteger)
240    {
241       aBigInteger = bigInteger;
242    }
243
244    public boolean isAboolean()
245    {
246       return aboolean;
247    }
248
249    public void setAboolean(boolean aboolean)
250    {
251       this.aboolean = aboolean;
252    }
253
254    public Boolean JavaDoc getABoolean()
255    {
256       return aBoolean;
257    }
258
259    public void setABoolean(Boolean JavaDoc boolean1)
260    {
261       aBoolean = boolean1;
262    }
263
264    public Number JavaDoc getANumber()
265    {
266       return aNumber;
267    }
268
269    public void setANumber(Number JavaDoc number)
270    {
271       aNumber = number;
272    }
273
274    public byte getAbyte()
275    {
276       return abyte;
277    }
278
279    public void setAbyte(byte abyte)
280    {
281       this.abyte = abyte;
282    }
283
284    public Byte JavaDoc getAByte()
285    {
286       return aByte;
287    }
288
289    public void setAByte(Byte JavaDoc byte1)
290    {
291       aByte = byte1;
292    }
293
294    public char getAchar()
295    {
296       return achar;
297    }
298
299    public void setAchar(char achar)
300    {
301       this.achar = achar;
302    }
303
304    public Character JavaDoc getACharacter()
305    {
306       return aCharacter;
307    }
308
309    public void setACharacter(Character JavaDoc character)
310    {
311       aCharacter = character;
312    }
313
314    public Date JavaDoc getADate()
315    {
316       return aDate;
317    }
318
319    public void setADate(Date JavaDoc date)
320    {
321       aDate = date;
322    }
323
324    public double getAdouble()
325    {
326       return adouble;
327    }
328
329    public void setAdouble(double adouble)
330    {
331       this.adouble = adouble;
332    }
333
334    public Double JavaDoc getADouble()
335    {
336       return aDouble;
337    }
338
339    public void setADouble(Double JavaDoc double1)
340    {
341       aDouble = double1;
342    }
343
344    public float getAfloat()
345    {
346       return afloat;
347    }
348
349    public void setAfloat(float afloat)
350    {
351       this.afloat = afloat;
352    }
353
354    public Float JavaDoc getAFloat()
355    {
356       return aFloat;
357    }
358
359    public void setAFloat(Float JavaDoc float1)
360    {
361       aFloat = float1;
362    }
363
364    public long getAlong()
365    {
366       return along;
367    }
368
369    public void setAlong(long along)
370    {
371       this.along = along;
372    }
373
374    public Long JavaDoc getALong()
375    {
376       return aLong;
377    }
378
379    public void setALong(Long JavaDoc long1)
380    {
381       aLong = long1;
382    }
383
384    public int getAnint()
385    {
386       return anint;
387    }
388
389    public void setAnint(int anint)
390    {
391       this.anint = anint;
392    }
393
394    public Integer JavaDoc getAnInt()
395    {
396       return anInt;
397    }
398
399    public void setAnInt(Integer JavaDoc anInt)
400    {
401       this.anInt = anInt;
402    }
403
404    public short getAshort()
405    {
406       return ashort;
407    }
408
409    public void setAshort(short ashort)
410    {
411       this.ashort = ashort;
412    }
413
414    public Short JavaDoc getAShort()
415    {
416       return aShort;
417    }
418
419    public void setAShort(Short JavaDoc short1)
420    {
421       aShort = short1;
422    }
423
424    public String JavaDoc getAString()
425    {
426       return aString;
427    }
428
429    public void setAString(String JavaDoc string)
430    {
431       aString = string;
432       if ("ERRORINPROPERTY".equals(aString))
433          throw new Error JavaDoc("BROKEN PROPERTY");
434    }
435
436    public ObjectName JavaDoc getObjectName()
437    {
438       return objectName;
439    }
440
441    public void setObjectName(ObjectName JavaDoc objectName)
442    {
443       this.objectName = objectName;
444    }
445
446    public Collection JavaDoc<ObjectName JavaDoc> getObjectNames()
447    {
448       return objectNames;
449    }
450
451    public void setObjectNames(Collection JavaDoc<ObjectName JavaDoc> objectNames)
452    {
453       this.objectNames = objectNames;
454    }
455
456    public String JavaDoc echoReverse(String JavaDoc test)
457    {
458       StringBuilder JavaDoc builder = new StringBuilder JavaDoc(test);
459       return builder.reverse().toString();
460    }
461    
462    public void touch()
463    {
464       this.touched = true;
465    }
466    
467    public boolean isTouched()
468    {
469       return touched;
470    }
471
472    public void setBrokenAttribute(String JavaDoc broken)
473    {
474       throw new Error JavaDoc("BROKEN");
475    }
476
477    public String JavaDoc getAttribute1()
478    {
479       return attribute1;
480    }
481
482    public void setAttribute1(String JavaDoc attribute1)
483    {
484       this.attribute1 = attribute1;
485    }
486
487    public String JavaDoc getAttribute2()
488    {
489       return attribute2;
490    }
491
492    public void setAttribute2(String JavaDoc attribute2)
493    {
494       this.attribute2 = attribute2;
495    }
496    
497    public void setBrokenObjectNameAttribute(ObjectName JavaDoc broken)
498    {
499       throw new Error JavaDoc("BROKEN");
500    }
501
502    public ObjectName JavaDoc getObjectNameAttribute1()
503    {
504       return objectNameAttribute1;
505    }
506
507    public void setObjectNameAttribute1(ObjectName JavaDoc objectNameAttribute1)
508    {
509       this.objectNameAttribute1 = objectNameAttribute1;
510    }
511
512    public ObjectName JavaDoc getObjectNameAttribute2()
513    {
514       return objectNameAttribute2;
515    }
516
517    public void setObjectNameAttribute2(ObjectName JavaDoc objectNameAttribute2)
518    {
519       this.objectNameAttribute2 = objectNameAttribute2;
520    }
521
522    public void setBrokenObjectNamesAttribute(Collection JavaDoc<ObjectName JavaDoc> broken)
523    {
524       throw new Error JavaDoc("BROKEN");
525    }
526
527    public Collection JavaDoc<ObjectName JavaDoc> getObjectNamesAttribute1()
528    {
529       return objectNamesAttribute1;
530    }
531    
532    public void setObjectNamesAttribute1(Collection JavaDoc<ObjectName JavaDoc> objectNamesAttribute1)
533    {
534       this.objectNamesAttribute1 = objectNamesAttribute1;
535    }
536
537    public Collection JavaDoc<ObjectName JavaDoc> getObjectNamesAttribute2()
538    {
539       return objectNamesAttribute2;
540    }
541
542    public void setObjectNamesAttribute2(Collection JavaDoc<ObjectName JavaDoc> objectNamesAttribute2)
543    {
544       this.objectNamesAttribute2 = objectNamesAttribute2;
545    }
546
547    public String JavaDoc getReadOnly()
548    {
549       return "ReadOnly!";
550    }
551    
552    public void setReadOnly(String JavaDoc readOnly)
553    {
554       throw new NotImplementedException("THIS ATTRIBUTE SHOULD BE READ ONLY!");
555    }
556
557    public SimpleStandardMBeanInterface getProxy()
558    {
559       return proxy;
560    }
561
562    public void setProxy(SimpleStandardMBeanInterface proxy)
563    {
564       this.proxy = proxy;
565    }
566    
567    public void touchProxy()
568    {
569       proxy.touch();
570    }
571
572    public Element JavaDoc getElement()
573    {
574       return element;
575    }
576
577    public void setElement(Element JavaDoc element)
578    {
579       this.element = element;
580    }
581
582    public JavaBean getJavaBean()
583    {
584       return javaBean;
585    }
586
587    public void setJavaBean(JavaBean javaBean)
588    {
589       this.javaBean = javaBean;
590    }
591    
592    public Simple getSimple()
593    {
594       return simple;
595    }
596
597    public void setSimple(Simple simple)
598    {
599       this.simple = simple;
600    }
601
602    public SimpleBean getSimpleBean()
603    {
604       return simpleBean;
605    }
606
607    public void setSimpleBean(SimpleBean simpleBean)
608    {
609       this.simpleBean = simpleBean;
610    }
611 }
612
Popular Tags