KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > ant > JMXSetTask


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

17
18
19 package org.apache.catalina.ant;
20
21
22 import org.apache.tools.ant.BuildException;
23
24
25 /**
26  * Ant task that implements the JMX Set command (<code>/jmxproxy/?set</code>)
27  * supported by the Tomcat manager application.
28  *
29  * @author Vivek Chopra
30  * @version $Revision: 467222 $
31  */

32 public class JMXSetTask extends AbstractCatalinaTask {
33
34     // Properties
35

36     /**
37      * The full bean name
38      */

39     protected String JavaDoc bean = null;
40
41     /**
42      * The attribute you wish to alter
43      */

44     protected String JavaDoc attribute = null;
45
46     /**
47      * The new value for the attribute
48      */

49     protected String JavaDoc value = null;
50
51     // Public Methods
52

53     /**
54      * Get method for the bean name
55      * @return Bean name
56      */

57     public String JavaDoc getBean () {
58         return this.bean;
59     }
60
61     /**
62      * Set method for the bean name
63      * @param bean Bean name
64      */

65     public void setBean (String JavaDoc bean) {
66         this.bean = bean;
67     }
68
69     /**
70      * Get method for the attribute name
71      * @return Attribute name
72      */

73     public String JavaDoc getAttribute () {
74         return this.attribute;
75     }
76
77     /**
78      * Set method for the attribute name
79      * @param attribute Attribute name
80      */

81     public void setAttribute (String JavaDoc attribute) {
82         this.attribute = attribute;
83     }
84
85     /**
86      * Get method for the attribute value
87      * @return Attribute value
88      */

89     public String JavaDoc getValue () {
90         return this.value;
91     }
92
93     /**
94      * Set method for the attribute value.
95      * @param value Attribute value
96      */

97     public void setValue (String JavaDoc value) {
98         this.value = value;
99     }
100
101     /**
102      * Execute the requested operation.
103      *
104      * @exception BuildException if an error occurs
105      */

106     public void execute() throws BuildException {
107         super.execute();
108         if (bean == null || attribute == null || value == null) {
109             throw new BuildException
110                 ("Must specify 'bean', 'attribute' and 'value' attributes");
111         }
112         log("Setting attribute " + attribute +
113                             " in bean " + bean +
114                             " to " + value);
115         execute("/jmxproxy/?set=" + bean
116                 + "&att=" + attribute
117                 + "&val=" + value);
118     }
119 }
120
Popular Tags