01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.catalina.ant;
19:
20: import org.apache.tools.ant.BuildException;
21:
22: /**
23: * Ant task that implements the JMX Get command (<code>/jmxproxy/?get</code>)
24: * supported by the Tomcat manager application.
25: *
26: * @author Peter Rossbach
27: * @version $Revision: 467222 $
28: */
29: public class JMXGetTask extends AbstractCatalinaTask {
30:
31: // Properties
32:
33: /**
34: * The full bean name
35: */
36: protected String bean = null;
37:
38: /**
39: * The attribute you wish to alter
40: */
41: protected String attribute = null;
42:
43: // Public Methods
44:
45: /**
46: * Get method for the bean name
47: * @return Bean name
48: */
49: public String getBean() {
50: return this .bean;
51: }
52:
53: /**
54: * Set method for the bean name
55: * @param bean Bean name
56: */
57: public void setBean(String bean) {
58: this .bean = bean;
59: }
60:
61: /**
62: * Get method for the attribute name
63: * @return Attribute name
64: */
65: public String getAttribute() {
66: return this .attribute;
67: }
68:
69: /**
70: * Set method for the attribute name
71: * @param attribute Attribute name
72: */
73: public void setAttribute(String attribute) {
74: this .attribute = attribute;
75: }
76:
77: /**
78: * Execute the requested operation.
79: *
80: * @exception BuildException if an error occurs
81: */
82: public void execute() throws BuildException {
83: super .execute();
84: if (bean == null || attribute == null) {
85: throw new BuildException(
86: "Must specify 'bean' and 'attribute' attributes");
87: }
88: log("Getting attribute " + attribute + " in bean " + bean);
89: execute("/jmxproxy/?get=" + bean + "&att=" + attribute);
90: }
91: }
|