JMXAccessorSetTask (Apache Tomcat 10.1.57 API Documentation)
Description: declaration: package: org.apache.catalina.ant.jmx, class: JMXAccessorSetTask

# Class JMXAccessorSetTask

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.catalina.ant.BaseRedirectorHelperTask
org.apache.catalina.ant.jmx.JMXAccessorTask
org.apache.catalina.ant.jmx.JMXAccessorSetTask

All Implemented Interfaces:
  `Cloneable`

public class JMXAccessorSetTask extends JMXAccessorTask
Access JMX JSR 160 MBeans Server.

- Get Mbeans attributes
- Show Get result as Ant console log
- Bind Get result as Ant properties

Examples: Set a Mbean Manager attribute maxActiveSessions. Set this attribute with fresh jmx connection without save reference

      <jmx:set
              host="127.0.0.1"
              port="9014"
              ref=""
              name="Catalina:type=Manager,context="/ClusterTest",host=localhost"
              attribute="maxActiveSessions"
              value="100"
              type="int"
              echo="false">
          />

First call to a remote MBean server save the JMXConnection a reference jmx.server

These tasks require Ant 1.6 or later interface.

Since:
  5.5.10

- ## Field Summary

  ### Fields inherited from class JMXAccessorTask

  `JMX_SERVICE_PREFIX, JMX_SERVICE_SUFFIX`

  ### Fields inherited from class BaseRedirectorHelperTask

  `alwaysLog, failOnError, redirectErrStream, redirector, redirectorConfigured, redirectorElement, redirectOutput, redirectOutStream`

  ### Fields inherited from class org.apache.tools.ant.Task

  `target, taskName, taskType, wrapper`

  ### Fields inherited from class org.apache.tools.ant.ProjectComponent

  `description, location, project`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JMXAccessorSetTask()`
  Constructs a new JMXAccessorSetTask.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getAttribute()`
  Get the MBean attribute name.
  `protected String`
  `getMBeanAttributeType(MBeanServerConnection jmxServerConnection, String name, String attribute)`
  Get MBean Attribute from Mbean Server
  `String`
  `getType()`
  Get the value type.
  `String`
  `getValue()`
  Get the attribute value.
  `boolean`
  `isConvert()`
  Get the convert flag.
  `String`
  `jmxExecute(MBeanServerConnection jmxServerConnection)`
  Execute the specified command, based on the configured properties.
  `protected String`
  `jmxSet(MBeanServerConnection jmxServerConnection, String name)`
  Set property value.
  `void`
  `setAttribute(String attribute)`
  Set the MBean attribute name.
  `void`
  `setConvert(boolean convert)`
  Set the convert flag.
  `void`
  `setType(String valueType)`
  Set the value type.
  `void`
  `setValue(String value)`
  Set the attribute value.

  ### Methods inherited from class JMXAccessorTask

  `accessJMXConnection, convertStringToType, createJMXConnection, createProperty, createProperty, echoResult, execute, getDelimiter, getHost, getIf, getJMXConnection, getName, getPassword, getPort, getProperty, getRef, getResultproperty, getUnless, getUrl, getUsername, isEcho, isSeparatearrayresults, isUseRef, setDelimiter, setEcho, setHost, setIf, setName, setPassword, setPort, setProperty, setRef, setResultproperty, setSeparatearrayresults, setUnless, setUrl, setUsername, testIfCondition, testUnlessCondition`

  ### Methods inherited from class BaseRedirectorHelperTask

  `addConfiguredRedirector, closeRedirector, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, handleOutput, isFailOnError, openRedirector, setAlwaysLog, setAppend, setCreateEmptyFiles, setError, setErrorProperty, setFailonerror, setLogError, setOutput, setOutputproperty`

  ### Methods inherited from class org.apache.tools.ant.Task

  `bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleInput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`

  ### Methods inherited from class org.apache.tools.ant.ProjectComponent

  `clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject`

  ### Methods inherited from class Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### JMXAccessorSetTask

    public JMXAccessorSetTask()
    Constructs a new JMXAccessorSetTask.

- ## Method Details

  - ### getAttribute

    public String getAttribute()
    Get the MBean attribute name.
    Returns:
      the attribute name

  - ### setAttribute

    public void setAttribute(String attribute)
    Set the MBean attribute name.
    Parameters:
      `attribute` - the attribute to set

  - ### getValue

    public String getValue()
    Get the attribute value.
    Returns:
      the value

  - ### setValue

    public void setValue(String value)
    Set the attribute value.
    Parameters:
      `value` - the value to set

  - ### getType

    public String getType()
    Get the value type.
    Returns:
      the type

  - ### setType

    public void setType(String valueType)
    Set the value type.
    Parameters:
      `valueType` - the type to set

  - ### isConvert

    public boolean isConvert()
    Get the convert flag.
    Returns:
      the convert flag

  - ### setConvert

    public void setConvert(boolean convert)
    Set the convert flag.
    Parameters:
      `convert` - the flag to set

  - ### jmxExecute

    public String jmxExecute(MBeanServerConnection jmxServerConnection) throws Exception
    Description copied from class: `JMXAccessorTask`
    Execute the specified command, based on the configured properties. The input stream will be closed upon completion of this task, whether it was executed successfully or not.
    Overrides:
      `jmxExecute` in class `JMXAccessorTask`
    Parameters:
      `jmxServerConnection` - The JMX connection that should be used
    Returns:
      An error message string in some situations
    Throws:
      `Exception` - if an error occurs

  - ### jmxSet

    protected String jmxSet(MBeanServerConnection jmxServerConnection, String name) throws Exception
    Set property value.
    Parameters:
      `jmxServerConnection` - Connection to the JMX server
      `name` - The MBean name
    Returns:
      null (no error message to report other than exception)
    Throws:
      `Exception` - An error occurred

  - ### getMBeanAttributeType

    protected String getMBeanAttributeType(MBeanServerConnection jmxServerConnection, String name, String attribute) throws Exception
    Get MBean Attribute from Mbean Server
    Parameters:
      `jmxServerConnection` - The JMX connection name
      `name` - The MBean name
      `attribute` - The attribute name
    Returns:
      The type of the attribute
    Throws:
      `Exception` - An error occurred