KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > jmx > examples > persistence > PersistentServiceExample


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, 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.jmx.examples.persistence;
23
24 import java.io.FileDescriptor JavaDoc;
25 import java.math.BigDecimal JavaDoc;
26 import java.sql.Timestamp JavaDoc;
27 import java.util.ArrayList JavaDoc;
28
29 import org.jboss.system.ServiceMBeanSupport;
30 import org.w3c.dom.Element JavaDoc;
31
32 /**
33  * PersistentServiceExample.
34  *
35  * Demonstrates the usage of XMBean attribute persistence.
36  *
37  * @jmx:mbean
38  * extends="org.jboss.system.ServiceMBean"
39  *
40  * @author <a HREF="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
41  * @version $Revision: 37459 $
42 **/

43 public class PersistentServiceExample
44    extends ServiceMBeanSupport
45    implements PersistentServiceExampleMBean
46 {
47    // Private Data --------------------------------------------------
48

49    // Primitives
50
private boolean someBoolean;
51    private int someInt;
52    
53    // Simple types with a property editor
54
private Integer JavaDoc someInteger;
55    private BigDecimal JavaDoc someBigDecimal;
56    private String JavaDoc someString;
57    
58    // an XML Element
59
private Element JavaDoc someElement;
60    
61    // a serializable object without a property editor
62
private Timestamp JavaDoc someTimestamp;
63    
64    // a serializable object containing non-serializable objects
65
private ArrayList JavaDoc someArrayList;
66    
67    // a non-serializable object without a property editor
68
private FileDescriptor JavaDoc someFileDescriptor;
69    
70    // a null object
71
private Object JavaDoc someNullObject;
72    
73    // Constructors -------------------------------------------------
74

75    /**
76     * Constructs a <tt>PersistentServiceExample</tt>.
77     */

78    public PersistentServiceExample()
79    {
80       super(PersistentServiceExample.class);
81       
82       this.someBoolean = true;
83       this.someInt = 666;
84       
85       this.someInteger = new Integer JavaDoc(999);
86       this.someBigDecimal = new BigDecimal JavaDoc("3.14e66");
87       this.someString = new String JavaDoc("I've got the devil inside me");
88       
89       this.someElement = null;
90
91       this.someTimestamp = new Timestamp JavaDoc(System.currentTimeMillis());
92       
93       this.someArrayList = new ArrayList JavaDoc();
94       this.someArrayList.add(new FileDescriptor JavaDoc());
95       
96       this.someFileDescriptor = new FileDescriptor JavaDoc();
97       
98       this.someNullObject = null;
99    }
100
101    // Attributes ----------------------------------------------------
102

103    /**
104     * @return Returns the someBigDecimal.
105     * @jmx:managed-attribute
106     */

107    public BigDecimal JavaDoc getSomeBigDecimal() {
108       return someBigDecimal;
109    }
110    
111    /**
112     * @param someBigDecimal The someBigDecimal to set.
113     * @jmx:managed-attribute
114     */

115    public void setSomeBigDecimal(BigDecimal JavaDoc someBigDecimal) {
116       this.someBigDecimal = someBigDecimal;
117    }
118    
119    /**
120     * @return Returns the someBoolean.
121     * @jmx:managed-attribute
122     */

123    public boolean isSomeBoolean() {
124       return someBoolean;
125    }
126    
127    /**
128     * @param someBoolean The someBoolean to set.
129     * @jmx:managed-attribute
130     */

131    public void setSomeBoolean(boolean someBoolean) {
132       this.someBoolean = someBoolean;
133    }
134    
135    /**
136     * @return Returns the someElement.
137     * @jmx:managed-attribute
138     */

139    public Element JavaDoc getSomeElement() {
140       return someElement;
141    }
142    
143    /**
144     * @param someElement The someElement to set.
145     * @jmx:managed-attribute
146     */

147    public void setSomeElement(Element JavaDoc someElement) {
148       this.someElement = someElement;
149    }
150    
151    /**
152     * @return Returns the someFileDescriptor.
153     * @jmx:managed-attribute
154     */

155    public FileDescriptor JavaDoc getSomeFileDescriptor() {
156       return someFileDescriptor;
157    }
158    
159    /**
160     * @param someFileDescriptor The someFileDescriptor to set.
161     * @jmx:managed-attribute
162     */

163    public void setSomeFileDescriptor(FileDescriptor JavaDoc someFileDescriptor) {
164       this.someFileDescriptor = someFileDescriptor;
165    }
166    
167    /**
168     * @return Returns the someInt.
169     * @jmx:managed-attribute
170     */

171    public int getSomeInt() {
172       return someInt;
173    }
174    
175    /**
176     * @param someInt The someInt to set.
177     * @jmx:managed-attribute
178     */

179    public void setSomeInt(int someInt) {
180       this.someInt = someInt;
181    }
182    
183    /**
184     * @return Returns the someInteger.
185     * @jmx:managed-attribute
186     */

187    public Integer JavaDoc getSomeInteger() {
188       return someInteger;
189    }
190    
191    /**
192     * @param someInteger The someInteger to set.
193     * @jmx:managed-attribute
194     */

195    public void setSomeInteger(Integer JavaDoc someInteger) {
196       this.someInteger = someInteger;
197    }
198    
199    /**
200     * @return Returns the someString.
201     * @jmx:managed-attribute
202     */

203    public String JavaDoc getSomeString() {
204       return someString;
205    }
206    
207    /**
208     * @param someString The someString to set.
209     * @jmx:managed-attribute
210     */

211    public void setSomeString(String JavaDoc someString) {
212       this.someString = someString;
213    }
214    
215    /**
216     * @return Returns the someTimestamp.
217     * @jmx:managed-attribute
218     */

219    public Timestamp JavaDoc getSomeTimestamp() {
220       someTimestamp = new Timestamp JavaDoc(System.currentTimeMillis());
221       return someTimestamp;
222    }
223    
224    /**
225     * @param someTimestamp The someTimestamp to set.
226     * @jmx:managed-attribute
227     */

228    public void setSomeTimestamp(Timestamp JavaDoc someTimestamp) {
229       this.someTimestamp = someTimestamp;
230    }
231    
232    /**
233     * @return Returns the someNullObject.
234     * @jmx:managed-attribute
235     */

236    public Object JavaDoc getSomeNullObject() {
237       return someNullObject;
238    }
239    
240    /**
241     * @param someNullObject The someNullObject to set.
242     * @jmx:managed-attribute
243     */

244    public void setSomeNullObject(Object JavaDoc someNullObject) {
245       // ignore
246
}
247    
248    /**
249     * @return Returns the someArrayList.
250     * @jmx:managed-attribute
251     */

252    public ArrayList JavaDoc getSomeArrayList() {
253       return someArrayList;
254    }
255    
256    /**
257     * @param someArrayList The someArrayList to set.
258     * @jmx:managed-attribute
259     */

260    public void setSomeArrayList(ArrayList JavaDoc someArrayList) {
261       this.someArrayList = someArrayList;
262    }
263 }
Popular Tags