001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.ant;
019:
020: import org.apache.tools.ant.BuildException;
021:
022: /**
023: * Ant task that implements the JMX Set command (<code>/jmxproxy/?set</code>)
024: * supported by the Tomcat manager application.
025: *
026: * @author Vivek Chopra
027: * @version $Revision: 467222 $
028: */
029: public class JMXSetTask extends AbstractCatalinaTask {
030:
031: // Properties
032:
033: /**
034: * The full bean name
035: */
036: protected String bean = null;
037:
038: /**
039: * The attribute you wish to alter
040: */
041: protected String attribute = null;
042:
043: /**
044: * The new value for the attribute
045: */
046: protected String value = null;
047:
048: // Public Methods
049:
050: /**
051: * Get method for the bean name
052: * @return Bean name
053: */
054: public String getBean() {
055: return this .bean;
056: }
057:
058: /**
059: * Set method for the bean name
060: * @param bean Bean name
061: */
062: public void setBean(String bean) {
063: this .bean = bean;
064: }
065:
066: /**
067: * Get method for the attribute name
068: * @return Attribute name
069: */
070: public String getAttribute() {
071: return this .attribute;
072: }
073:
074: /**
075: * Set method for the attribute name
076: * @param attribute Attribute name
077: */
078: public void setAttribute(String attribute) {
079: this .attribute = attribute;
080: }
081:
082: /**
083: * Get method for the attribute value
084: * @return Attribute value
085: */
086: public String getValue() {
087: return this .value;
088: }
089:
090: /**
091: * Set method for the attribute value.
092: * @param value Attribute value
093: */
094: public void setValue(String value) {
095: this .value = value;
096: }
097:
098: /**
099: * Execute the requested operation.
100: *
101: * @exception BuildException if an error occurs
102: */
103: public void execute() throws BuildException {
104: super .execute();
105: if (bean == null || attribute == null || value == null) {
106: throw new BuildException(
107: "Must specify 'bean', 'attribute' and 'value' attributes");
108: }
109: log("Setting attribute " + attribute + " in bean " + bean
110: + " to " + value);
111: execute("/jmxproxy/?set=" + bean + "&att=" + attribute
112: + "&val=" + value);
113: }
114: }
|