KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > testapp > mbeans > Configuration


1 /**
2  * Copyright 2004-2005 jManage.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.jmanage.testapp.mbeans;
17
18 /**
19  *
20  * date: Dec 19, 2004
21  * @author Rakesh Kalra
22  */

23 public class Configuration implements ConfigurationMBean {
24
25     private final String JavaDoc appName = "testApp";
26     private long whenStarted = System.currentTimeMillis();
27     private int maxConnectionPoolSize = 10;
28
29     /* read only properties */
30     public String JavaDoc getAppName() {
31         return appName;
32     }
33
34     public long getAppUptime() {
35         return System.currentTimeMillis() - whenStarted;
36     }
37
38     /* read write property */
39     public int getMaxConnectionPoolSize() {
40         return maxConnectionPoolSize;
41     }
42
43     public void setMaxConnectionPoolSize(int size) {
44         this.maxConnectionPoolSize = size;
45     }
46
47     /**@return previous uptime */
48     public long resetAppUptime() {
49         long prevUptime = getAppUptime();
50         whenStarted = System.currentTimeMillis();
51         return prevUptime;
52     }
53
54     public void throwError(){
55         throw new RuntimeException JavaDoc("This is a test error.");
56     }
57 }
58
Popular Tags