01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.management.jmx.export;
19:
20: import javax.management.JMException;
21: import javax.management.ObjectName;
22:
23: import org.apache.cxf.management.ManagedComponent;
24: import org.apache.cxf.management.annotation.ManagedAttribute;
25: import org.apache.cxf.management.annotation.ManagedNotification;
26: import org.apache.cxf.management.annotation.ManagedNotifications;
27: import org.apache.cxf.management.annotation.ManagedOperation;
28: import org.apache.cxf.management.annotation.ManagedOperationParameter;
29: import org.apache.cxf.management.annotation.ManagedOperationParameters;
30: import org.apache.cxf.management.annotation.ManagedResource;
31:
32: @ManagedResource(componentName="AnnotationTest",description="My Managed Bean",persistPolicy="OnUpdate",currencyTimeLimit=15,log=false,logFile="jmx.log",persistPeriod=200,persistLocation="/local/work",persistName="bar.jmx")
33: @ManagedNotifications({@ManagedNotification(name="My Notification",notificationTypes={"type.foo","type.bar"})})
34: public class AnnotationTestInstrumentation implements ManagedComponent {
35:
36: private String name;
37:
38: private String nickName;
39:
40: private int age;
41:
42: private boolean isSuperman;
43:
44: @ManagedAttribute(description="The Age Attribute",currencyTimeLimit=15)
45: public int getAge() {
46: return age;
47: }
48:
49: public void setAge(int a) {
50: this .age = a;
51: }
52:
53: @ManagedOperation(currencyTimeLimit=30)
54: public long myOperation() {
55: return 1L;
56: }
57:
58: @ManagedAttribute(description="The Name Attribute",currencyTimeLimit=20,defaultValue="bar",persistPolicy="OnUpdate")
59: public void setName(String n) {
60: this .name = n;
61: }
62:
63: @ManagedAttribute(defaultValue="bar",persistPeriod=300)
64: public String getName() {
65: return name;
66: }
67:
68: @ManagedAttribute(defaultValue="barasd",description="The Nick Name Attribute")
69: public String getNickName() {
70: return this .nickName;
71: }
72:
73: public void setNickName(String n) {
74: this .nickName = n;
75: }
76:
77: @ManagedAttribute(description="The Is Superman Attribute")
78: public void setSuperman(boolean super man) {
79: this .isSuperman = super man;
80: }
81:
82: public boolean isSuperman() {
83: return isSuperman;
84: }
85:
86: @ManagedOperation(description="Add Two Numbers Together")
87: @ManagedOperationParameters({@ManagedOperationParameter(name="x",description="Left operand"),@ManagedOperationParameter(name="y",description="Right operand")})
88: public int add(int x, int y) {
89: return x + y;
90: }
91:
92: public ObjectName getObjectName() throws JMException {
93: return new ObjectName(
94: "org.apache.cxf:type=AnnotationTestInstrumentation");
95: }
96:
97: }
|