001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.jmx.examples.persistence;
023:
024: import java.io.FileDescriptor;
025: import java.math.BigDecimal;
026: import java.sql.Timestamp;
027: import java.util.ArrayList;
028:
029: import org.jboss.system.ServiceMBeanSupport;
030: import org.w3c.dom.Element;
031:
032: /**
033: * PersistentServiceExample.
034: *
035: * Demonstrates the usage of XMBean attribute persistence.
036: *
037: * @jmx:mbean
038: * extends="org.jboss.system.ServiceMBean"
039: *
040: * @author <a href="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
041: * @version $Revision: 57210 $
042: **/
043: public class PersistentServiceExample extends ServiceMBeanSupport
044: implements PersistentServiceExampleMBean {
045: // Private Data --------------------------------------------------
046:
047: // Primitives
048: private boolean someBoolean;
049: private int someInt;
050:
051: // Simple types with a property editor
052: private Integer someInteger;
053: private BigDecimal someBigDecimal;
054: private String someString;
055:
056: // an XML Element
057: private Element someElement;
058:
059: // a serializable object without a property editor
060: private Timestamp someTimestamp;
061:
062: // a serializable object containing non-serializable objects
063: private ArrayList someArrayList;
064:
065: // a non-serializable object without a property editor
066: private FileDescriptor someFileDescriptor;
067:
068: // a null object
069: private Object someNullObject;
070:
071: // Constructors -------------------------------------------------
072:
073: /**
074: * Constructs a <tt>PersistentServiceExample</tt>.
075: */
076: public PersistentServiceExample() {
077: super (PersistentServiceExample.class);
078:
079: this .someBoolean = true;
080: this .someInt = 666;
081:
082: this .someInteger = new Integer(999);
083: this .someBigDecimal = new BigDecimal("3.14e66");
084: this .someString = new String("I've got the devil inside me");
085:
086: this .someElement = null;
087:
088: this .someTimestamp = new Timestamp(System.currentTimeMillis());
089:
090: this .someArrayList = new ArrayList();
091: this .someArrayList.add(new FileDescriptor());
092:
093: this .someFileDescriptor = new FileDescriptor();
094:
095: this .someNullObject = null;
096: }
097:
098: // Attributes ----------------------------------------------------
099:
100: /**
101: * @return Returns the someBigDecimal.
102: * @jmx:managed-attribute
103: */
104: public BigDecimal getSomeBigDecimal() {
105: return someBigDecimal;
106: }
107:
108: /**
109: * @param someBigDecimal The someBigDecimal to set.
110: * @jmx:managed-attribute
111: */
112: public void setSomeBigDecimal(BigDecimal someBigDecimal) {
113: this .someBigDecimal = someBigDecimal;
114: }
115:
116: /**
117: * @return Returns the someBoolean.
118: * @jmx:managed-attribute
119: */
120: public boolean isSomeBoolean() {
121: return someBoolean;
122: }
123:
124: /**
125: * @param someBoolean The someBoolean to set.
126: * @jmx:managed-attribute
127: */
128: public void setSomeBoolean(boolean someBoolean) {
129: this .someBoolean = someBoolean;
130: }
131:
132: /**
133: * @return Returns the someElement.
134: * @jmx:managed-attribute
135: */
136: public Element getSomeElement() {
137: return someElement;
138: }
139:
140: /**
141: * @param someElement The someElement to set.
142: * @jmx:managed-attribute
143: */
144: public void setSomeElement(Element someElement) {
145: this .someElement = someElement;
146: }
147:
148: /**
149: * @return Returns the someFileDescriptor.
150: * @jmx:managed-attribute
151: */
152: public FileDescriptor getSomeFileDescriptor() {
153: return someFileDescriptor;
154: }
155:
156: /**
157: * @param someFileDescriptor The someFileDescriptor to set.
158: * @jmx:managed-attribute
159: */
160: public void setSomeFileDescriptor(FileDescriptor someFileDescriptor) {
161: this .someFileDescriptor = someFileDescriptor;
162: }
163:
164: /**
165: * @return Returns the someInt.
166: * @jmx:managed-attribute
167: */
168: public int getSomeInt() {
169: return someInt;
170: }
171:
172: /**
173: * @param someInt The someInt to set.
174: * @jmx:managed-attribute
175: */
176: public void setSomeInt(int someInt) {
177: this .someInt = someInt;
178: }
179:
180: /**
181: * @return Returns the someInteger.
182: * @jmx:managed-attribute
183: */
184: public Integer getSomeInteger() {
185: return someInteger;
186: }
187:
188: /**
189: * @param someInteger The someInteger to set.
190: * @jmx:managed-attribute
191: */
192: public void setSomeInteger(Integer someInteger) {
193: this .someInteger = someInteger;
194: }
195:
196: /**
197: * @return Returns the someString.
198: * @jmx:managed-attribute
199: */
200: public String getSomeString() {
201: return someString;
202: }
203:
204: /**
205: * @param someString The someString to set.
206: * @jmx:managed-attribute
207: */
208: public void setSomeString(String someString) {
209: this .someString = someString;
210: }
211:
212: /**
213: * @return Returns the someTimestamp.
214: * @jmx:managed-attribute
215: */
216: public Timestamp getSomeTimestamp() {
217: someTimestamp = new Timestamp(System.currentTimeMillis());
218: return someTimestamp;
219: }
220:
221: /**
222: * @param someTimestamp The someTimestamp to set.
223: * @jmx:managed-attribute
224: */
225: public void setSomeTimestamp(Timestamp someTimestamp) {
226: this .someTimestamp = someTimestamp;
227: }
228:
229: /**
230: * @return Returns the someNullObject.
231: * @jmx:managed-attribute
232: */
233: public Object getSomeNullObject() {
234: return someNullObject;
235: }
236:
237: /**
238: * @param someNullObject The someNullObject to set.
239: * @jmx:managed-attribute
240: */
241: public void setSomeNullObject(Object someNullObject) {
242: // ignore
243: }
244:
245: /**
246: * @return Returns the someArrayList.
247: * @jmx:managed-attribute
248: */
249: public ArrayList getSomeArrayList() {
250: return someArrayList;
251: }
252:
253: /**
254: * @param someArrayList The someArrayList to set.
255: * @jmx:managed-attribute
256: */
257: public void setSomeArrayList(ArrayList someArrayList) {
258: this.someArrayList = someArrayList;
259: }
260: }
|