KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jmx > export > annotation > AnnotationTestBean


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16
17 package org.springframework.jmx.export.annotation;
18
19 import org.springframework.jmx.IJmxTestBean;
20
21 /**
22  * @author Rob Harrop
23  */

24 @ManagedResource(objectName = "bean:name=testBean4", description = "My Managed Bean", log = true,
25         logFile = "jmx.log", currencyTimeLimit = 15, persistPolicy = "OnUpdate", persistPeriod = 200,
26         persistLocation = "./foo", persistName = "bar.jmx")
27 public class AnnotationTestBean implements IJmxTestBean {
28
29     private String JavaDoc name;
30
31     private String JavaDoc nickName;
32
33     private int age;
34
35     private boolean isSuperman;
36
37
38     @ManagedAttribute(description = "The Age Attribute", currencyTimeLimit = 15)
39     public int getAge() {
40         return age;
41     }
42
43     public void setAge(int age) {
44         this.age = age;
45     }
46
47     @ManagedOperation(currencyTimeLimit = 30)
48     public long myOperation() {
49         return 1L;
50     }
51
52     @ManagedAttribute(description = "The Name Attribute",
53             currencyTimeLimit = 20,
54             defaultValue = "bar",
55             persistPolicy = "OnUpdate")
56     public void setName(String JavaDoc name) {
57         this.name = name;
58     }
59
60     @ManagedAttribute(defaultValue = "foo", persistPeriod = 300)
61     public String JavaDoc getName() {
62         return name;
63     }
64
65     @org.springframework.jmx.export.annotation.ManagedAttribute(description = "The Nick Name Attribute")
66     public String JavaDoc getNickName() {
67         return this.nickName;
68     }
69
70     public void setNickName(String JavaDoc nickName) {
71         this.nickName = nickName;
72     }
73
74     @org.springframework.jmx.export.annotation.ManagedAttribute(description = "The Is Superman Attribute")
75     public void setSuperman(boolean superman) {
76         this.isSuperman = superman;
77     }
78
79     public boolean isSuperman() {
80         return isSuperman;
81     }
82
83     @org.springframework.jmx.export.annotation.ManagedOperation(description = "Add Two Numbers Together")
84     @ManagedOperationParameters({@ManagedOperationParameter(name="x", description="Left operand"),
85     @ManagedOperationParameter(name="y", description="Right operand")})
86     public int add(int x, int y) {
87         return x + y;
88     }
89
90     /**
91      * Test method that is not exposed by the MetadataAssembler.
92      */

93     public void dontExposeMe() {
94         throw new RuntimeException JavaDoc();
95     }
96
97 }
98
Popular Tags