KickJava   Java API By Example, From Geeks To Geeks.

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


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 Get command (<code>/jmxproxy/?get</code>)
27  * supported by the Tomcat manager application.
28  *
29  * @author Peter Rossbach
30  * @version $Revision: 467222 $
31  */

32 public class JMXGetTask 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     // Public Methods
47

48     /**
49      * Get method for the bean name
50      * @return Bean name
51      */

52     public String JavaDoc getBean () {
53         return this.bean;
54     }
55
56     /**
57      * Set method for the bean name
58      * @param bean Bean name
59      */

60     public void setBean (String JavaDoc bean) {
61         this.bean = bean;
62     }
63
64     /**
65      * Get method for the attribute name
66      * @return Attribute name
67      */

68     public String JavaDoc getAttribute () {
69         return this.attribute;
70     }
71
72     /**
73      * Set method for the attribute name
74      * @param attribute Attribute name
75      */

76     public void setAttribute (String JavaDoc attribute) {
77         this.attribute = attribute;
78     }
79
80     /**
81      * Execute the requested operation.
82      *
83      * @exception BuildException if an error occurs
84      */

85     public void execute() throws BuildException {
86         super.execute();
87         if (bean == null || attribute == null) {
88             throw new BuildException
89                 ("Must specify 'bean' and 'attribute' attributes");
90         }
91         log("Getting attribute " + attribute +
92                 " in bean " + bean );
93         execute("/jmxproxy/?get=" + bean
94                 + "&att=" + attribute );
95     }
96 }
97
Popular Tags